Skip to content

Commit be5d0f7

Browse files
authored
Go modernize + upgrade Go (#413)
* Ran `go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./...` * Minimum Go version 1.23 (removed build tags) * Upgrade tinygo
1 parent 9ed94a8 commit be5d0f7

36 files changed

+154
-267
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
test:
2222
strategy:
2323
matrix:
24-
go-version: [1.22.x, 1.23.x, 1.24.x]
24+
go-version: [1.23.x, 1.24.x, 1.25.x]
2525
os: [ubuntu-latest]
2626
runs-on: ${{ matrix.os }}
2727
timeout-minutes: 10

.github/workflows/validate.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
linters:
2222
strategy:
2323
matrix:
24-
go-version: [1.24.x]
24+
go-version: [1.25.x]
2525
os: [ubuntu-latest]
2626
runs-on: ${{ matrix.os }}
2727
timeout-minutes: 10
@@ -35,5 +35,5 @@ jobs:
3535
- name: lint
3636
uses: golangci/golangci-lint-action@v8
3737
with:
38-
version: v2.1.6
38+
version: v2.5.0
3939
args: --print-resources-usage --timeout=10m --verbose

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ ci: prepare
5555
if [ `arch` == 'x86_64' ]; then \
5656
sudo apt-get -y -q update; \
5757
sudo apt-get -y -q install build-essential; \
58-
wget -q https://github.com/tinygo-org/tinygo/releases/download/v0.38.0/tinygo_0.38.0_amd64.deb; \
59-
sudo dpkg -i tinygo_0.38.0_amd64.deb; \
58+
wget -q https://github.com/tinygo-org/tinygo/releases/download/v0.39.0/tinygo_0.39.0_amd64.deb; \
59+
sudo dpkg -i tinygo_0.39.0_amd64.deb; \
6060
export PATH=$$PATH:/usr/local/tinygo/bin; \
6161
fi
6262
go test -v ./... ./_generated

gen/elem.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package gen
22

33
import (
44
"fmt"
5+
"slices"
56
"strings"
67
)
78

@@ -601,12 +602,7 @@ func (sf *StructField) HasTagPart(pname string) bool {
601602
if len(sf.FieldTagParts) < 2 {
602603
return false
603604
}
604-
for _, p := range sf.FieldTagParts[1:] {
605-
if p == pname {
606-
return true
607-
}
608-
}
609-
return false
605+
return slices.Contains(sf.FieldTagParts[1:], pname)
610606
}
611607

612608
type ShimMode int

gen/encode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (e *encodeGen) Apply(dirs []string) error {
2727
return nil
2828
}
2929

30-
func (e *encodeGen) writeAndCheck(typ string, argfmt string, arg interface{}) {
30+
func (e *encodeGen) writeAndCheck(typ string, argfmt string, arg any) {
3131
if e.ctx.compFloats && typ == "Float64" {
3232
typ = "Float"
3333
}

gen/marshal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (m *marshalGen) Execute(p Elem, ctx Context) error {
6262
return m.p.err
6363
}
6464

65-
func (m *marshalGen) rawAppend(typ string, argfmt string, arg interface{}) {
65+
func (m *marshalGen) rawAppend(typ string, argfmt string, arg any) {
6666
if m.ctx.compFloats && typ == "Float64" {
6767
typ = "Float"
6868
}

gen/spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ func (p *printer) comment(s string) {
462462
p.print("\n// " + s)
463463
}
464464

465-
func (p *printer) printf(format string, args ...interface{}) {
465+
func (p *printer) printf(format string, args ...any) {
466466
if p.err == nil {
467467
_, p.err = fmt.Fprintf(p.w, format, args...)
468468
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/tinylib/msgp
22

3-
go 1.22
3+
go 1.23
44

55
require (
66
github.com/philhofer/fwd v1.2.0

issue185_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func TestIssue185Overlap(t *testing.T) {
133133
}
134134
}
135135

136-
func loadVars(t *testing.T, tpl *template.Template, tplData interface{}) (vars extractedVars, err error) {
136+
func loadVars(t *testing.T, tpl *template.Template, tplData any) (vars extractedVars, err error) {
137137
tempDir := t.TempDir()
138138

139139
if !debugTemp {
@@ -218,7 +218,7 @@ func extractVars(file string) (extractedVars, error) {
218218
return vars, nil
219219
}
220220

221-
func goGenerateTpl(cwd, tfile string, tpl *template.Template, tplData interface{}) error {
221+
func goGenerateTpl(cwd, tfile string, tpl *template.Template, tplData any) error {
222222
outf, err := os.OpenFile(tfile, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0o600)
223223
if err != nil {
224224
return err

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var (
4444
directives = stringArrFlags{}
4545
)
4646

47-
func diagf(f string, args ...interface{}) {
47+
func diagf(f string, args ...any) {
4848
if !*verbose {
4949
return
5050
}

0 commit comments

Comments
 (0)