Go analyzer updates — July 2021

Autofix for Go has undergone some updates this past month. Here’s what’s new:

  • 2 Autofix issues have been added
  • Several improvements have been made

Here’s the detailed changelog:

New Autofixes

SCC-S1032: Use sort.Ints(x), sort.Float64s(x), and sort.Strings(x)

Before Autofix

sort.Sort(sort.StringSlice(x))

After Autofix

sort.Strings(x)

SCC-SA1024: A string cutset contains duplicate characters

Before Autofix

fmt.Print(strings.Trim("¡¡¡Hello, Gophers!!!", "!!!¡"))
// Output:
// Hello, Gophers

After Autofix

fmt.Print(strings.Trim("¡¡¡Hello, Gophers!!!", "!¡"))
// Output:
// Hello, Gophers

More Autofixes are coming soon!

Improvements in Autofix

The following improvements made to Autofix would lead to fewer failures and improved running time:

  • Improved the running time for Autofix.
  • Previously, if there were any syntax errors in your code, the Autofix used to fail unable to gather the type information correctly. Now, it tries to fix your code despite errors, if it can.
  • Few more general improvements.
1 Like