Skip to content

Commit d737dbc

Browse files
authored
go1.25 (#102)
* go1.25 * x * x
1 parent 8402705 commit d737dbc

File tree

13 files changed

+230
-66
lines changed

13 files changed

+230
-66
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,53 @@
11
name: CI
2+
23
on:
34
push:
45
branches:
56
- master
67
pull_request:
78
branches:
89
- master
10+
schedule:
11+
# Run daily at 2 AM UTC to check for new vulnerabilities
12+
- cron: "0 2 * * *"
13+
14+
permissions:
15+
contents: read
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
921
jobs:
1022
test:
23+
timeout-minutes: 15
1124
strategy:
1225
matrix:
13-
go-version: [1.23.x]
26+
go-version: [1.25.x, 1.24.x]
1427
os: [ubuntu-latest, macos-latest]
1528
runs-on: ${{ matrix.os }}
1629
steps:
17-
- uses: actions/setup-go@v3
30+
- uses: actions/checkout@v6
31+
with:
32+
persist-credentials: false
33+
34+
- uses: actions/setup-go@v6
1835
with:
1936
go-version: ${{ matrix.go-version }}
20-
- uses: actions/checkout@v3
37+
cache: true
38+
2139
- name: golangci-lint
22-
uses: golangci/golangci-lint-action@v3
40+
uses: golangci/golangci-lint-action@v9
41+
with:
42+
version: v2.7.2
43+
44+
- name: Build
45+
run: go build -v ./...
46+
47+
- name: Run govulncheck
48+
uses: golang/govulncheck-action@v1
2349
with:
24-
version: v1.63
25-
- run: go vet ./...
26-
- run: go test ./...
50+
go-version-input: ${{ matrix.go-version }}
51+
52+
- name: Test
53+
run: go test -race ./...

.golangci.yml

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,66 @@
1-
linters-settings:
2-
gocritic:
3-
disabled-checks:
4-
- ifElseChain
5-
- elseif
1+
version: "2"
2+
3+
run:
4+
timeout: 5m
5+
tests: true
6+
7+
formatters:
8+
enable:
9+
- gofumpt
610

711
linters:
812
enable:
9-
- gofmt
10-
- govet
11-
- gocritic
12-
- unconvert
13-
- revive
13+
# Core recommended linters
14+
- errcheck # Checks for unchecked errors
15+
- govet # Go vet checks
16+
- ineffassign # Detects ineffectual assignments
17+
- staticcheck # Advanced static analysis
18+
- unused # Finds unused code
19+
20+
# Code quality
21+
- misspell # Finds commonly misspelled words
22+
- unconvert # Unnecessary type conversions (already enabled in original)
23+
- unparam # Finds unused function parameters
24+
- gocritic # Various checks (already enabled in original)
25+
- revive # Fast, configurable linter (already enabled in original)
26+
27+
# Security and best practices
28+
- gosec # Security-focused linter
29+
- bodyclose # Checks HTTP response body closed
30+
- noctx # Finds HTTP requests without context
31+
32+
settings:
33+
gocritic:
34+
disabled-checks:
35+
- ifElseChain
36+
- elseif
37+
38+
govet:
39+
enable-all: true
40+
disable:
41+
- shadow
42+
- fieldalignment
43+
44+
revive:
45+
enable-all-rules: false
46+
47+
exclusions:
48+
rules:
49+
# Exclude specific revive rules
50+
- linters:
51+
- revive
52+
text: "package-comments"
53+
54+
- linters:
55+
- revive
56+
text: "exported"
57+
58+
# Exclude specific staticcheck rules
59+
- linters:
60+
- staticcheck
61+
text: "ST1005"
62+
63+
# Exclude specific gocritic rules
64+
- linters:
65+
- gocritic
66+
text: "ifElseChain"

bot.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,21 @@ func (b *Bot) HelpMessage() string {
6969
w := new(tabwriter.Writer)
7070
buf := new(bytes.Buffer)
7171
w.Init(buf, 8, 8, 8, ' ', 0)
72-
fmt.Fprintln(w, "Command\tDescription")
72+
if _, err := fmt.Fprintln(w, "Command\tDescription"); err != nil {
73+
log.Printf("Error writing help header: %s", err)
74+
return "Error generating help message"
75+
}
7376
for _, trigger := range b.triggers() {
7477
command := b.commands[trigger]
75-
fmt.Fprintf(w, "%s\t%s\n", trigger, command.Description())
78+
if _, err := fmt.Fprintf(w, "%s\t%s\n", trigger, command.Description()); err != nil {
79+
log.Printf("Error writing help command: %s", err)
80+
return "Error generating help message"
81+
}
82+
}
83+
if err := w.Flush(); err != nil {
84+
log.Printf("Error flushing help writer: %s", err)
85+
return "Error generating help message"
7686
}
77-
_ = w.Flush()
7887
return BlockQuote(buf.String())
7988
}
8089

cli/cli.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ func Parse(app *kingpin.Application, args []string, stringBuffer *bytes.Buffer)
3636

3737
if err != nil && stringBuffer.Len() == 0 {
3838
log.Printf("Error in parsing command: %s. got %s", args, err)
39-
_, _ = io.WriteString(stringBuffer, fmt.Sprintf("I don't know what you mean by `%s`.\nError: `%s`\nHere's my usage:\n\n", strings.Join(args, " "), err.Error()))
39+
if _, writeErr := io.WriteString(stringBuffer, fmt.Sprintf("I don't know what you mean by `%s`.\nError: `%s`\nHere's my usage:\n\n", strings.Join(args, " "), err.Error())); writeErr != nil {
40+
log.Printf("Error writing error message: %s", writeErr)
41+
}
4042
// Print out help page if there was an error parsing command
4143
app.Usage([]string{})
4244
}

command.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func (c execCommand) Run(_ string, _ []string) (string, error) {
4141
return fmt.Sprintf("I'm in dry run mode. I would have run `%s` with args: %s", c.exec, c.args), nil
4242
}
4343

44+
//nolint:gosec,noctx // Command execution is the purpose of this bot, no context available
4445
out, err := exec.Command(c.exec, c.args...).CombinedOutput()
4546
outAsString := string(out)
4647
return outAsString, err

config.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func (c *config) SetDryRun(dryRun bool) {
5454

5555
func getConfigPath() (string, error) {
5656
currentUser, err := user.Current()
57-
5857
if err != nil {
5958
return "", err
6059
}
@@ -83,13 +82,11 @@ func readConfigOrDefault() config {
8382
}
8483

8584
path, err := getConfigPath()
86-
8785
if err != nil {
8886
return defaultConfig
8987
}
9088

91-
fileBytes, err := os.ReadFile(path)
92-
89+
fileBytes, err := os.ReadFile(filepath.Clean(path))
9390
if err != nil {
9491
return defaultConfig
9592
}
@@ -115,7 +112,7 @@ func (c config) Save() error {
115112
return err
116113
}
117114

118-
err = os.WriteFile(path, b, 0644)
115+
err = os.WriteFile(filepath.Clean(path), b, 0o644) //nolint:gosec // Config file should be user-readable
119116
if err != nil {
120117
return err
121118
}

go.mod

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

3-
go 1.21
3+
go 1.24.0
44

5-
toolchain go1.23.4
5+
toolchain go1.25.5
66

77
require (
8-
github.com/keybase/go-keybase-chat-bot v0.0.0-20250106203511-859265729a56
8+
github.com/keybase/go-keybase-chat-bot v0.0.0-20251212163122-450fd0812017
99
github.com/nlopes/slack v0.1.1-0.20180101221843-107290b5bbaf
1010
gopkg.in/alecthomas/kingpin.v2 v2.2.6
1111
)
@@ -17,7 +17,7 @@ require (
1717
github.com/kr/text v0.2.0 // indirect
1818
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
1919
github.com/pmezard/go-difflib v1.0.0 // indirect
20-
github.com/stretchr/testify v1.10.0 // indirect
20+
github.com/stretchr/testify v1.11.1 // indirect
2121
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 // indirect
2222
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
2323
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-20250106203511-859265729a56 h1:w8ikAizh5hbXZxBXbees5iOxOoi7nH/qp1lJQ3pOPiY=
10-
github.com/keybase/go-keybase-chat-bot v0.0.0-20250106203511-859265729a56/go.mod h1:cmXzSxB8TNJdxMKcmywTHsbv+H3WZ/92lP9nyEbCGNQ=
9+
github.com/keybase/go-keybase-chat-bot v0.0.0-20251212163122-450fd0812017 h1:lB6jgDag58Ie9yfLSGDQiUZt60zPyRpK6aWCtovQeSo=
10+
github.com/keybase/go-keybase-chat-bot v0.0.0-20251212163122-450fd0812017/go.mod h1:wl5lBoVNkepL8Hzs7jyqg3GS6U+by4yQeNr7oT0Evt0=
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.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
24-
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
23+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
24+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ func newHybridRunner(runner BotCommandRunner, channel string) *hybridRunner {
1818

1919
func (r *hybridRunner) RunCommand(args []string, _ string) error {
2020
return r.runner.RunCommand(args, r.channel)
21-
2221
}
2322

2423
type HybridBackendMember struct {

0 commit comments

Comments
 (0)