update fix subcommand for go 1.26
This commit is contained in:
parent
989d044545
commit
5a5edf6914
95
src/_golang
95
src/_golang
|
|
@ -30,7 +30,7 @@
|
||||||
# Description
|
# Description
|
||||||
# -----------
|
# -----------
|
||||||
#
|
#
|
||||||
# Completion script for go 1.25.0 (https://go.dev/).
|
# Completion script for go 1.26.0 (https://go.dev/).
|
||||||
#
|
#
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Authors
|
# Authors
|
||||||
|
|
@ -312,20 +312,33 @@ __go_packages() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
__go_fix_names() {
|
__go_fix_analyzers() {
|
||||||
local -a fix_names=(
|
local -a fix_analyzers=(
|
||||||
'buildtag[remove +build comments from modules using Go 1.18 or later]'
|
"any[replace interface{} with any]"
|
||||||
'cftype[fixes initializers and casts of C.*Ref and JNI types]'
|
"buildtag[check //go:build and // +build directives]"
|
||||||
'context[Change imports of golang.org/x/net/context to context]'
|
"fmtappendf[replace \[\]byte(fmt.Sprintf) with fmt.Appendf]"
|
||||||
'egl[fixes initializers of EGLDisplay]'
|
"forvar[remove redundant re-declaration of loop variables]"
|
||||||
'eglconf[fixes initializers of EGLConfig]'
|
"hostport[check format of addresses passed to net.Dial]"
|
||||||
'gotypes[change imports of oglang.org/x/tools/go{exact,types} to go/{constant,types}]'
|
"inline[apply fixes based on 'go:fix inline' comment directives]"
|
||||||
"jni[fixes initializers of JNI's jobject and subtypes]"
|
"mapsloop[replace explicit loops over maps with calls to maps package]"
|
||||||
'netipv6zone[adapt element key to IPAddr, UPDAddr, TCPAddr composite literals]'
|
"minmax[replace if/else statements with calls to min or max]"
|
||||||
'printerconfig[add element keys to Config composite literals]'
|
"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
|
if [[ "$service" = -value-* ]]; then
|
||||||
|
|
@ -399,6 +412,38 @@ case $state in
|
||||||
'why:explain why packages or modules are needed'
|
'why:explain why packages or modules are needed'
|
||||||
'help:get more information about a command'
|
'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
|
case $words[1] in
|
||||||
(build)
|
(build)
|
||||||
|
|
@ -532,10 +577,7 @@ case $state in
|
||||||
(fix)
|
(fix)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-C[change to directory before running the command]: :_files -/' \
|
'-C[change to directory before running the command]: :_files -/' \
|
||||||
'-diff[display diffs instead of rewriting files]' \
|
$fix_flags[@] \
|
||||||
'-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' \
|
|
||||||
'*:importpaths:__go_packages'
|
'*:importpaths:__go_packages'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
@ -572,7 +614,6 @@ case $state in
|
||||||
(install)
|
(install)
|
||||||
_arguments \
|
_arguments \
|
||||||
${build_flags[@]} \
|
${build_flags[@]} \
|
||||||
'-json[emit install output in JSON suitable for automated processing]' \
|
|
||||||
'*:importpaths:__go_packages'
|
'*:importpaths:__go_packages'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
@ -602,7 +643,7 @@ case $state in
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(mod)
|
(mod)
|
||||||
_arguments \
|
_arguments -C \
|
||||||
"1: :{_describe 'command' mod_commands}" \
|
"1: :{_describe 'command' mod_commands}" \
|
||||||
'*:: :->args'
|
'*:: :->args'
|
||||||
|
|
||||||
|
|
@ -639,8 +680,8 @@ case $state in
|
||||||
'-e[attempt to proceed despite errors encountered while loading packages]' \
|
'-e[attempt to proceed despite errors encountered while loading packages]' \
|
||||||
'-x[print the commands download executes]' \
|
'-x[print the commands download executes]' \
|
||||||
'-diff[not to modify go.mod or go.sum but instead print necessary changes as a unified diff]' \
|
'-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' \
|
'-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'
|
'-compat=[preserves additional checksums needed for the indicated Go version]:version'
|
||||||
;;
|
;;
|
||||||
(vendor)
|
(vendor)
|
||||||
_arguments \
|
_arguments \
|
||||||
|
|
@ -908,12 +949,12 @@ case $state in
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(fix)
|
(fix)
|
||||||
_arguments \
|
if [[ $words[2] == "help" ]]; then
|
||||||
'(* -)-help[show help message]' \
|
__go_fix_analyzers
|
||||||
'-diff[display diffs instead of rewriting files]' \
|
else
|
||||||
'-force[force fixes to run even if the code looks updated]:string:__go_fix_names' \
|
_arguments \
|
||||||
'-r[restrict the rewrites]:string:__go_fix_names' \
|
"*:args:{ _alternative ':subcommand:(help)' _files }"
|
||||||
'*:files:_files'
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(link)
|
(link)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue