Skip to content

Commit 34bdec4

Browse files
authored
upgrade go (#98)
* upgrade go * x
1 parent f0601b6 commit 34bdec4

File tree

12 files changed

+40
-42
lines changed

12 files changed

+40
-42
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
test:
1111
strategy:
1212
matrix:
13-
go-version: [1.21.x]
13+
go-version: [1.23.x]
1414
os: [ubuntu-latest, macos-latest]
1515
runs-on: ${{ matrix.os }}
1616
steps:
@@ -21,6 +21,6 @@ jobs:
2121
- name: golangci-lint
2222
uses: golangci/golangci-lint-action@v3
2323
with:
24-
version: v1.55
24+
version: v1.63
2525
- run: go vet ./...
2626
- run: go test ./...

.golangci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
linters-settings:
2+
gocritic:
3+
disabled-checks:
4+
- ifElseChain
5+
- elseif
6+
7+
linters:
8+
enable:
9+
- gofmt
10+
- govet
11+
- gocritic
12+
- unconvert
13+
- revive

examplebot/extension.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
type extension struct{}
1616

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

35-
switch cmd {
36-
case testCmd.FullCommand():
35+
if cmd == testCmd.FullCommand() {
3736
return *testCmdEchoFlag, nil
3837
}
3938
return cmd, nil

go.mod

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
module github.com/keybase/slackbot
22

3-
go 1.19
3+
go 1.21
4+
5+
toolchain go1.23.4
46

57
require (
6-
github.com/keybase/go-keybase-chat-bot v0.0.0-20231213202706-1bdf50c0adf4
8+
github.com/keybase/go-keybase-chat-bot v0.0.0-20250106203511-859265729a56
79
github.com/nlopes/slack v0.1.1-0.20180101221843-107290b5bbaf
810
gopkg.in/alecthomas/kingpin.v2 v2.2.6
911
)
@@ -15,7 +17,7 @@ require (
1517
github.com/kr/text v0.2.0 // indirect
1618
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
1719
github.com/pmezard/go-difflib v1.0.0 // indirect
18-
github.com/stretchr/testify v1.8.4 // indirect
20+
github.com/stretchr/testify v1.10.0 // indirect
1921
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 // indirect
2022
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
2123
gopkg.in/yaml.v2 v2.4.0 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
66
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
77
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
88
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9-
github.com/keybase/go-keybase-chat-bot v0.0.0-20231213202706-1bdf50c0adf4 h1:PlYdzv1QYDX8aYRJRa5Nz/CP7mqXcUn5kZww5+A3Oaw=
10-
github.com/keybase/go-keybase-chat-bot v0.0.0-20231213202706-1bdf50c0adf4/go.mod h1:ebfhBYCricPJlrhrYBw6Z0kGDoa5vkeUgPCXS1RPp/4=
9+
github.com/keybase/go-keybase-chat-bot v0.0.0-20250106203511-859265729a56 h1:w8ikAizh5hbXZxBXbees5iOxOoi7nH/qp1lJQ3pOPiY=
10+
github.com/keybase/go-keybase-chat-bot v0.0.0-20250106203511-859265729a56/go.mod h1:cmXzSxB8TNJdxMKcmywTHsbv+H3WZ/92lP9nyEbCGNQ=
1111
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
1212
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
1313
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
@@ -20,8 +20,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
2020
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2121
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
2222
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
23-
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
24-
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
23+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
24+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
2525
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 h1:DZshvxDdVoeKIbudAdFEKi+f70l51luSy/7b76ibTY0=
2626
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
2727
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=

hybrid.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func newHybridRunner(runner BotCommandRunner, channel string) *hybridRunner {
1616
}
1717
}
1818

19-
func (r *hybridRunner) RunCommand(args []string, channel string) error {
19+
func (r *hybridRunner) RunCommand(args []string, _ string) error {
2020
return r.runner.RunCommand(args, r.channel)
2121

2222
}
@@ -36,7 +36,7 @@ func NewHybridBackend(backends ...HybridBackendMember) *HybridBackend {
3636
}
3737
}
3838

39-
func (b *HybridBackend) SendMessage(text string, channel string) {
39+
func (b *HybridBackend) SendMessage(text string, _ string) {
4040
for _, backend := range b.backends {
4141
backend.Backend.SendMessage(text, backend.Channel)
4242
}

kbchat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (b *KeybaseChatBotBackend) SendMessage(text string, convID string) {
3737
return
3838
}
3939
log.Printf("sending message: convID: %s text: %s", convID, text)
40-
if _, err := b.kbc.SendMessageByConvID(chat1.ConvIDStr(convID), text); err != nil {
40+
if _, err := b.kbc.SendMessageByConvID(chat1.ConvIDStr(convID), "%s", text); err != nil {
4141
log.Printf("SendMessage: failed to send: %s\n", err)
4242
}
4343
}

keybot/main_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,6 @@ func TestAddBasicCommands(t *testing.T) {
1818
addBasicCommands(bot)
1919
}
2020

21-
func TestBuildDarwin(t *testing.T) {
22-
bot, err := slackbot.NewTestBot()
23-
if err != nil {
24-
t.Fatal(err)
25-
}
26-
ext := &darwinbot{}
27-
out, err := ext.Run(bot, "", []string{"build", "darwin"})
28-
if err != nil {
29-
t.Fatal(err)
30-
}
31-
if out != "I would have run: `\"build darwin\"`" {
32-
t.Errorf("Unexpected output: %s", out)
33-
}
34-
}
35-
3621
func TestPromoteRelease(t *testing.T) {
3722
bot, err := slackbot.NewTestBot()
3823
if err != nil {

keybot/winbot.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func (d *winbot) Run(bot *slackbot.Bot, channel string, args []string) (string,
209209
logf.Close()
210210
return string(stdoutStderr), err
211211
}
212-
commit := strings.TrimSpace(string(stdoutStderr[:]))
212+
commit := strings.TrimSpace(string(stdoutStderr))
213213
if commit != "HEAD" {
214214
gitCmd = exec.Command(
215215
"git.exe",
@@ -294,7 +294,7 @@ func (d *winbot) Run(bot *slackbot.Bot, channel string, args []string) (string,
294294
scanner := bufio.NewScanner(f)
295295
for scanner.Scan() {
296296
lines[lineCount%numLogLines] = scanner.Text()
297-
lineCount += 1
297+
lineCount++
298298
}
299299
if err := scanner.Err(); err != nil {
300300
bot.SendMessage(autoBuild+"Error scanning "+logFileName+": "+err.Error(), channel)
@@ -315,7 +315,7 @@ func (d *winbot) Run(bot *slackbot.Bot, channel string, args []string) (string,
315315
msg := fmt.Sprintf("%s, log upload error %s", resultMsg, err2.Error())
316316
bot.SendMessage(msg, channel)
317317
} else {
318-
msg := fmt.Sprintf("%s, view log at %s", resultMsg, string(urlBytes[:]))
318+
msg := fmt.Sprintf("%s, view log at %s", resultMsg, string(urlBytes))
319319
bot.SendMessage(msg, channel)
320320
}
321321
}()
@@ -374,7 +374,7 @@ func (d *winbot) Run(bot *slackbot.Bot, channel string, args []string) (string,
374374
bot.SendMessage(string(stdoutStderr), channel)
375375

376376
case restartCmd.FullCommand():
377-
os.Exit(0)
377+
os.Exit(0) //nolint
378378
}
379379
return cmd, nil
380380
}

send/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func main() {
3232
}
3333

3434
api := slack.New(slackbot.GetTokenFromEnv())
35-
//api.SetDebug(true)
35+
// api.SetDebug(true)
3636

3737
channelIDs, err := slackbot.LoadChannelIDs(*api)
3838
if err != nil {

slack.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
// SlackBotBackend is a Slack bot backend
10-
type SlackBotBackend struct {
10+
type SlackBotBackend struct { //nolint
1111
api *slack.Client
1212
rtm *slack.RTM
1313

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

2222
channelIDs, err := LoadChannelIDs(*api)
2323
if err != nil {
@@ -80,10 +80,10 @@ Loop:
8080
}
8181

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

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

8888
case *slack.RTMError:
8989
log.Printf("Error: %s\n", ev.Error())

tuxbot/tuxbot.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
kingpin "gopkg.in/alecthomas/kingpin.v2"
2020
)
2121

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

76-
switch cmd {
77-
case buildLinux.FullCommand():
76+
if cmd == buildLinux.FullCommand() {
7877
if bot.Config().DryRun() {
7978
if *buildLinuxSkipCI {
8079
return "Dry Run: Doing that would run `prerelease.sh` with NOWAIT=1 set", nil

0 commit comments

Comments
 (0)