Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade go #98

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.21.x]
go-version: [1.23.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -21,6 +21,6 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.55
version: v1.63
- run: go vet ./...
- run: go test ./...
13 changes: 13 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
linters-settings:
gocritic:
disabled-checks:
- ifElseChain
- elseif

linters:
enable:
- gofmt
- govet
- gocritic
- unconvert
- revive
5 changes: 2 additions & 3 deletions examplebot/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

type extension struct{}

func (e *extension) Run(bot *slackbot.Bot, channel string, args []string) (string, error) {
func (e *extension) Run(bot *slackbot.Bot, _ string, args []string) (string, error) {
app := kingpin.New("examplebot", "Kingpin extension")
app.Terminate(nil)
stringBuffer := new(bytes.Buffer)
Expand All @@ -32,8 +32,7 @@ func (e *extension) Run(bot *slackbot.Bot, channel string, args []string) (strin
return fmt.Sprintf("I would have run: `%#v`", cmd), nil
}

switch cmd {
case testCmd.FullCommand():
if cmd == testCmd.FullCommand() {
return *testCmdEchoFlag, nil
}
return cmd, nil
Expand Down
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module github.com/keybase/slackbot

go 1.19
go 1.21

toolchain go1.23.4

require (
github.com/keybase/go-keybase-chat-bot v0.0.0-20231213202706-1bdf50c0adf4
github.com/keybase/go-keybase-chat-bot v0.0.0-20250106203511-859265729a56
github.com/nlopes/slack v0.1.1-0.20180101221843-107290b5bbaf
gopkg.in/alecthomas/kingpin.v2 v2.2.6
)
Expand All @@ -15,7 +17,7 @@ require (
github.com/kr/text v0.2.0 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/stretchr/testify v1.10.0 // indirect
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/keybase/go-keybase-chat-bot v0.0.0-20231213202706-1bdf50c0adf4 h1:PlYdzv1QYDX8aYRJRa5Nz/CP7mqXcUn5kZww5+A3Oaw=
github.com/keybase/go-keybase-chat-bot v0.0.0-20231213202706-1bdf50c0adf4/go.mod h1:ebfhBYCricPJlrhrYBw6Z0kGDoa5vkeUgPCXS1RPp/4=
github.com/keybase/go-keybase-chat-bot v0.0.0-20250106203511-859265729a56 h1:w8ikAizh5hbXZxBXbees5iOxOoi7nH/qp1lJQ3pOPiY=
github.com/keybase/go-keybase-chat-bot v0.0.0-20250106203511-859265729a56/go.mod h1:cmXzSxB8TNJdxMKcmywTHsbv+H3WZ/92lP9nyEbCGNQ=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand All @@ -20,8 +20,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 h1:DZshvxDdVoeKIbudAdFEKi+f70l51luSy/7b76ibTY0=
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
Expand Down
4 changes: 2 additions & 2 deletions hybrid.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func newHybridRunner(runner BotCommandRunner, channel string) *hybridRunner {
}
}

func (r *hybridRunner) RunCommand(args []string, channel string) error {
func (r *hybridRunner) RunCommand(args []string, _ string) error {
return r.runner.RunCommand(args, r.channel)

}
Expand All @@ -36,7 +36,7 @@ func NewHybridBackend(backends ...HybridBackendMember) *HybridBackend {
}
}

func (b *HybridBackend) SendMessage(text string, channel string) {
func (b *HybridBackend) SendMessage(text string, _ string) {
for _, backend := range b.backends {
backend.Backend.SendMessage(text, backend.Channel)
}
Expand Down
2 changes: 1 addition & 1 deletion kbchat.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (b *KeybaseChatBotBackend) SendMessage(text string, convID string) {
return
}
log.Printf("sending message: convID: %s text: %s", convID, text)
if _, err := b.kbc.SendMessageByConvID(chat1.ConvIDStr(convID), text); err != nil {
if _, err := b.kbc.SendMessageByConvID(chat1.ConvIDStr(convID), "%s", text); err != nil {
log.Printf("SendMessage: failed to send: %s\n", err)
}
}
Expand Down
15 changes: 0 additions & 15 deletions keybot/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,6 @@ func TestAddBasicCommands(t *testing.T) {
addBasicCommands(bot)
}

func TestBuildDarwin(t *testing.T) {
bot, err := slackbot.NewTestBot()
if err != nil {
t.Fatal(err)
}
ext := &darwinbot{}
out, err := ext.Run(bot, "", []string{"build", "darwin"})
if err != nil {
t.Fatal(err)
}
if out != "I would have run: `\"build darwin\"`" {
t.Errorf("Unexpected output: %s", out)
}
}

func TestPromoteRelease(t *testing.T) {
bot, err := slackbot.NewTestBot()
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions keybot/winbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (d *winbot) Run(bot *slackbot.Bot, channel string, args []string) (string,
logf.Close()
return string(stdoutStderr), err
}
commit := strings.TrimSpace(string(stdoutStderr[:]))
commit := strings.TrimSpace(string(stdoutStderr))
if commit != "HEAD" {
gitCmd = exec.Command(
"git.exe",
Expand Down Expand Up @@ -294,7 +294,7 @@ func (d *winbot) Run(bot *slackbot.Bot, channel string, args []string) (string,
scanner := bufio.NewScanner(f)
for scanner.Scan() {
lines[lineCount%numLogLines] = scanner.Text()
lineCount += 1
lineCount++
}
if err := scanner.Err(); err != nil {
bot.SendMessage(autoBuild+"Error scanning "+logFileName+": "+err.Error(), channel)
Expand All @@ -315,7 +315,7 @@ func (d *winbot) Run(bot *slackbot.Bot, channel string, args []string) (string,
msg := fmt.Sprintf("%s, log upload error %s", resultMsg, err2.Error())
bot.SendMessage(msg, channel)
} else {
msg := fmt.Sprintf("%s, view log at %s", resultMsg, string(urlBytes[:]))
msg := fmt.Sprintf("%s, view log at %s", resultMsg, string(urlBytes))
bot.SendMessage(msg, channel)
}
}()
Expand Down Expand Up @@ -374,7 +374,7 @@ func (d *winbot) Run(bot *slackbot.Bot, channel string, args []string) (string,
bot.SendMessage(string(stdoutStderr), channel)

case restartCmd.FullCommand():
os.Exit(0)
os.Exit(0) //nolint
}
return cmd, nil
}
Expand Down
2 changes: 1 addition & 1 deletion send/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func main() {
}

api := slack.New(slackbot.GetTokenFromEnv())
//api.SetDebug(true)
// api.SetDebug(true)

channelIDs, err := slackbot.LoadChannelIDs(*api)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

// SlackBotBackend is a Slack bot backend
type SlackBotBackend struct {
type SlackBotBackend struct { //nolint
api *slack.Client
rtm *slack.RTM

Expand All @@ -17,7 +17,7 @@ type SlackBotBackend struct {
// NewSlackBotBackend constructs a bot backend from a Slack token
func NewSlackBotBackend(token string) (BotBackend, error) {
api := slack.New(token)
//api.SetDebug(true)
// api.SetDebug(true)

channelIDs, err := LoadChannelIDs(*api)
if err != nil {
Expand Down Expand Up @@ -80,10 +80,10 @@ Loop:
}

case *slack.PresenceChangeEvent:
//log.Printf("Presence Change: %v\n", ev)
// log.Printf("Presence Change: %v\n", ev)

case *slack.LatencyReport:
//log.Printf("Current latency: %v\n", ev.Value)
// log.Printf("Current latency: %v\n", ev.Value)

case *slack.RTMError:
log.Printf("Error: %s\n", ev.Error())
Expand Down
5 changes: 2 additions & 3 deletions tuxbot/tuxbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
kingpin "gopkg.in/alecthomas/kingpin.v2"
)

func (t *tuxbot) linuxBuildFunc(channel string, args []string, skipCI bool, nightly bool) (string, error) {
func (t *tuxbot) linuxBuildFunc(channel string, _ []string, skipCI bool, nightly bool) (string, error) {
currentUser, err := user.Current()
if err != nil {
return "", err
Expand Down Expand Up @@ -73,8 +73,7 @@ func (t *tuxbot) Run(bot *slackbot.Bot, channel string, args []string) (string,
return usage, err
}

switch cmd {
case buildLinux.FullCommand():
if cmd == buildLinux.FullCommand() {
if bot.Config().DryRun() {
if *buildLinuxSkipCI {
return "Dry Run: Doing that would run `prerelease.sh` with NOWAIT=1 set", nil
Expand Down
Loading