Skip to content

Commit 562b722

Browse files
authoredFeb 7, 2024
Update to Go 1.22 (#5)
* Get ready for Go 1.22. * Fix test. * Use Go 1.22 in CI. * Use modver v2.7.0 in CI.
1 parent 53b1956 commit 562b722

File tree

8 files changed

+175
-5
lines changed

8 files changed

+175
-5
lines changed
 

‎.github/workflows/go.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Set up Go
1919
uses: actions/setup-go@v2
2020
with:
21-
go-version: 1.21
21+
go-version: 1.22
2222

2323
- name: Unit tests
2424
run: go test -coverprofile=cover.out ./...
@@ -30,7 +30,7 @@ jobs:
3030

3131
- name: Modver
3232
if: ${{ github.event_name == 'pull_request' }}
33-
uses: bobg/modver@v2.5.0
33+
uses: bobg/modver@v2.7.0
3434
with:
3535
github_token: ${{ secrets.GITHUB_TOKEN }}
3636
pull_request_url: https://github.com/${{ github.repository }}/pull/${{ github.event.number }}

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/cover.out

‎_testdata/21/foo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
var x = max(1, 2)
1+
var twentyone = max(1, 2)

‎_testdata/22/foo.go

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
func twentytwo() {
2+
for range 10 {
3+
println("hello")
4+
}
5+
}

‎api/go1.22.txt

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
pkg archive/tar, method (*Writer) AddFS(fs.FS) error #58000
2+
pkg archive/zip, method (*Writer) AddFS(fs.FS) error #54898
3+
pkg cmp, func Or[$0 comparable](...$0) $0 #60204
4+
pkg crypto/x509, func OIDFromInts([]uint64) (OID, error) #60665
5+
pkg crypto/x509, method (*CertPool) AddCertWithConstraint(*Certificate, func([]*Certificate) error) #57178
6+
pkg crypto/x509, method (OID) Equal(OID) bool #60665
7+
pkg crypto/x509, method (OID) EqualASN1OID(asn1.ObjectIdentifier) bool #60665
8+
pkg crypto/x509, method (OID) String() string #60665
9+
pkg crypto/x509, type Certificate struct, Policies []OID #60665
10+
pkg crypto/x509, type OID struct #60665
11+
pkg database/sql, method (*Null[$0]) Scan(interface{}) error #60370
12+
pkg database/sql, method (Null[$0]) Value() (driver.Value, error) #60370
13+
pkg database/sql, type Null[$0 interface{}] struct #60370
14+
pkg database/sql, type Null[$0 interface{}] struct, V $0 #60370
15+
pkg database/sql, type Null[$0 interface{}] struct, Valid bool #60370
16+
pkg debug/elf, const R_LARCH_64_PCREL = 109 #63725
17+
pkg debug/elf, const R_LARCH_64_PCREL R_LARCH #63725
18+
pkg debug/elf, const R_LARCH_ADD6 = 105 #63725
19+
pkg debug/elf, const R_LARCH_ADD6 R_LARCH #63725
20+
pkg debug/elf, const R_LARCH_ADD_ULEB128 = 107 #63725
21+
pkg debug/elf, const R_LARCH_ADD_ULEB128 R_LARCH #63725
22+
pkg debug/elf, const R_LARCH_ALIGN = 102 #63725
23+
pkg debug/elf, const R_LARCH_ALIGN R_LARCH #63725
24+
pkg debug/elf, const R_LARCH_CFA = 104 #63725
25+
pkg debug/elf, const R_LARCH_CFA R_LARCH #63725
26+
pkg debug/elf, const R_LARCH_DELETE = 101 #63725
27+
pkg debug/elf, const R_LARCH_DELETE R_LARCH #63725
28+
pkg debug/elf, const R_LARCH_PCREL20_S2 = 103 #63725
29+
pkg debug/elf, const R_LARCH_PCREL20_S2 R_LARCH #63725
30+
pkg debug/elf, const R_LARCH_SUB6 = 106 #63725
31+
pkg debug/elf, const R_LARCH_SUB6 R_LARCH #63725
32+
pkg debug/elf, const R_LARCH_SUB_ULEB128 = 108 #63725
33+
pkg debug/elf, const R_LARCH_SUB_ULEB128 R_LARCH #63725
34+
pkg debug/elf, const R_MIPS_PC32 = 248 #61974
35+
pkg debug/elf, const R_MIPS_PC32 R_MIPS #61974
36+
pkg encoding/base32, method (*Encoding) AppendDecode([]uint8, []uint8) ([]uint8, error) #53693
37+
pkg encoding/base32, method (*Encoding) AppendEncode([]uint8, []uint8) []uint8 #53693
38+
pkg encoding/base64, method (*Encoding) AppendDecode([]uint8, []uint8) ([]uint8, error) #53693
39+
pkg encoding/base64, method (*Encoding) AppendEncode([]uint8, []uint8) []uint8 #53693
40+
pkg encoding/hex, func AppendDecode([]uint8, []uint8) ([]uint8, error) #53693
41+
pkg encoding/hex, func AppendEncode([]uint8, []uint8) []uint8 #53693
42+
pkg go/ast, func NewPackage //deprecated #52463
43+
pkg go/ast, func Unparen(Expr) Expr #60061
44+
pkg go/ast, type Importer //deprecated #52463
45+
pkg go/ast, type Object //deprecated #52463
46+
pkg go/ast, type Package //deprecated #52463
47+
pkg go/ast, type Scope //deprecated #52463
48+
pkg go/types, func NewAlias(*TypeName, Type) *Alias #63223
49+
pkg go/types, func Unalias(Type) Type #63223
50+
pkg go/types, method (*Alias) Obj() *TypeName #63223
51+
pkg go/types, method (*Alias) String() string #63223
52+
pkg go/types, method (*Alias) Underlying() Type #63223
53+
pkg go/types, method (*Info) PkgNameOf(*ast.ImportSpec) *PkgName #62037
54+
pkg go/types, method (Checker) PkgNameOf(*ast.ImportSpec) *PkgName #62037
55+
pkg go/types, type Alias struct #63223
56+
pkg go/types, type Info struct, FileVersions map[*ast.File]string #62605
57+
pkg go/version, func Compare(string, string) int #62039
58+
pkg go/version, func IsValid(string) bool #62039
59+
pkg go/version, func Lang(string) string #62039
60+
pkg html/template, const ErrJSTemplate //deprecated #61619
61+
pkg io, method (*SectionReader) Outer() (ReaderAt, int64, int64) #61870
62+
pkg log/slog, func SetLogLoggerLevel(Level) Level #62418
63+
pkg math/big, method (*Rat) FloatPrec() (int, bool) #50489
64+
pkg math/rand/v2, func ExpFloat64() float64 #61716
65+
pkg math/rand/v2, func Float32() float32 #61716
66+
pkg math/rand/v2, func Float64() float64 #61716
67+
pkg math/rand/v2, func Int() int #61716
68+
pkg math/rand/v2, func Int32() int32 #61716
69+
pkg math/rand/v2, func Int32N(int32) int32 #61716
70+
pkg math/rand/v2, func Int64() int64 #61716
71+
pkg math/rand/v2, func Int64N(int64) int64 #61716
72+
pkg math/rand/v2, func IntN(int) int #61716
73+
pkg math/rand/v2, func N[$0 intType]($0) $0 #61716
74+
pkg math/rand/v2, func New(Source) *Rand #61716
75+
pkg math/rand/v2, func NewChaCha8([32]uint8) *ChaCha8 #61716
76+
pkg math/rand/v2, func NewPCG(uint64, uint64) *PCG #61716
77+
pkg math/rand/v2, func NewZipf(*Rand, float64, float64, uint64) *Zipf #61716
78+
pkg math/rand/v2, func NormFloat64() float64 #61716
79+
pkg math/rand/v2, func Perm(int) []int #61716
80+
pkg math/rand/v2, func Shuffle(int, func(int, int)) #61716
81+
pkg math/rand/v2, func Uint32() uint32 #61716
82+
pkg math/rand/v2, func Uint32N(uint32) uint32 #61716
83+
pkg math/rand/v2, func Uint64() uint64 #61716
84+
pkg math/rand/v2, func Uint64N(uint64) uint64 #61716
85+
pkg math/rand/v2, func UintN(uint) uint #61716
86+
pkg math/rand/v2, method (*ChaCha8) MarshalBinary() ([]uint8, error) #61716
87+
pkg math/rand/v2, method (*ChaCha8) Seed([32]uint8) #61716
88+
pkg math/rand/v2, method (*ChaCha8) Uint64() uint64 #61716
89+
pkg math/rand/v2, method (*ChaCha8) UnmarshalBinary([]uint8) error #61716
90+
pkg math/rand/v2, method (*PCG) MarshalBinary() ([]uint8, error) #61716
91+
pkg math/rand/v2, method (*PCG) Seed(uint64, uint64) #61716
92+
pkg math/rand/v2, method (*PCG) Uint64() uint64 #61716
93+
pkg math/rand/v2, method (*PCG) UnmarshalBinary([]uint8) error #61716
94+
pkg math/rand/v2, method (*Rand) ExpFloat64() float64 #61716
95+
pkg math/rand/v2, method (*Rand) Float32() float32 #61716
96+
pkg math/rand/v2, method (*Rand) Float64() float64 #61716
97+
pkg math/rand/v2, method (*Rand) Int() int #61716
98+
pkg math/rand/v2, method (*Rand) Int32() int32 #61716
99+
pkg math/rand/v2, method (*Rand) Int32N(int32) int32 #61716
100+
pkg math/rand/v2, method (*Rand) Int64() int64 #61716
101+
pkg math/rand/v2, method (*Rand) Int64N(int64) int64 #61716
102+
pkg math/rand/v2, method (*Rand) IntN(int) int #61716
103+
pkg math/rand/v2, method (*Rand) NormFloat64() float64 #61716
104+
pkg math/rand/v2, method (*Rand) Perm(int) []int #61716
105+
pkg math/rand/v2, method (*Rand) Shuffle(int, func(int, int)) #61716
106+
pkg math/rand/v2, method (*Rand) Uint32() uint32 #61716
107+
pkg math/rand/v2, method (*Rand) Uint32N(uint32) uint32 #61716
108+
pkg math/rand/v2, method (*Rand) Uint64() uint64 #61716
109+
pkg math/rand/v2, method (*Rand) Uint64N(uint64) uint64 #61716
110+
pkg math/rand/v2, method (*Rand) UintN(uint) uint #61716
111+
pkg math/rand/v2, method (*Zipf) Uint64() uint64 #61716
112+
pkg math/rand/v2, type ChaCha8 struct #61716
113+
pkg math/rand/v2, type PCG struct #61716
114+
pkg math/rand/v2, type Rand struct #61716
115+
pkg math/rand/v2, type Source interface { Uint64 } #61716
116+
pkg math/rand/v2, type Source interface, Uint64() uint64 #61716
117+
pkg math/rand/v2, type Zipf struct #61716
118+
pkg net, method (*TCPConn) WriteTo(io.Writer) (int64, error) #58808
119+
pkg net/http, func FileServerFS(fs.FS) Handler #51971
120+
pkg net/http, func NewFileTransportFS(fs.FS) RoundTripper #51971
121+
pkg net/http, func ServeFileFS(ResponseWriter, *Request, fs.FS, string) #51971
122+
pkg net/http, method (*Request) PathValue(string) string #61410
123+
pkg net/http, method (*Request) SetPathValue(string, string) #61410
124+
pkg net/netip, method (AddrPort) Compare(AddrPort) int #61642
125+
pkg os, method (*File) WriteTo(io.Writer) (int64, error) #58808
126+
pkg reflect, func PtrTo //deprecated #59599
127+
pkg reflect, func TypeFor[$0 interface{}]() Type #60088
128+
pkg slices, func Concat[$0 interface{ ~[]$1 }, $1 interface{}](...$0) $0 #56353
129+
pkg syscall (linux-386), type SysProcAttr struct, PidFD *int #51246
130+
pkg syscall (linux-386-cgo), type SysProcAttr struct, PidFD *int #51246
131+
pkg syscall (linux-amd64), type SysProcAttr struct, PidFD *int #51246
132+
pkg syscall (linux-amd64-cgo), type SysProcAttr struct, PidFD *int #51246
133+
pkg syscall (linux-arm), type SysProcAttr struct, PidFD *int #51246
134+
pkg syscall (linux-arm-cgo), type SysProcAttr struct, PidFD *int #51246
135+
pkg testing/slogtest, func Run(*testing.T, func(*testing.T) slog.Handler, func(*testing.T) map[string]interface{}) #61758

‎go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/bobg/mingo
22

3-
go 1.21.0
3+
go 1.22
44

55
require (
66
github.com/bobg/errors v0.10.0

‎mingo_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestLangChecks(t *testing.T) {
6464
defer os.RemoveAll(tmpdir)
6565

6666
gomod := filepath.Join(tmpdir, "go.mod")
67-
if err := os.WriteFile(gomod, []byte("module foo\ngo 1.21.0\n"), 0644); err != nil {
67+
if err := os.WriteFile(gomod, []byte("module foo\ngo 1.22.0\n"), 0644); err != nil {
6868
t.Fatal(err)
6969
}
7070

‎stmt.go

+29
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"go/ast"
66
"go/token"
7+
"go/types"
78
)
89

910
func (p *pkgScanner) stmt(stmt ast.Stmt) error {
@@ -286,5 +287,33 @@ func (p *pkgScanner) rangeStmt(stmt *ast.RangeStmt) error {
286287
if p.isMax() {
287288
return nil
288289
}
290+
291+
tv, ok := p.info.Types[stmt.X]
292+
if !ok {
293+
return fmt.Errorf("no type info for range expression at %s", p.fset.Position(stmt.X.Pos()))
294+
}
295+
switch typ := tv.Type.Underlying().(type) {
296+
case *types.Basic:
297+
switch typ.Kind() {
298+
case types.Int, types.Int8, types.Int16, types.Int32, types.Int64, types.Uint, types.Uint8, types.Uint16, types.Uint32, types.Uint64:
299+
// TODO: all integer kinds, or just some?
300+
p.greater(posResult{
301+
version: 22,
302+
pos: p.fset.Position(stmt.Pos()),
303+
desc: "range over integer",
304+
})
305+
}
306+
307+
case *types.Signature:
308+
p.greater(posResult{
309+
version: 23,
310+
pos: p.fset.Position(stmt.Pos()),
311+
desc: "range over function",
312+
})
313+
}
314+
if p.isMax() {
315+
return nil
316+
}
317+
289318
return p.blockStmt(stmt.Body)
290319
}

0 commit comments

Comments
 (0)
Please sign in to comment.