Skip to content

Commit a8fcbb2

Browse files
authored
APP-6222 upgrade to go 1.23 (viamrobotics#4401)
1 parent 38f055d commit a8fcbb2

File tree

30 files changed

+493
-499
lines changed

30 files changed

+493
-499
lines changed

.github/workflows/cli.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ jobs:
2929
with:
3030
ref: ${{ github.event.pull_request.head.sha }}
3131

32-
- uses: actions/setup-go@v4
32+
- uses: actions/setup-go@v5
3333
with:
34-
go-version: '1.21.x'
34+
go-version-file: go.mod
3535

3636
- name: build
3737
env:

.github/workflows/droid.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ jobs:
3333
with:
3434
ref: ${{ github.event.pull_request.head.sha }}
3535

36-
- uses: actions/setup-go@v4
36+
- uses: actions/setup-go@v5
3737
with:
38-
go-version: '1.21'
38+
go-version-file: go.mod
3939

4040
- id: cache-ndk
4141
uses: actions/cache@v3

.github/workflows/full-static.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- uses: actions/setup-node@v4
4444
- uses: actions/setup-go@v5
4545
with:
46-
go-version: '1.21'
46+
go-version-file: go.mod
4747

4848
- name: build js
4949
run: make build-web

.github/workflows/macos.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
1414
- uses: actions/setup-go@v5
1515
with:
16-
go-version: '1.21.x'
16+
go-version-file: go.mod
1717
- name: brew
1818
run: |
1919
brew config

cli/archive.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func createArchive(files []string, buf, stdout io.Writer) error {
6363
}()
6464

6565
if stdout != nil {
66-
fmt.Fprintf(stdout, "\rCompressing... %d%% (%d/%d files)", 0, 1, len(files)) // no newline
66+
fmt.Fprintf(stdout, "\rCompressing... %d%% (%d/%d files)", 0, 1, len(files)) //nolint:errcheck // no newline
6767
}
6868
// Iterate over files and add them to the tar archive
6969
for i, file := range files {
@@ -73,7 +73,7 @@ func createArchive(files []string, buf, stdout io.Writer) error {
7373
}
7474
if stdout != nil {
7575
compressPercent := int(math.Ceil(100 * float64(i+1) / float64(len(files))))
76-
fmt.Fprintf(stdout, "\rCompressing... %d%% (%d/%d files)", compressPercent, i+1, len(files)) // no newline
76+
fmt.Fprintf(stdout, "\rCompressing... %d%% (%d/%d files)", compressPercent, i+1, len(files)) //nolint:errcheck // no newline
7777
}
7878
}
7979
return nil

cli/client.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1514,10 +1514,10 @@ func (c *viamClient) startRobotPartShell(
15141514
case outputData, ok := <-output:
15151515
if ok {
15161516
if outputData.Output != "" {
1517-
fmt.Fprint(c.c.App.Writer, outputData.Output) // no newline
1517+
fmt.Fprint(c.c.App.Writer, outputData.Output) //nolint:errcheck // no newline
15181518
}
15191519
if outputData.Error != "" {
1520-
fmt.Fprint(c.c.App.ErrWriter, outputData.Error) // no newline
1520+
fmt.Fprint(c.c.App.ErrWriter, outputData.Error) //nolint:errcheck // no newline
15211521
}
15221522
if outputData.EOF {
15231523
return

cli/data.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func DataTagActionByFilter(c *cli.Context) error {
110110
}
111111

112112
// DataTagActionByIds is the corresponding action for 'data tag'.
113-
func DataTagActionByIds(c *cli.Context) error {
113+
func DataTagActionByIds(c *cli.Context) error { //nolint:var-naming,revive
114114
client, err := newViamClient(c)
115115
if err != nil {
116116
return err
@@ -561,7 +561,7 @@ func (c *viamClient) downloadBinary(dst string, id *datapb.BinaryID) error {
561561
dataFile, err := os.Create(dataPath)
562562
if err != nil {
563563
debugf(c.c.App.Writer, c.c.Bool(debugFlag), "Failed creating file %s: %s", id.FileId, err)
564-
return errors.Wrapf(err, fmt.Sprintf("could not create file for datum %s", datum.GetMetadata().GetId()))
564+
return errors.Wrapf(err, fmt.Sprintf("could not create file for datum %s", datum.GetMetadata().GetId())) //nolint:govet
565565
}
566566
//nolint:gosec
567567
if _, err := io.Copy(dataFile, r); err != nil {
@@ -627,7 +627,7 @@ func (c *viamClient) tabularData(dst string, filter *datapb.Filter, limit uint)
627627
}
628628
w := bufio.NewWriter(dataFile)
629629

630-
fmt.Fprintf(c.c.App.Writer, "Downloading..") // no newline
630+
fmt.Fprintf(c.c.App.Writer, "Downloading..") //nolint:errcheck // no newline
631631
var last string
632632
mdIndexes := make(map[string]int)
633633
mdIndex := 0
@@ -641,7 +641,7 @@ func (c *viamClient) tabularData(dst string, filter *datapb.Filter, limit uint)
641641
},
642642
CountOnly: false,
643643
})
644-
fmt.Fprintf(c.c.App.Writer, ".") // no newline
644+
fmt.Fprintf(c.c.App.Writer, ".") //nolint:errcheck // no newline
645645
if err == nil {
646646
break
647647
}
@@ -673,7 +673,7 @@ func (c *viamClient) tabularData(dst string, filter *datapb.Filter, limit uint)
673673
//nolint:gosec
674674
mdFile, err := os.Create(filepath.Join(dst, metadataDir, strconv.Itoa(mdIndex)+".json"))
675675
if err != nil {
676-
return errors.Wrapf(err, fmt.Sprintf("could not create metadata file for metadata index %d", mdIndex))
676+
return errors.Wrapf(err, fmt.Sprintf("could not create metadata file for metadata index %d", mdIndex)) //nolint:govet
677677
}
678678
if _, err := mdFile.Write(mdJSONBytes); err != nil {
679679
return errors.Wrapf(err, "could not write to metadata file %s", mdFile.Name())

cli/module_build.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ func (c *viamClient) moduleBuildListAction(cCtx *cli.Context) error {
169169
// minwidth, tabwidth, padding int, padchar byte, flags uint
170170
w := tabwriter.NewWriter(cCtx.App.Writer, 5, 4, 1, ' ', 0)
171171
tableFormat := "%s\t%s\t%s\t%s\t%s\n"
172-
fmt.Fprintf(w, tableFormat, "ID", "PLATFORM", "STATUS", "VERSION", "TIME")
172+
fmt.Fprintf(w, tableFormat, "ID", "PLATFORM", "STATUS", "VERSION", "TIME") //nolint:errcheck
173173
for _, job := range jobs.Jobs {
174-
fmt.Fprintf(w,
174+
fmt.Fprintf(w, //nolint:errcheck
175175
tableFormat,
176176
job.BuildId,
177177
job.Platform,
@@ -359,7 +359,7 @@ func (c *viamClient) printModuleBuildLogs(buildID, platform string) error {
359359
infof(c.c.App.Writer, log.BuildStep)
360360
lastBuildStep = log.BuildStep
361361
}
362-
fmt.Fprint(c.c.App.Writer, log.Data) // data is already formatted with newlines
362+
fmt.Fprint(c.c.App.Writer, log.Data) //nolint:errcheck // data is already formatted with newlines
363363
}
364364

365365
return nil

cli/module_registry.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ func sendUploadRequests(ctx context.Context, moduleStream apppb.AppService_Uploa
900900

901901
// Simple progress reading until we have a proper tui library
902902
uploadPercent := int(math.Ceil(100 * float64(uploadedBytes) / float64(fileSize)))
903-
fmt.Fprintf(stdout, "\rUploading... %d%% (%d/%d bytes)", uploadPercent, uploadedBytes, fileSize) // no newline
903+
fmt.Fprintf(stdout, "\rUploading... %d%% (%d/%d bytes)", uploadPercent, uploadedBytes, fileSize) //nolint:errcheck // no newline
904904
}
905905
}
906906

cli/print.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const asciiViam = `
2323

2424
// printf prints a message with no prefix.
2525
func printf(w io.Writer, format string, a ...interface{}) {
26-
fmt.Fprintf(w, format+"\n", a...)
26+
fmt.Fprintf(w, format+"\n", a...) //nolint:errcheck
2727
}
2828

2929
// debugf prints a message prefixed with a bold grey "Debug: ".
@@ -34,7 +34,7 @@ func debugf(w io.Writer, debugMode bool, format string, a ...interface{}) {
3434
if _, err := color.New(color.Bold, color.FgHiBlack).Fprint(w, "Debug: "); err != nil {
3535
log.Fatal(err)
3636
}
37-
fmt.Fprintf(w, format+"\n", a...)
37+
fmt.Fprintf(w, format+"\n", a...) //nolint:errcheck
3838
}
3939

4040
// infof prints a message prefixed with a bold cyan "Info: ".
@@ -45,15 +45,15 @@ func infof(w io.Writer, format string, a ...interface{}) {
4545
if _, err := color.New(color.Bold, color.FgCyan).Fprint(w, "Info: "); err != nil {
4646
log.Fatal(err)
4747
}
48-
fmt.Fprintf(w, format+"\n", a...)
48+
fmt.Fprintf(w, format+"\n", a...) //nolint:errcheck
4949
}
5050

5151
// warningf prints a message prefixed with a bold yellow "Warning: ".
5252
func warningf(w io.Writer, format string, a ...interface{}) {
5353
if _, err := color.New(color.Bold, color.FgYellow).Fprint(w, "Warning: "); err != nil {
5454
log.Fatal(err)
5555
}
56-
fmt.Fprintf(w, format+"\n", a...)
56+
fmt.Fprintf(w, format+"\n", a...) //nolint:errcheck
5757
}
5858

5959
// Errorf prints a message prefixed with a bold red "Error: " prefix and exits with 1.
@@ -69,7 +69,7 @@ func Errorf(w io.Writer, format string, a ...interface{}) {
6969
log.Fatal("Malformed error message:", toPrint)
7070
}
7171
upperR := unicode.ToUpper(r)
72-
fmt.Fprintf(w, string(upperR)+toPrint[i:])
72+
fmt.Fprintf(w, string(upperR)+toPrint[i:]) //nolint:errcheck,govet
7373

7474
os.Exit(1)
7575
}

components/camera/client.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -729,17 +729,17 @@ func (c *client) bufAndCBToString() string {
729729
if len(c.runningStreams) == 0 {
730730
return "len: 0"
731731
}
732-
strIds := []string{}
733-
strIdsToCB := map[string]bufAndCB{}
732+
strIDs := []string{}
733+
strIDsToCB := map[string]bufAndCB{}
734734
for id, cb := range c.runningStreams {
735735
strID := id.String()
736-
strIds = append(strIds, strID)
737-
strIdsToCB[strID] = cb
736+
strIDs = append(strIDs, strID)
737+
strIDsToCB[strID] = cb
738738
}
739-
slices.Sort(strIds)
739+
slices.Sort(strIDs)
740740
ret := fmt.Sprintf("len: %d, ", len(c.runningStreams))
741-
for _, strID := range strIds {
742-
ret += fmt.Sprintf("%s: %v, ", strID, strIdsToCB[strID])
741+
for _, strID := range strIDs {
742+
ret += fmt.Sprintf("%s: %v, ", strID, strIDsToCB[strID])
743743
}
744744
return ret
745745
}

components/motor/dmc4000/dmc.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,9 @@ func (m *Motor) posToSteps(pos float64) int32 {
434434
goal := int32(pos * float64(m.TicksPerRotation))
435435

436436
// Hard limits from controller
437-
if goal > 2147483647 {
437+
if goal > 2147483647 { //nolint:staticcheck
438438
goal = 2147483647
439-
} else if goal < -2147483648 {
439+
} else if goal < -2147483648 { //nolint:staticcheck
440440
goal = -2147483648
441441
}
442442
return goal

components/motor/gpio/encoded.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func (m *EncodedMotor) GoFor(ctx context.Context, rpm, revolutions float64, extr
299299
return nil
300300
}
301301

302-
func (m *EncodedMotor) goForInternal(rpm, goalPos, direction float64) error {
302+
func (m *EncodedMotor) goForInternal(rpm, goalPos, direction float64) error { //nolint:unparam
303303
// cancel makeAdjustments if it already exists
304304
if m.makeAdjustmentsDone != nil {
305305
m.makeAdjustmentsDone()

control/trapezoid_velocity_profile.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ type trapezoidVelocityGenerator struct {
2323
maxVel float64
2424
lastVelCmd float64
2525
trapDistance float64
26-
kPP float64 //nolint: revive
27-
kPP0 float64 //nolint: revive
26+
kPP float64
27+
kPP0 float64
2828
vDec float64
2929
targetPos float64
3030
y []*Signal

data/capture_file.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func ReadCaptureFile(f *os.File) (*CaptureFile, error) {
6767
md := &v1.DataCaptureMetadata{}
6868
initOffset, err := pbutil.ReadDelimited(f, md)
6969
if err != nil {
70-
return nil, errors.Wrapf(err, fmt.Sprintf("failed to read DataCaptureMetadata from %s", f.Name()))
70+
return nil, errors.Wrapf(err, fmt.Sprintf("failed to read DataCaptureMetadata from %s", f.Name())) //nolint:govet
7171
}
7272

7373
ret := CaptureFile{

etc/.golangci.yaml

+19-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
service:
2-
golangci-lint-version: 1.51.x
2+
golangci-lint-version: 1.61.x
33
run:
4+
timeout: 10m
45
deadline: 900s
56
modules-download-mode: readonly
67
skip-dirs-use-default: false
@@ -13,48 +14,50 @@ linters:
1314
enable-all: true
1415
disable:
1516
- asasalint
17+
- canonicalheader
1618
- containedctx
1719
- contextcheck
20+
- copyloopvar # TODO(go1.23): reenable in follow-up
1821
- cyclop
19-
- deadcode
2022
- depguard
21-
- exhaustivestruct
2223
- exhaustruct
24+
- fatcontext # TODO(go1.23): reenable in follow-up
2325
- forcetypeassert
2426
- funlen
2527
- gocognit
2628
- godox
27-
- goerr113
29+
- err113
2830
- gochecknoglobals
2931
- gochecknoinits
3032
- gocyclo
3133
- gofmt
3234
- goimports
33-
- golint
3435
- gomnd
35-
- ifshort
3636
- importas
37+
- inamedparam
3738
- interfacebloat
38-
- interfacer
39+
- intrange # TODO(go1.23): reenable in follow-up
3940
- ireturn
4041
- maintidx
41-
- maligned
4242
- makezero
43+
- mnd
4344
- musttag
4445
- nakedret
4546
- nestif
47+
- nilnil # TODO(go1.23): low-pri to reenable
4648
- nlreturn
47-
- nosnakecase
4849
- nonamedreturns
4950
- nosprintfhostport
5051
- paralleltest
52+
- perfsprint
5153
- prealloc
52-
- scopelint
53-
- structcheck
54+
- predeclared # TODO(go1.23): reenable in follow-up
55+
- protogetter # TODO(go1.23): maybe reenable in the future but it's a big diff + buggy.
56+
- spancheck # TODO(go1.23): reenable in follow-up
5457
- tagliatelle
58+
- tenv # TODO(go1.23): reenable in follow-up
5559
- testpackage
5660
- thelper # false positives
57-
- varcheck
5861
- varnamelen
5962
- wrapcheck
6063
- wsl
@@ -67,14 +70,17 @@ linters-settings:
6770
- default
6871
- prefix(go.viam.com/rdk)
6972
gofumpt:
70-
lang-version: "1.21"
73+
lang-version: "1.23"
7174
extra-rules: true
7275
govet:
7376
enable-all: true
7477
disable:
7578
- fieldalignment
7679
- shadow
7780
- composites
81+
gosec:
82+
excludes:
83+
- G115 # TODO(go1.23): maybe reenable
7884
revive:
7985
# Unfortunately configuring a single rules disables all other rules, even
8086
# if we set `enable-all: true`

etc/setup.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ do_brew(){
160160
tap "viamrobotics/brews"
161161
162162
# pinned
163-
brew "go@1.21", link: true, conflicts_with: ["go"]
163+
brew "go@1.23", link: true, conflicts_with: ["go"]
164164
brew "node@18", link: true, conflicts_with: ["node"]
165165
166166
# unpinned
@@ -181,8 +181,8 @@ do_brew(){
181181
exit 1
182182
fi
183183

184-
# replace default go (currently 1.22, from canon build) with pinned [email protected]
185-
brew link --overwrite go@1.21
184+
# replace default go with pinned
185+
brew link --overwrite go@1.23
186186

187187
# due to a missing bottle in homebrew, this has to be installed on its own
188188
brew install upx

0 commit comments

Comments
 (0)