SuperAPI AI Directory

go

Coding & development

View repository

Updated 10-15 20:09

About this skill

Go

Frameworks, build tools, and HTTP libraries follow the project; do not specify them in this skill.

Do not write APIs from training data. First determine the language version, then read the corresponding reference.

Determine version

  1. Read the go.mod in go line(language version). Do not use the local go version as the language version. When there is go.work , also read the go line in it.
  2. When there is toolchain : the toolchain may be updated,syntax and std APIs are still constrained by the go line。go 1.24 + toolchain go1.26.x still write per 1.24, do not use new(expr)。
  3. Take 1.y(go 1.25.2 → 1.25), open the file in the table below, and write code according to that file. Single-file //go:build go1.xx only raises that file.
1.y File
1.24 references/1.24.md
1.25 references/1.25.md
1.26 references/1.26.md
1.27 references/1.27.md

Unlisted newer 1.y: use the highest covered level as the base, then check the official https://go.dev/doc/go1.N . Older: do not use the new APIs in this skill.

Hard rules (1.24+)

  • Use for i := range nfor integer loops; use for x := range seqto iterate iterators. Do not treat for i := 0; i < n; i++ as the default.
  • Use fmt.Errorf("...: %w", err) / errors.Joinfor errors. Do not concatenate with err.Error() and then errors.New。
  • Table-driven tests:tests := []struct{ name string; ... }{...} + t.Run(tt.name, ...)。
  • Do not pull in duplicate implementations of capabilities the standard library already has (especially crypto/*、testing、iter). First search the pkg.go.dev package documentation for the current language version.