update fix subcommand for go 1.26
This commit is contained in:
parent
989d044545
commit
5a5edf6914
93
src/_golang
93
src/_golang
|
|
@ -30,7 +30,7 @@
|
|||
# Description
|
||||
# -----------
|
||||
#
|
||||
# Completion script for go 1.25.0 (https://go.dev/).
|
||||
# Completion script for go 1.26.0 (https://go.dev/).
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
|
|
@ -312,20 +312,33 @@ __go_packages() {
|
|||
fi
|
||||
}
|
||||
|
||||
__go_fix_names() {
|
||||
local -a fix_names=(
|
||||
'buildtag[remove +build comments from modules using Go 1.18 or later]'
|
||||
'cftype[fixes initializers and casts of C.*Ref and JNI types]'
|
||||
'context[Change imports of golang.org/x/net/context to context]'
|
||||
'egl[fixes initializers of EGLDisplay]'
|
||||
'eglconf[fixes initializers of EGLConfig]'
|
||||
'gotypes[change imports of oglang.org/x/tools/go{exact,types} to go/{constant,types}]'
|
||||
"jni[fixes initializers of JNI's jobject and subtypes]"
|
||||
'netipv6zone[adapt element key to IPAddr, UPDAddr, TCPAddr composite literals]'
|
||||
'printerconfig[add element keys to Config composite literals]'
|
||||
__go_fix_analyzers() {
|
||||
local -a fix_analyzers=(
|
||||
"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]"
|
||||
)
|
||||
|
||||
_values -s ',' 'fix name' $fix_names
|
||||
_values 'analyzer' $fix_analyzers
|
||||
}
|
||||
|
||||
if [[ "$service" = -value-* ]]; then
|
||||
|
|
@ -399,6 +412,38 @@ case $state in
|
|||
'why:explain why packages or modules are needed'
|
||||
'help:get more information about a command'
|
||||
)
|
||||
local -a fix_flags=(
|
||||
'-fixtool=[specify fix analyzer]:analyzer:__go_fix_analyzers'
|
||||
'-diff[display diffs instead of rewriting files]'
|
||||
'-fixtool=[select analysis tool]:analyzer:'
|
||||
'(- *)-V[print version and exit]'
|
||||
'-any[enable any analysis]'
|
||||
'-buildtag[enable buildtag analysis]'
|
||||
'-c[display offending line with this many lines of content(default: -1)]:num'
|
||||
'-fix[apply all suggested fixes]'
|
||||
'-flags[print analyzer flags in JSON]'
|
||||
'-fmtappendf[enable fmtappendf analysis]'
|
||||
'-forvar[enable forvar analysis]'
|
||||
'-hostport[enable hostport analysis]'
|
||||
'-inline[enable inline analysis]'
|
||||
'-json[emit JSON output]'
|
||||
'-mapsloop[enable mapsloop analysis]'
|
||||
'-minmax[enable minmax analysis]'
|
||||
'-newexpr[enable newexpr analysis]'
|
||||
'-omitzero[enable omitzero analysis]'
|
||||
'-plusbuild[enable plusbuild analysis]'
|
||||
'-rangeint[enable rangeint analysis]'
|
||||
'-reflecttypefor[enable reflecttypefor analysis]'
|
||||
'-slicescontains[enable slicescontains analysis]'
|
||||
'-slicessort[enable slicessort analysis]'
|
||||
'-stditerators[enable stditerators analysis]'
|
||||
'-stringsbuilder[enable stringsbuilder analysis]'
|
||||
'-stringscut[enable stringscut analysis]'
|
||||
'-stringscutprefix[enable stringscutprefix analysis]'
|
||||
'-stringsseq[enable stringsseq analysis]'
|
||||
'-testingcontext[enable testingcontext analysis]'
|
||||
'-waitgroup[enable waitgroup analysis]'
|
||||
)
|
||||
|
||||
case $words[1] in
|
||||
(build)
|
||||
|
|
@ -532,10 +577,7 @@ case $state in
|
|||
(fix)
|
||||
_arguments \
|
||||
'-C[change to directory before running the command]: :_files -/' \
|
||||
'-diff[display diffs instead of rewriting files]' \
|
||||
'-force[force these fixes to run even if the code looks updated]:fix_names:__go_fix_names' \
|
||||
'-go[go language version for files]:version' \
|
||||
'-r[restrict the rewrites to this comma-separated list]:fix_names:__go_fix_names' \
|
||||
$fix_flags[@] \
|
||||
'*:importpaths:__go_packages'
|
||||
;;
|
||||
|
||||
|
|
@ -572,7 +614,6 @@ case $state in
|
|||
(install)
|
||||
_arguments \
|
||||
${build_flags[@]} \
|
||||
'-json[emit install output in JSON suitable for automated processing]' \
|
||||
'*:importpaths:__go_packages'
|
||||
;;
|
||||
|
||||
|
|
@ -602,7 +643,7 @@ case $state in
|
|||
;;
|
||||
|
||||
(mod)
|
||||
_arguments \
|
||||
_arguments -C \
|
||||
"1: :{_describe 'command' mod_commands}" \
|
||||
'*:: :->args'
|
||||
|
||||
|
|
@ -639,8 +680,8 @@ case $state in
|
|||
'-e[attempt to proceed despite errors encountered while loading packages]' \
|
||||
'-x[print the commands download executes]' \
|
||||
'-diff[not to modify go.mod or go.sum but instead print necessary changes as a unified diff]' \
|
||||
'-go[update the go directive in the go.mod file to the given version]:goversion' \
|
||||
'-compat[preserves additional checksums needed for the indicated Go version]:version'
|
||||
'-go=[update the go directive in the go.mod file to the given version]:goversion' \
|
||||
'-compat=[preserves additional checksums needed for the indicated Go version]:version'
|
||||
;;
|
||||
(vendor)
|
||||
_arguments \
|
||||
|
|
@ -908,12 +949,12 @@ case $state in
|
|||
;;
|
||||
|
||||
(fix)
|
||||
if [[ $words[2] == "help" ]]; then
|
||||
__go_fix_analyzers
|
||||
else
|
||||
_arguments \
|
||||
'(* -)-help[show help message]' \
|
||||
'-diff[display diffs instead of rewriting files]' \
|
||||
'-force[force fixes to run even if the code looks updated]:string:__go_fix_names' \
|
||||
'-r[restrict the rewrites]:string:__go_fix_names' \
|
||||
'*:files:_files'
|
||||
"*:args:{ _alternative ':subcommand:(help)' _files }"
|
||||
fi
|
||||
;;
|
||||
|
||||
(link)
|
||||
|
|
|
|||
Loading…
Reference in New Issue