Skip to content

Instantly share code, notes, and snippets.

@tomholford
Created February 18, 2026 20:55
Show Gist options
  • Select an option

  • Save tomholford/33664d6b848b6ed2a6349d3df93a9853 to your computer and use it in GitHub Desktop.

Select an option

Save tomholford/33664d6b848b6ed2a6349d3df93a9853 to your computer and use it in GitHub Desktop.

go fix Analysis — packages/server/

Go version: 1.26.0
Date: 2026-02-18
Command: go fix -diff ./...


Summary

7 fixes across 7 files. The codebase is fairly modern — no deprecated patterns, no strings.Indexstrings.Cut candidates, and min()/max() builtins are already in use.


Findings

1. interface{}any (2 occurrences)

File Line Before After
pkg/db/announcement.go 144 []interface{}{} []any{}
pkg/web/handler_kagami.go 145 func() (interface{}, error) func() (any, error)

Risk: None. any is a built-in alias for interface{} since Go 1.18. Pure readability improvement.

2. 3-clause forrange over int (3 occurrences)

File Line Before After
pkg/db/crafting_recipe.go 48 for j := 0; j < len(inputs); j++ for j := range len(inputs)
pkg/mongodb/user_achievement.go 69 for i := 0; i < minLen; i++ for i := range minLen
pkg/property/syncer_test.go 32, 68 for n := 0; n < 4; n++ for n := range 4 (×2)

Risk: None. Range-over-integer (Go 1.22) is semantically identical for simple counted loops.

3. omitempty on struct fields (2 occurrences) — ⚠️ review needed

File Line Field Change
pkg/web/dto.go 54 Result db.CardSpec json:"result,omitempty"json:"result"
pkg/web/handler_crafting.go 18 UserState UserState json:"user,omitempty"json:"user"

Risk: Behavioral change. omitempty on struct types omits the field only when the struct is its zero value. Removing it means the field is always serialized (even when zero). If API clients depend on these fields being absent in certain responses, this changes the JSON contract.

The tool also noted it ignored an alternative omitzero fix (new in Go 1.26) since that would also be a behavior change.

Recommendation: Review these two fields against actual API usage before applying.


What was NOT flagged

  • No strings.Indexstrings.Cut candidates
  • No if/elsemin()/max() candidates (already using builtins)
  • No deprecated stdlib usage
  • No sort.Sliceslices.SortFunc candidates

Applying fixes

Safe mechanical upgrades (categories 1 & 2):

go fix -any -rangeint ./...

All fixes including omitempty removal:

go fix ./...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment