Skip to content

Commit

Permalink
APP-6222 upgrade to go 1.23 (#4401)
Browse files Browse the repository at this point in the history
  • Loading branch information
abe-winter authored Oct 1, 2024
1 parent 38f055d commit a8fcbb2
Show file tree
Hide file tree
Showing 30 changed files with 493 additions and 499 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21.x'
go-version-file: go.mod

- name: build
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/droid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version-file: go.mod

- id: cache-ndk
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/full-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- uses: actions/setup-node@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version-file: go.mod

- name: build js
run: make build-web
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
- uses: actions/setup-go@v5
with:
go-version: '1.21.x'
go-version-file: go.mod
- name: brew
run: |
brew config
Expand Down
4 changes: 2 additions & 2 deletions cli/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func createArchive(files []string, buf, stdout io.Writer) error {
}()

if stdout != nil {
fmt.Fprintf(stdout, "\rCompressing... %d%% (%d/%d files)", 0, 1, len(files)) // no newline
fmt.Fprintf(stdout, "\rCompressing... %d%% (%d/%d files)", 0, 1, len(files)) //nolint:errcheck // no newline
}
// Iterate over files and add them to the tar archive
for i, file := range files {
Expand All @@ -73,7 +73,7 @@ func createArchive(files []string, buf, stdout io.Writer) error {
}
if stdout != nil {
compressPercent := int(math.Ceil(100 * float64(i+1) / float64(len(files))))
fmt.Fprintf(stdout, "\rCompressing... %d%% (%d/%d files)", compressPercent, i+1, len(files)) // no newline
fmt.Fprintf(stdout, "\rCompressing... %d%% (%d/%d files)", compressPercent, i+1, len(files)) //nolint:errcheck // no newline
}
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions cli/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1514,10 +1514,10 @@ func (c *viamClient) startRobotPartShell(
case outputData, ok := <-output:
if ok {
if outputData.Output != "" {
fmt.Fprint(c.c.App.Writer, outputData.Output) // no newline
fmt.Fprint(c.c.App.Writer, outputData.Output) //nolint:errcheck // no newline
}
if outputData.Error != "" {
fmt.Fprint(c.c.App.ErrWriter, outputData.Error) // no newline
fmt.Fprint(c.c.App.ErrWriter, outputData.Error) //nolint:errcheck // no newline
}
if outputData.EOF {
return
Expand Down
10 changes: 5 additions & 5 deletions cli/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func DataTagActionByFilter(c *cli.Context) error {
}

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

fmt.Fprintf(c.c.App.Writer, "Downloading..") // no newline
fmt.Fprintf(c.c.App.Writer, "Downloading..") //nolint:errcheck // no newline
var last string
mdIndexes := make(map[string]int)
mdIndex := 0
Expand All @@ -641,7 +641,7 @@ func (c *viamClient) tabularData(dst string, filter *datapb.Filter, limit uint)
},
CountOnly: false,
})
fmt.Fprintf(c.c.App.Writer, ".") // no newline
fmt.Fprintf(c.c.App.Writer, ".") //nolint:errcheck // no newline
if err == nil {
break
}
Expand Down Expand Up @@ -673,7 +673,7 @@ func (c *viamClient) tabularData(dst string, filter *datapb.Filter, limit uint)
//nolint:gosec
mdFile, err := os.Create(filepath.Join(dst, metadataDir, strconv.Itoa(mdIndex)+".json"))
if err != nil {
return errors.Wrapf(err, fmt.Sprintf("could not create metadata file for metadata index %d", mdIndex))
return errors.Wrapf(err, fmt.Sprintf("could not create metadata file for metadata index %d", mdIndex)) //nolint:govet
}
if _, err := mdFile.Write(mdJSONBytes); err != nil {
return errors.Wrapf(err, "could not write to metadata file %s", mdFile.Name())
Expand Down
6 changes: 3 additions & 3 deletions cli/module_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ func (c *viamClient) moduleBuildListAction(cCtx *cli.Context) error {
// minwidth, tabwidth, padding int, padchar byte, flags uint
w := tabwriter.NewWriter(cCtx.App.Writer, 5, 4, 1, ' ', 0)
tableFormat := "%s\t%s\t%s\t%s\t%s\n"
fmt.Fprintf(w, tableFormat, "ID", "PLATFORM", "STATUS", "VERSION", "TIME")
fmt.Fprintf(w, tableFormat, "ID", "PLATFORM", "STATUS", "VERSION", "TIME") //nolint:errcheck
for _, job := range jobs.Jobs {
fmt.Fprintf(w,
fmt.Fprintf(w, //nolint:errcheck
tableFormat,
job.BuildId,
job.Platform,
Expand Down Expand Up @@ -359,7 +359,7 @@ func (c *viamClient) printModuleBuildLogs(buildID, platform string) error {
infof(c.c.App.Writer, log.BuildStep)
lastBuildStep = log.BuildStep
}
fmt.Fprint(c.c.App.Writer, log.Data) // data is already formatted with newlines
fmt.Fprint(c.c.App.Writer, log.Data) //nolint:errcheck // data is already formatted with newlines
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion cli/module_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ func sendUploadRequests(ctx context.Context, moduleStream apppb.AppService_Uploa

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

Expand Down
10 changes: 5 additions & 5 deletions cli/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const asciiViam = `

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

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

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

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

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

os.Exit(1)
}
Expand Down
14 changes: 7 additions & 7 deletions components/camera/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,17 +729,17 @@ func (c *client) bufAndCBToString() string {
if len(c.runningStreams) == 0 {
return "len: 0"
}
strIds := []string{}
strIdsToCB := map[string]bufAndCB{}
strIDs := []string{}
strIDsToCB := map[string]bufAndCB{}
for id, cb := range c.runningStreams {
strID := id.String()
strIds = append(strIds, strID)
strIdsToCB[strID] = cb
strIDs = append(strIDs, strID)
strIDsToCB[strID] = cb
}
slices.Sort(strIds)
slices.Sort(strIDs)
ret := fmt.Sprintf("len: %d, ", len(c.runningStreams))
for _, strID := range strIds {
ret += fmt.Sprintf("%s: %v, ", strID, strIdsToCB[strID])
for _, strID := range strIDs {
ret += fmt.Sprintf("%s: %v, ", strID, strIDsToCB[strID])
}
return ret
}
4 changes: 2 additions & 2 deletions components/motor/dmc4000/dmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,9 @@ func (m *Motor) posToSteps(pos float64) int32 {
goal := int32(pos * float64(m.TicksPerRotation))

// Hard limits from controller
if goal > 2147483647 {
if goal > 2147483647 { //nolint:staticcheck
goal = 2147483647
} else if goal < -2147483648 {
} else if goal < -2147483648 { //nolint:staticcheck
goal = -2147483648
}
return goal
Expand Down
2 changes: 1 addition & 1 deletion components/motor/gpio/encoded.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (m *EncodedMotor) GoFor(ctx context.Context, rpm, revolutions float64, extr
return nil
}

func (m *EncodedMotor) goForInternal(rpm, goalPos, direction float64) error {
func (m *EncodedMotor) goForInternal(rpm, goalPos, direction float64) error { //nolint:unparam
// cancel makeAdjustments if it already exists
if m.makeAdjustmentsDone != nil {
m.makeAdjustmentsDone()
Expand Down
4 changes: 2 additions & 2 deletions control/trapezoid_velocity_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type trapezoidVelocityGenerator struct {
maxVel float64
lastVelCmd float64
trapDistance float64
kPP float64 //nolint: revive
kPP0 float64 //nolint: revive
kPP float64
kPP0 float64
vDec float64
targetPos float64
y []*Signal
Expand Down
2 changes: 1 addition & 1 deletion data/capture_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func ReadCaptureFile(f *os.File) (*CaptureFile, error) {
md := &v1.DataCaptureMetadata{}
initOffset, err := pbutil.ReadDelimited(f, md)
if err != nil {
return nil, errors.Wrapf(err, fmt.Sprintf("failed to read DataCaptureMetadata from %s", f.Name()))
return nil, errors.Wrapf(err, fmt.Sprintf("failed to read DataCaptureMetadata from %s", f.Name())) //nolint:govet
}

ret := CaptureFile{
Expand Down
32 changes: 19 additions & 13 deletions etc/.golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
service:
golangci-lint-version: 1.51.x
golangci-lint-version: 1.61.x
run:
timeout: 10m
deadline: 900s
modules-download-mode: readonly
skip-dirs-use-default: false
Expand All @@ -13,48 +14,50 @@ linters:
enable-all: true
disable:
- asasalint
- canonicalheader
- containedctx
- contextcheck
- copyloopvar # TODO(go1.23): reenable in follow-up
- cyclop
- deadcode
- depguard
- exhaustivestruct
- exhaustruct
- fatcontext # TODO(go1.23): reenable in follow-up
- forcetypeassert
- funlen
- gocognit
- godox
- goerr113
- err113
- gochecknoglobals
- gochecknoinits
- gocyclo
- gofmt
- goimports
- golint
- gomnd
- ifshort
- importas
- inamedparam
- interfacebloat
- interfacer
- intrange # TODO(go1.23): reenable in follow-up
- ireturn
- maintidx
- maligned
- makezero
- mnd
- musttag
- nakedret
- nestif
- nilnil # TODO(go1.23): low-pri to reenable
- nlreturn
- nosnakecase
- nonamedreturns
- nosprintfhostport
- paralleltest
- perfsprint
- prealloc
- scopelint
- structcheck
- predeclared # TODO(go1.23): reenable in follow-up
- protogetter # TODO(go1.23): maybe reenable in the future but it's a big diff + buggy.
- spancheck # TODO(go1.23): reenable in follow-up
- tagliatelle
- tenv # TODO(go1.23): reenable in follow-up
- testpackage
- thelper # false positives
- varcheck
- varnamelen
- wrapcheck
- wsl
Expand All @@ -67,14 +70,17 @@ linters-settings:
- default
- prefix(go.viam.com/rdk)
gofumpt:
lang-version: "1.21"
lang-version: "1.23"
extra-rules: true
govet:
enable-all: true
disable:
- fieldalignment
- shadow
- composites
gosec:
excludes:
- G115 # TODO(go1.23): maybe reenable
revive:
# Unfortunately configuring a single rules disables all other rules, even
# if we set `enable-all: true`
Expand Down
6 changes: 3 additions & 3 deletions etc/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ do_brew(){
tap "viamrobotics/brews"
# pinned
brew "go@1.21", link: true, conflicts_with: ["go"]
brew "go@1.23", link: true, conflicts_with: ["go"]
brew "node@18", link: true, conflicts_with: ["node"]
# unpinned
Expand All @@ -181,8 +181,8 @@ do_brew(){
exit 1
fi

# replace default go (currently 1.22, from canon build) with pinned go@1.21
brew link --overwrite go@1.21
# replace default go with pinned
brew link --overwrite go@1.23

# due to a missing bottle in homebrew, this has to be installed on its own
brew install upx
Expand Down
Loading

0 comments on commit a8fcbb2

Please sign in to comment.