TGViewer
Амади и проекты Амади и проекты @amadi_dev · 2.36K subscribers
Post #711 2.3K
go fix

В версии 1.26 нам завезли переделанную команду go fix, которая автоматически исправляет код. Со 100% безопасностью.

fix - это такая общая утилита из отдельных analyzers. Например, компонент "any", который меняет в коде "interface{}" на "any"

Список всех "аналайзеров":

any          replace interface{} with any
buildtag check //go:build and // +build directives
fmtappendf replace []byte(fmt.Sprintf) with fmt.Appendf
forvar remove redundant re-declaration of loop variables
hostport check format of addresses passed to net.Dial
inline apply fixes based on 'go:fix inline' comment directives
mapsloop replace explicit loops over maps with calls to maps package
minmax replace if/else statements with calls to min or max
newexpr simplify code by using go1.26's new(expr)
omitzero suggest replacing omitempty with omitzero for struct fields
plusbuild remove obsolete //+build comments
rangeint replace 3-clause for loops with for-range over integers
reflecttypefor replace reflect.TypeOf(x) with TypeFor[T]()
slicescontains replace loops with slices.Contains or slices.ContainsFunc
slicessort replace sort.Slice with slices.Sort for basic types
stditerators use iterators instead of Len/At-style APIs
stringsbuilder replace += with strings.Builder
stringscut replace strings.Index etc. with strings.Cut
stringscutprefix replace HasPrefix/TrimPrefix with CutPrefix
stringsseq replace ranging over Split/Fields with SplitSeq/FieldsSeq
testingcontext replace context.WithCancel with t.Context in tests
waitgroup replace wg.Add(1)/go/wg.Done() with wg.Go


Примеры на скрине

https://go.dev/blog/gofix
  • 👍 8
  • 🔥 3
  • 👾 3
More from @amadi_dev
  1. Sep 28, 2026Внимательный инженер
  2. Sep 25, 2026Тонкости голосового агента для групповой беседы 1) Важно, чтобы говорил, когда обращаются…
  3. Sep 23, 2026Сейчас в интернете много "я сделал это за 1 промпт" или "я сделал вот это за 2 часа" Снача…
  4. Sep 21, 2026Посмотрите, что такое Jev. Очень интересная модель классификации. Если прям вкратце, она о…
  5. Sep 20, 2026Началась новая неделя лимитов, и я уже потратил половину 20x подписки. За 30 часов.
  6. Sep 19, 2026Не думал, что когда-нибудь скажу это, но... Не особо успеваю вести канал в последнее время…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →