Switch to Go 1.23 and fix CI failures

Some new upcoming changes require us to use Go 1.23. However, if we switch to Go 1.23 some
new linter errors are showing up. This commit fixes most of the errors and adds an
exclusion for integer overflow errors.

Signed-off-by: Amit <ambarve@microsoft.com>
This commit is contained in:
Amit
2025-10-27 09:08:22 -07:00
committed by Amit Barve
parent bdc6c11280
commit fd34511314
52 changed files with 41 additions and 82 deletions
+4
View File
@@ -59,6 +59,10 @@ issues:
text: "^directive `//nolint:errorlint` should provide explanation"
source: '[=|!]= io.EOF'
- linters:
- gosec
text: "^G115: integer overflow conversion"
linters-settings:
exhaustive:
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package winio
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package winio
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package backuptar
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package backuptar
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package winio
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package winio
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package winio
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package winio
+9 -4
View File
@@ -1,11 +1,16 @@
module github.com/Microsoft/go-winio
go 1.21
go 1.23.0
toolchain go1.23.8
require (
github.com/sirupsen/logrus v1.9.3
golang.org/x/sys v0.10.0
golang.org/x/tools v0.11.0
golang.org/x/sys v0.35.0
golang.org/x/tools v0.36.0
)
require golang.org/x/mod v0.12.0 // indirect
require (
golang.org/x/mod v0.27.0 // indirect
golang.org/x/sync v0.16.0 // indirect
)
+10 -8
View File
@@ -1,6 +1,8 @@
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/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
@@ -8,15 +10,15 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ=
golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8=
golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package winio
+2 -2
View File
@@ -437,7 +437,7 @@ func TestHvSockCloseReadWriteDial(t *testing.T) {
n, err = c.Read(b)
if n != 0 {
return fmt.Errorf("server did not get EOF")
return errors.New("server did not get EOF")
}
if !errors.Is(err, io.EOF) {
return errors.New("server did not get EOF")
@@ -632,7 +632,7 @@ func (u testUtil) Assert(b bool, msgs ...string) {
return
}
u.T.Helper()
u.T.Fatalf(msgJoin(msgs, "failed assertion"))
u.T.Fatal(msgJoin(msgs, "failed assertion"))
}
func (u testUtil) Is(err, target error, msgs ...string) {
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package winio
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package winio
+4 -5
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package bindfilter
@@ -109,7 +108,7 @@ func GetBindMappings(volumePath string) ([]BindMapping, error) {
}
if outBuffSize < 12 {
return nil, fmt.Errorf("invalid buffer returned")
return nil, errors.New("invalid buffer returned")
}
result := buf[:outBuffSize]
@@ -185,7 +184,7 @@ func decodeEntry(buffer []byte) (string, error) {
func getTargetsFromBuffer(buffer []byte, offset, count int) ([]string, error) {
if len(buffer) < offset+count*6 {
return nil, fmt.Errorf("invalid buffer")
return nil, errors.New("invalid buffer")
}
targets := make([]string, count)
@@ -193,7 +192,7 @@ func getTargetsFromBuffer(buffer []byte, offset, count int) ([]string, error) {
entryBuf := buffer[offset+i*8 : offset+i*8+8]
tgt := *(*mappingTargetEntry)(unsafe.Pointer(&entryBuf[0]))
if len(buffer) < int(tgt.TargetRootOffset)+int(tgt.TargetRootLength) {
return nil, fmt.Errorf("invalid buffer")
return nil, errors.New("invalid buffer")
}
decoded, err := decodeEntry(buffer[tgt.TargetRootOffset : tgt.TargetRootOffset+tgt.TargetRootLength])
if err != nil {
@@ -259,7 +258,7 @@ func getFinalPath(pth string) (string, error) {
func getBindMappingFromBuffer(buffer []byte, entry mappingEntry) (BindMapping, error) {
if len(buffer) < int(entry.VirtRootOffset)+int(entry.VirtRootLength) {
return BindMapping{}, fmt.Errorf("invalid buffer")
return BindMapping{}, errors.New("invalid buffer")
}
src, err := decodeEntry(buffer[entry.VirtRootOffset : entry.VirtRootOffset+entry.VirtRootLength])
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package bindfilter
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package etw
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package etw
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package etw
-2
View File
@@ -1,6 +1,4 @@
//go:build windows && (amd64 || arm64 || 386)
// +build windows
// +build amd64 arm64 386
package etw
-1
View File
@@ -1,5 +1,4 @@
//go:build windows && arm
// +build windows,arm
package etw
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package etw
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package etw
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package etw
-2
View File
@@ -1,6 +1,4 @@
//go:build windows && (386 || arm)
// +build windows
// +build 386 arm
package etw
-2
View File
@@ -1,6 +1,4 @@
//go:build windows && (amd64 || arm64)
// +build windows
// +build amd64 arm64
package etw
-1
View File
@@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package main
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
// Shows a sample usage of the ETW logging package.
package main
-2
View File
@@ -1,6 +1,4 @@
//go:build windows && (386 || arm)
// +build windows
// +build 386 arm
package etw
-2
View File
@@ -1,6 +1,4 @@
//go:build windows && (amd64 || arm64)
// +build windows
// +build amd64 arm64
package etw
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package etwlogrus
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package etwlogrus
-1
View File
@@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package guid
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package guid
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package process
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package process
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package security
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package security
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package winio
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package winio
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package winio
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package winio
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package winio
-1
View File
@@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package main
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package main
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package vhd
-1
View File
@@ -1,5 +1,4 @@
//go:build windows || linux
// +build windows linux
package wim
+12 -12
View File
@@ -100,7 +100,7 @@ func (f *decompressor) ensureAtLeast(n int) error {
}
n, err := io.ReadAtLeast(f.r, f.b[f.bv-f.bo:], n)
if err != nil {
if err == io.EOF { //nolint:errorlint
if err == io.EOF {
err = io.ErrUnexpectedEOF
} else {
f.fail(err)
@@ -153,28 +153,28 @@ func buildTable(codelens []byte) *huffman {
// Determine the number of codes of each length, and the
// maximum length.
var count [maxTreePathLen + 1]uint
var max byte
var maxValue byte
for _, cl := range codelens {
count[cl]++
if max < cl {
max = cl
if maxValue < cl {
maxValue = cl
}
}
if max == 0 {
if maxValue == 0 {
return &huffman{}
}
// Determine the first code of each length.
var first [maxTreePathLen + 1]uint
code := uint(0)
for i := byte(1); i <= max; i++ {
for i := byte(1); i <= maxValue; i++ {
code <<= 1
first[i] = code
code += count[i]
}
if code != 1<<max {
if code != 1<<maxValue {
return nil
}
@@ -182,14 +182,14 @@ func buildTable(codelens []byte) *huffman {
// put all possible suffixes for the code into the table, too.
// For max > tablebits, split long codes into additional tables
// of suffixes of max-tablebits length.
h := &huffman{maxbits: max}
if max > tablebits {
h := &huffman{maxbits: maxValue}
if maxValue > tablebits {
core := first[tablebits+1] / 2 // Number of codes that fit without extra tables
nextra := 1<<tablebits - core // Number of extra entries
h.extra = make([][]uint16, nextra)
for code := core; code < 1<<tablebits; code++ {
h.table[code] = uint16(code - core)
h.extra[code-core] = make([]uint16, 1<<(max-tablebits))
h.extra[code-core] = make([]uint16, 1<<(maxValue-tablebits))
}
}
@@ -206,8 +206,8 @@ func buildTable(codelens []byte) *huffman {
} else {
prefix := code >> (cl - tablebits)
suffix := code & (1<<(cl-tablebits) - 1)
extendedCode := suffix << (max - cl)
for j := uint(0); j < 1<<(max-cl); j++ {
extendedCode := suffix << (maxValue - cl)
for j := uint(0); j < 1<<(maxValue-cl); j++ {
h.extra[h.table[prefix]][extendedCode+j] = v
}
}
-1
View File
@@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package main
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package main
-1
View File
@@ -1,5 +1,4 @@
//go:build windows || linux
// +build windows linux
// Package wim implements a WIM file parser.
//