Merge pull request #1093 from zsh-users/update-go-completion
Update go completion
This commit is contained in:
commit
77005bb0dc
515
src/_golang
515
src/_golang
|
|
@ -30,7 +30,7 @@
|
||||||
# Description
|
# Description
|
||||||
# -----------
|
# -----------
|
||||||
#
|
#
|
||||||
# Completion script for go 1.21 (https://go.dev/).
|
# Completion script for go 1.22.5 (https://go.dev/).
|
||||||
#
|
#
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Authors
|
# Authors
|
||||||
|
|
@ -207,128 +207,131 @@ __go_envvarvals() {
|
||||||
# decide which variable to go to. if $1 is not set, then __go_envvarvals is
|
# decide which variable to go to. if $1 is not set, then __go_envvarvals is
|
||||||
# called from the `go env` completion and the current word (with all after
|
# called from the `go env` completion and the current word (with all after
|
||||||
# the first '=' removed) is the current variable.
|
# the first '=' removed) is the current variable.
|
||||||
local variable
|
local env_variable=${1-${words[$CURRENT]%%=*}}
|
||||||
variable=${1-${words[$CURRENT]%%=*}}
|
case $env_variable in
|
||||||
case $variable in
|
(GO111MODULE)
|
||||||
|
_values "module mode" off on auto
|
||||||
|
;;
|
||||||
# commands
|
# commands
|
||||||
AR)
|
(AR|CC|CXX|FC|GCCGO)
|
||||||
;&
|
|
||||||
CC)
|
|
||||||
;&
|
|
||||||
CXX)
|
|
||||||
;&
|
|
||||||
FC)
|
|
||||||
;&
|
|
||||||
GCCGO)
|
|
||||||
_command_names -e
|
_command_names -e
|
||||||
;;
|
;;
|
||||||
# directories (using fallthrough)
|
# directories
|
||||||
GOBIN)
|
(GOBIN|GOCACHE|GOTMPDIR|GOTOOLDIR|GOROOT|GOROOT_FINAL|GCCGOTOOLDIR|GOPATH|GOMODCACHE|GOCOVERDIR)
|
||||||
;&
|
|
||||||
GOCACHE)
|
|
||||||
;&
|
|
||||||
GOTMPDIR)
|
|
||||||
;&
|
|
||||||
GOTOOLDIR)
|
|
||||||
;&
|
|
||||||
GOROOT)
|
|
||||||
;&
|
|
||||||
GOROOT_FINAL)
|
|
||||||
;&
|
|
||||||
GCCGOTOOLDIR)
|
|
||||||
;&
|
|
||||||
GOPATH)
|
|
||||||
;&
|
|
||||||
GOMODCACHE)
|
|
||||||
_files -/
|
_files -/
|
||||||
;;
|
;;
|
||||||
# regular files (using fallthrough)
|
# regular files
|
||||||
GOMOD)
|
(GOMOD|PKG_CONFIG|GOENV)
|
||||||
;&
|
|
||||||
PKG_CONFIG)
|
|
||||||
;&
|
|
||||||
GOENV)
|
|
||||||
_files
|
_files
|
||||||
;;
|
;;
|
||||||
# special
|
# special
|
||||||
GOHOSTOS)
|
(GOHOSTOS|GOOS)
|
||||||
;&
|
|
||||||
GOOS)
|
|
||||||
# from https://golang.org/doc/install/source#environment
|
# from https://golang.org/doc/install/source#environment
|
||||||
_values 'operating system' aix android darwin dragonfly freebsd illumos ios js linux netbsd openbsd plan9 solaris windows wasip1
|
local -a supported_os=(
|
||||||
|
aix android darwin dragonfly freebsd illumos ios js linux netbsd openbsd plan9 solaris wasip1 windows
|
||||||
|
)
|
||||||
|
_values 'operating system' $supported_os
|
||||||
;;
|
;;
|
||||||
GOHOSTARCH)
|
(GOHOSTARCH|GOARCH)
|
||||||
;&
|
local -a supported_arch=(
|
||||||
GOARCH)
|
amd64 386 arm arm64 ppc64le ppc64 mips64le mips64 mipsle mips s390x riscv64 wasm
|
||||||
_values 'architecture' amd64 386 arm64 arm ppc64 ppc64le mips mipsle mips64 mips64le riscv64 s390x wasm
|
)
|
||||||
|
_values 'architecture' $supported_arch
|
||||||
;;
|
;;
|
||||||
CGO_ENABLED)
|
(CGO_ENABLED)
|
||||||
_values 'enable/disable cgo' 0 1
|
_values 'enable/disable cgo' 0 1
|
||||||
;;
|
;;
|
||||||
GO_EXTLINK_ENABLED)
|
(GO_EXTLINK_ENABLED)
|
||||||
_values 'enable/disable external linkage' 0 1
|
_values 'enable/disable external linkage' 0 1
|
||||||
;;
|
;;
|
||||||
GOARM)
|
(GOARM)
|
||||||
_values 'target arm architecture' 5 6 7
|
_values 'target arm architecture' 5 6 7
|
||||||
;;
|
;;
|
||||||
GO386)
|
(GO386)
|
||||||
_values 'x86 floating point instruction set' 387 sse2
|
_values 'x86 floating point instruction set' sse2 softfloat
|
||||||
;;
|
;;
|
||||||
GOAMD64)
|
(GOAMD64)
|
||||||
_values 'amd64 instruction set' v1 v2 v3 v4
|
_values 'amd64 instruction set' v1 v2 v3 v4
|
||||||
;;
|
;;
|
||||||
GOMIPS*)
|
(GOMIPS*)
|
||||||
_values 'mips floating point instructions' hardfloat softfloat
|
_values 'mips floating point instructions' hardfloat softfloat
|
||||||
;;
|
;;
|
||||||
GOPPC64)
|
(GOPPC64)
|
||||||
_values 'powerpc64 instruction set' power8 power9 power10
|
_values 'powerpc64 instruction set' power8 power9 power10
|
||||||
;;
|
;;
|
||||||
GOWASM)
|
(GOWASM)
|
||||||
_values 'web assembly features' -s ',' satconv signext
|
_values 'web assembly features' -s ',' satconv signext
|
||||||
;;
|
;;
|
||||||
GOPROXY)
|
(GOPROXY)
|
||||||
_urls
|
_urls
|
||||||
;;
|
;;
|
||||||
GOEXE)
|
(GOEXE)
|
||||||
_message "suffix for executables"
|
_message "suffix for executables"
|
||||||
;;
|
;;
|
||||||
CGO_*FLAGS_*ALLOW)
|
(CGO_*FLAGS_*ALLOW)
|
||||||
_message "regexp"
|
_message "regexp"
|
||||||
;;
|
;;
|
||||||
CGO_*FLAGS)
|
(CGO_*FLAGS)
|
||||||
_dispatch $service -value-,${variable#CGO_},-default-
|
_dispatch $service -value-,${variable#CGO_},-default-
|
||||||
;;
|
;;
|
||||||
GODEBUG)
|
(GODEBUG)
|
||||||
__go_runtimedebug
|
__go_runtimedebug
|
||||||
;;
|
;;
|
||||||
GOFLAGS)
|
(GOFLAGS)
|
||||||
# not implemented, sorry
|
# not implemented, sorry
|
||||||
;;
|
;;
|
||||||
GOINSECURE)
|
(GOINSECURE|GOPRIVATE|GONOPROXY|GONOSUMDB)
|
||||||
;&
|
|
||||||
GOPRIVATE)
|
|
||||||
;&
|
|
||||||
GONOPROXY)
|
|
||||||
;&
|
|
||||||
GONOSUMDB)
|
|
||||||
# comma separated glob patterns (in the syntax of Go's path.Match)
|
# comma separated glob patterns (in the syntax of Go's path.Match)
|
||||||
_message "comma separated glob pattern"
|
_message "comma separated glob pattern"
|
||||||
;;
|
;;
|
||||||
GOSUMDB)
|
(GOSUMDB)
|
||||||
_message "e.g. sum.golang.org+<publickey> https://sum.golang.org"
|
_message "e.g. sum.golang.org+<publickey> https://sum.golang.org"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__go_packages() {
|
||||||
|
local -a gopaths=("${(s/:/)$(go env GOPATH)}")
|
||||||
|
gopaths+=("$(go env GOROOT)")
|
||||||
|
for p in $gopaths; do
|
||||||
|
_path_files $@ -W "$p/src" -/
|
||||||
|
done
|
||||||
|
# no special treatment for
|
||||||
|
# - relative paths starting with ..
|
||||||
|
# - absolute path starting with /
|
||||||
|
# - variables, substitutions, subshells
|
||||||
|
if [[ $words[$CURRENT] = ..* || $words[$CURRENT] = \$* || $words[$CURRENT] = /* ]]; then
|
||||||
|
_path_files $@ -/ -g '*.go'
|
||||||
|
else
|
||||||
|
# go build accepts paths relative to the cwd but they must start with './', so prefix them
|
||||||
|
_path_files $@ -P './' -/ -g '*.go'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
__go_fix_names() {
|
||||||
|
local -a fix_names=(
|
||||||
|
'buildtag[remove +build comments from modules using Go 1.18 or later]'
|
||||||
|
'cftype[fixes initialzers 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]'
|
||||||
|
)
|
||||||
|
|
||||||
|
_values -s ',' 'fix name' $fix_names
|
||||||
|
}
|
||||||
|
|
||||||
if [[ "$service" = -value-* ]]; then
|
if [[ "$service" = -value-* ]]; then
|
||||||
variable=${${service%,-default-}#-value-,}
|
local env_variable=${${service%,-default-}#-value-,}
|
||||||
# some special variables are not read from the environment
|
# some special variables are not read from the environment
|
||||||
local -a blacklist
|
local -a blacklist=('GOEXE' 'GOGCCFLAGS' 'GOHOSTARCH' 'GOHOSTOS' 'GOMOD' 'GOTOOLDIR')
|
||||||
blacklist=('GOEXE' 'GOGCCFLAGS' 'GOHOSTARCH' 'GOHOSTOS' 'GOMOD' 'GOTOOLDIR')
|
if (($blacklist[(I)$env_variable])); then
|
||||||
if (($blacklist[(I)$variable])); then
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
__go_envvarvals $variable
|
__go_envvarvals $env_variable
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -377,40 +380,32 @@ case $state in
|
||||||
'-go[sets the expected Go language version]:goversion'
|
'-go[sets the expected Go language version]:goversion'
|
||||||
'*-replace=[add a replacement of the given module path and version]:replace'
|
'*-replace=[add a replacement of the given module path and version]:replace'
|
||||||
'*-dropreplace=[drop a replacement of the given module path and version]:dropreplace'
|
'*-dropreplace=[drop a replacement of the given module path and version]:dropreplace'
|
||||||
|
'-toolchain=[set the Go toolchain to use]:name'
|
||||||
'-json[prints the final go.mod/work file in JSON format]'
|
'-json[prints the final go.mod/work file in JSON format]'
|
||||||
'-print[prints the final go.mod/work in its text format]'
|
'-print[prints the final go.mod/work in its text format]'
|
||||||
)
|
)
|
||||||
|
local -a mod_commands=(
|
||||||
__go_packages() {
|
'download:download modules to local cache'
|
||||||
local gopaths
|
'edit:edit go.mod from tools or scripts'
|
||||||
declare -a gopaths
|
'graph:print module requirement graph'
|
||||||
gopaths=("${(s/:/)$(go env GOPATH)}")
|
'init:initialize new module in current directory'
|
||||||
gopaths+=("$(go env GOROOT)")
|
'tidy:add missing and remove unused modules'
|
||||||
for p in $gopaths; do
|
'vendor:make vendored copy of dependencies'
|
||||||
_path_files $@ -W "$p/src" -/
|
'verify:verify dependencies have expected content'
|
||||||
done
|
'why:explain why packages or modules are needed'
|
||||||
# no special treatment for
|
'help:get more information about a command'
|
||||||
# - relative paths starting with ..
|
)
|
||||||
# - absolute path starting with /
|
|
||||||
# - variables, substitutions, subshells
|
|
||||||
if [[ $words[$CURRENT] = ..* || $words[$CURRENT] = \$* || $words[$CURRENT] = /* ]]; then
|
|
||||||
_path_files $@ -/ -g '*.go'
|
|
||||||
else
|
|
||||||
# go build accepts paths relative to the cwd but they must start with './', so prefix them
|
|
||||||
_path_files $@ -P './' -/ -g '*.go'
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
case $words[1] in
|
case $words[1] in
|
||||||
build)
|
(build)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-o[force build to write to named output file or directory]:file or directory:_files' \
|
'-o[force build to write to named output file or directory]:file or directory:_files' \
|
||||||
${build_flags[@]} \
|
${build_flags[@]} \
|
||||||
${mod_flags[@]} \
|
${mod_flags[@]} \
|
||||||
'*:importpaths:__go_packages'
|
'*:importpaths:__go_packages'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
clean)
|
(clean)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-i[remove corresponding installed archive or binary]' \
|
'-i[remove corresponding installed archive or binary]' \
|
||||||
'-r[apply clean recursively on all dependencies]' \
|
'-r[apply clean recursively on all dependencies]' \
|
||||||
|
|
@ -421,24 +416,28 @@ case $state in
|
||||||
${build_flags[@]} \
|
${build_flags[@]} \
|
||||||
${mod_flags[@]} \
|
${mod_flags[@]} \
|
||||||
'*:importpaths:__go_packages'
|
'*:importpaths:__go_packages'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
doc)
|
(doc)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-all[show all the documentation for the package]' \
|
'-all[show all the documentation for the package]' \
|
||||||
'-c[respect case when matching symbols]' \
|
'-c[respect case when matching symbols]' \
|
||||||
'-cmd[treat a command (package main) like a regular package]' \
|
'-cmd[treat a command (package main) like a regular package]' \
|
||||||
'-short[one-line representation for each symbol]' \
|
'-short[one-line representation for each symbol]' \
|
||||||
'-src[show the full source code for the symbol]' \
|
'-src[show the full source code for the symbol]' \
|
||||||
'-u[show docs for unexported and exported symbols and methods]'
|
'-u[show docs for unexported and exported symbols and methods]' \
|
||||||
;;
|
'*:importpaths:__go_packages'
|
||||||
|
;;
|
||||||
|
|
||||||
env)
|
(env)
|
||||||
local -a goenvvars=(
|
local -a goenvvars=(
|
||||||
"GOARCH[architecture, or processor, for which to compile code.]:architecture"
|
# General-purpose environment variables
|
||||||
|
"GO111MODULE[controls whether the go command runs in module-aware mode]:value"
|
||||||
"GCCGO[gccgo command to run.]:gccgo command"
|
"GCCGO[gccgo command to run.]:gccgo command"
|
||||||
|
"GOARCH[architecture, or processor, for which to compile code.]:architecture"
|
||||||
"GOBIN[directory where 'go install' installs to]:go install target dir"
|
"GOBIN[directory where 'go install' installs to]:go install target dir"
|
||||||
"GOCACHE[directory to store cached information]:go build cache dir"
|
"GOCACHE[directory to store cached information]:go build cache dir"
|
||||||
|
"GOMODCACHE[module cache directory]:path"
|
||||||
"GODEBUG[enable runtime debug facilities]:runtime debug settings"
|
"GODEBUG[enable runtime debug facilities]:runtime debug settings"
|
||||||
"GOENV[location of the go environment configuration file]:configuration file"
|
"GOENV[location of the go environment configuration file]:configuration file"
|
||||||
"GOFLAGS[default go command line flags]:space separated default command line flags"
|
"GOFLAGS[default go command line flags]:space separated default command line flags"
|
||||||
|
|
@ -446,13 +445,16 @@ case $state in
|
||||||
"GOOS[target operating system]:operating system"
|
"GOOS[target operating system]:operating system"
|
||||||
"GOPATH[path to resolve import statements]:import path"
|
"GOPATH[path to resolve import statements]:import path"
|
||||||
"GOPROXY[URL of go module proxy]:proxy url"
|
"GOPROXY[URL of go module proxy]:proxy url"
|
||||||
"GOROOT[root of the go tree]:go root directory"
|
|
||||||
"GOTMPDIR[directory for temporary sources, packages, and binaries]:tmp directory"
|
|
||||||
"GOPRIVATE[modules that should always be fetched directly]:comma separated glob patterns"
|
"GOPRIVATE[modules that should always be fetched directly]:comma separated glob patterns"
|
||||||
"GONOPROXY[modules that should always be fetched directly]:comma separated glob patterns"
|
"GONOPROXY[modules that should always be fetched directly]:comma separated glob patterns"
|
||||||
"GONOSUMDB[modules that should not be compared against the checksum db]:comma separated glob patterns"
|
"GONOSUMDB[modules that should not be compared against the checksum db]:comma separated glob patterns"
|
||||||
"GOMODCACHE[module cache directory]:path"
|
"GOROOT[root of the go tree]:go root directory"
|
||||||
"GOSUMDB[checksum database]:name(+publickey( url))"
|
"GOSUMDB[checksum database]:name(+publickey( url))"
|
||||||
|
"GOTOOLCHAIN[control which Go tool chain is used]:toolchain"
|
||||||
|
"GOTMPDIR[directory for temporary sources, packages, and binaries]:tmp directory"
|
||||||
|
"GOVCS[lists version control commands that may be used with matching servers]:commands"
|
||||||
|
"GOWORK[use the given go.work file as a workspace file]:workspace_file"
|
||||||
|
# Environment variables for use with cgo
|
||||||
"AR[command for manipulating library archives (for gccgo)]:archive manipulation program"
|
"AR[command for manipulating library archives (for gccgo)]:archive manipulation program"
|
||||||
"CC[command to compile C code]:C compiler"
|
"CC[command to compile C code]:C compiler"
|
||||||
"CGO_ENABLED[enable/disable cgo]:boolean"
|
"CGO_ENABLED[enable/disable cgo]:boolean"
|
||||||
|
|
@ -474,6 +476,7 @@ case $state in
|
||||||
"CXX[command to compile C++]:C++ compiler"
|
"CXX[command to compile C++]:C++ compiler"
|
||||||
"FC[command to compile Fortran]:Fortran compiler"
|
"FC[command to compile Fortran]:Fortran compiler"
|
||||||
"PKG_CONFIG[Path to pkg-config tool.]:path to pkg-config"
|
"PKG_CONFIG[Path to pkg-config tool.]:path to pkg-config"
|
||||||
|
# Architecture-specific environment variables
|
||||||
"GOARM[arm architecture]:arm architecture"
|
"GOARM[arm architecture]:arm architecture"
|
||||||
"GO386[x86 instruction set]:x86 instruction set"
|
"GO386[x86 instruction set]:x86 instruction set"
|
||||||
"GOAMD64[amd64 instruction set]:amd64 instruction set"
|
"GOAMD64[amd64 instruction set]:amd64 instruction set"
|
||||||
|
|
@ -481,20 +484,26 @@ case $state in
|
||||||
"GOMIPS64[mips64 instruction set]:mips64 instruction set"
|
"GOMIPS64[mips64 instruction set]:mips64 instruction set"
|
||||||
"GOPPC64[powerpc64 instruction set]:powerpc64 instruction set"
|
"GOPPC64[powerpc64 instruction set]:powerpc64 instruction set"
|
||||||
"GOWASM[web assembly features]:comma separated web assembly features"
|
"GOWASM[web assembly features]:comma separated web assembly features"
|
||||||
|
# Environment variable for use with code coverage
|
||||||
|
"GOCOVERDIR[directory into which to write code coverage data files]"
|
||||||
|
# Special-purpose environment variables
|
||||||
"GCCGOTOOLDIR[directory of gccgo tools]:gccgo tool directory"
|
"GCCGOTOOLDIR[directory of gccgo tools]:gccgo tool directory"
|
||||||
|
"GOEXPERIMENT[comma-separated list of toolchain experiments to enable or disable]"
|
||||||
"GOROOT_FINAL[root of the go tree]:go root"
|
"GOROOT_FINAL[root of the go tree]:go root"
|
||||||
"GO_EXTLINK_ENABLED[enable external linking mode]:boolean"
|
"GO_EXTLINK_ENABLED[enable external linking mode]:boolean"
|
||||||
"GIT_ALLOW_PROTOCOL[schemes allowed to fetch]:colon separated git schemes"
|
"GIT_ALLOW_PROTOCOL[schemes allowed to fetch]:colon separated git schemes"
|
||||||
|
# Additional information
|
||||||
"GOEXE[suffix for executables]:executable suffix"
|
"GOEXE[suffix for executables]:executable suffix"
|
||||||
"GOGCCFLAGS[arguments supplied to CC]:space separated arguments to CC"
|
"GOGCCFLAGS[arguments supplied to CC]:space separated arguments to CC"
|
||||||
"GOHOSTARCH[architecture of the toolchain binaries]:host os architecture"
|
"GOHOSTARCH[architecture of the toolchain binaries]:host os architecture"
|
||||||
"GOHOSTOS[operating system of the toolchain binaries]:host os"
|
"GOHOSTOS[operating system of the toolchain binaries]:host os"
|
||||||
"GOMOD[absolute path the the main go.mod]:abs path to main go.mod"
|
"GOMOD[absolute path the the main go.mod]:abs path to main go.mod"
|
||||||
"GOTOOLDIR[installation directory of go tools]:tool installation directory"
|
"GOTOOLDIR[installation directory of go tools]:tool installation directory"
|
||||||
|
"GOVERSION[The version of the installed Go tree]"
|
||||||
)
|
)
|
||||||
local -a exclude_from_w=(GOENV)
|
local -a exclude_from_w=(GOENV)
|
||||||
|
|
||||||
__list_env_vars() {
|
__go_list_env_vars() {
|
||||||
# the parameter expansion strops off everything after the first [
|
# the parameter expansion strops off everything after the first [
|
||||||
_values -s ' ' -w 'environment variable' ${goenvvars[@]%%\[*}
|
_values -s ' ' -w 'environment variable' ${goenvvars[@]%%\[*}
|
||||||
}
|
}
|
||||||
|
|
@ -506,35 +515,41 @@ case $state in
|
||||||
'-json[print the environment in JSON format]' \
|
'-json[print the environment in JSON format]' \
|
||||||
'-u[unset environment variables]' \
|
'-u[unset environment variables]' \
|
||||||
'-w[change the default setting of environment variables]' \
|
'-w[change the default setting of environment variables]' \
|
||||||
'*:[show environment variable]: __list_env_vars' || _values \
|
'*:[show environment variable]: __go_list_env_vars' || _values \
|
||||||
-s ' ' -S "=" -w 'environment variable' ${^goenvvars:#GOENV*}": __go_envvarvals"
|
-s ' ' -S "=" -w 'environment variable' ${^goenvvars:#GOENV*}": __go_envvarvals"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
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]' \
|
||||||
|
'-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'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
fmt)
|
(fmt)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-C[change to directory before running the command]: :_files -/' \
|
'-C[change to directory before running the command]: :_files -/' \
|
||||||
'-n[prints commands that would be executed]' \
|
'-n[print commands that would be executed]' \
|
||||||
'-x[prints commands as they are executed]' \
|
'-x[print commands as they are executed]' \
|
||||||
|
'-mod=[set which download mode to use]:mode:(readonly vendor)' \
|
||||||
'*:importpaths:__go_packages'
|
'*:importpaths:__go_packages'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
generate)
|
(generate)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-C[change to directory before running the command]: :_files -/' \
|
'-C[change to directory before running the command]: :_files -/' \
|
||||||
'-run=[specifies a regular expression to select directives]:regex' \
|
'-run=[specifies a regular expression to select directives]:regex' \
|
||||||
'-x[print the commands]' \
|
'-x[print the commands]' \
|
||||||
'-n[print the commands but do not run them]' \
|
'-n[print the commands but do not run them]' \
|
||||||
'-v[print the names of packages as they are compiled]' \
|
'-v[print the names of packages as they are compiled]' \
|
||||||
|
${build_flags[@]} \
|
||||||
"*:args:{ _alternative ':importpaths:__go_packages' _files }"
|
"*:args:{ _alternative ':importpaths:__go_packages' _files }"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
get)
|
(get)
|
||||||
# no mod_flags for get
|
# no mod_flags for get
|
||||||
_arguments \
|
_arguments \
|
||||||
'-d[instructs get to stop after downloading the packages]' \
|
'-d[instructs get to stop after downloading the packages]' \
|
||||||
|
|
@ -547,18 +562,21 @@ case $state in
|
||||||
'*:importpaths:__go_packages'
|
'*:importpaths:__go_packages'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
install)
|
(install)
|
||||||
_arguments ${build_flags[@]} \
|
_arguments ${build_flags[@]} \
|
||||||
'*:importpaths:__go_packages'
|
'*:importpaths:__go_packages'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
list)
|
(list)
|
||||||
local -a list_args=(
|
local -a list_args=(
|
||||||
'-e[changes the handling of erroneous packages]'
|
'-e[changes the handling of erroneous packages]'
|
||||||
'-f[specifies an alternate format for the list]:format'
|
'-f[specifies an alternate format for the list]:format'
|
||||||
'-json[causes package data to be printed in JSON format]'
|
'-json[causes package data to be printed in JSON format]'
|
||||||
'-compiled[set CompiledGoFiles to the Go source files presented to the compiler]'
|
'-compiled[set CompiledGoFiles to the Go source files presented to the compiler]'
|
||||||
'-deps[iterate over named packages and their dependencies]'
|
'-deps[iterate over named packages and their dependencies]'
|
||||||
|
'-export[set the Export for the given package]:package'
|
||||||
|
'-find[identify the named packages but not resolve their dependencies]:package'
|
||||||
|
'-test[report not only the named packages but also their test binaries]'
|
||||||
'-m[list modules instead of packages]'
|
'-m[list modules instead of packages]'
|
||||||
${build_flags[@]}
|
${build_flags[@]}
|
||||||
${mod_flags[@]}
|
${mod_flags[@]}
|
||||||
|
|
@ -567,40 +585,28 @@ case $state in
|
||||||
# -u and -versions are only available if -m is present on the commandline
|
# -u and -versions are only available if -m is present on the commandline
|
||||||
if (($words[(I)-m])); then
|
if (($words[(I)-m])); then
|
||||||
list_args+=(
|
list_args+=(
|
||||||
'-u[adds information about available upgrades]'
|
'-u[adds information about available upgrades]'
|
||||||
'-versions[list all known versions of modules]'
|
'-versions[list all known versions of modules]'
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
_arguments ${list_args[@]}
|
_arguments ${list_args[@]}
|
||||||
;;
|
;;
|
||||||
|
|
||||||
mod)
|
(mod)
|
||||||
local -a mod_commands=(
|
|
||||||
'download:download modules to local cache'
|
|
||||||
'edit:edit go.mod from tools or scripts'
|
|
||||||
'graph:print module requirement graph'
|
|
||||||
'init:initialize new module in current directory'
|
|
||||||
'tidy:add missing and remove unused modules'
|
|
||||||
'vendor:make vendored copy of dependencies'
|
|
||||||
'verify:verify dependencies have expected content'
|
|
||||||
'why:explain why packages or modules are needed'
|
|
||||||
'help:get more information about a command'
|
|
||||||
)
|
|
||||||
|
|
||||||
_arguments \
|
_arguments \
|
||||||
"1: :{_describe 'command' mod_commands}" \
|
"1: :{_describe 'command' mod_commands}" \
|
||||||
'*:: :->args'
|
'*:: :->args'
|
||||||
|
|
||||||
case $state in
|
case $state in
|
||||||
args)
|
(args)
|
||||||
case $words[1] in
|
case $words[1] in
|
||||||
download)
|
(download)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-json[print a sequence of JSON objects to standard output]' \
|
'-json[print a sequence of JSON objects to standard output]' \
|
||||||
'-x[print the commands download executes]'
|
'-x[print the commands download executes]' \
|
||||||
|
'-reuse[file containing the JSON output of a previous "go mod download -json" invocation]:json:_files -g "*.json"'
|
||||||
;;
|
;;
|
||||||
|
(edit)
|
||||||
edit)
|
|
||||||
_arguments \
|
_arguments \
|
||||||
${edit_flags[@]} \
|
${edit_flags[@]} \
|
||||||
"-module[change the module's path]" \
|
"-module[change the module's path]" \
|
||||||
|
|
@ -608,31 +614,31 @@ case $state in
|
||||||
'*-dropexclude=[drop an exclusion for the given module path and version]:dropexclude' \
|
'*-dropexclude=[drop an exclusion for the given module path and version]:dropexclude' \
|
||||||
':go.mod:_path_files -g "go.mod"'
|
':go.mod:_path_files -g "go.mod"'
|
||||||
;;
|
;;
|
||||||
graph)
|
(graph)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-go[report the module graph as loaded by the given Go version]:goversion'
|
'-go[report the module graph as loaded by the given Go version]:goversion' \
|
||||||
|
'-x[print the commands graph executes]'
|
||||||
;;
|
;;
|
||||||
init)
|
(init)
|
||||||
# Use go packages as module name suggestion
|
# Use go packages as module name suggestion
|
||||||
_arguments \
|
_arguments \
|
||||||
'*:module:__go_packages'
|
'*:module:__go_packages'
|
||||||
;;
|
;;
|
||||||
tidy)
|
(tidy)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-v[print information about removed modules to standard error]' \
|
'-v[print information about removed modules to standard error]' \
|
||||||
'-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]' \
|
||||||
'-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]'
|
'-compat[preserves additional checksums needed for the indicated Go version]:version'
|
||||||
;;
|
;;
|
||||||
vendor)
|
(vendor)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-v[print the names of vendored modules and packages to standard error]' \
|
'-v[print the names of vendored modules and packages to standard error]' \
|
||||||
'-e[attempt to proceed despite errors encountered while loading packages]' \
|
'-e[attempt to proceed despite errors encountered while loading packages]' \
|
||||||
'-o[create the vendor directory at the given path instead of "vendor"]:directory:_path_files -/'
|
'-o[create the vendor directory at the given path instead of "vendor"]:directory:_path_files -/'
|
||||||
;;
|
;;
|
||||||
verify)
|
(why)
|
||||||
;;
|
|
||||||
why)
|
|
||||||
_arguments \
|
_arguments \
|
||||||
'-m[treats the arguments as a list of modules]' \
|
'-m[treats the arguments as a list of modules]' \
|
||||||
'-vendor[exclude tests of dependencies]' \
|
'-vendor[exclude tests of dependencies]' \
|
||||||
|
|
@ -643,14 +649,14 @@ case $state in
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
run)
|
(run)
|
||||||
_arguments \
|
_arguments \
|
||||||
${build_flags[@]} \
|
${build_flags[@]} \
|
||||||
'-exec[invoke the binary using xprog]:xporg' \
|
'-exec[invoke the binary using xprog]:xporg' \
|
||||||
'*:importpaths:__go_packages'
|
'*:importpaths:__go_packages'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
test)
|
(test)
|
||||||
if [[ $words[$CURRENT] = -test.* ]]; then
|
if [[ $words[$CURRENT] = -test.* ]]; then
|
||||||
_arguments \
|
_arguments \
|
||||||
'-test.bench[run only benchmarks matching regexp]:regexp' \
|
'-test.bench[run only benchmarks matching regexp]:regexp' \
|
||||||
|
|
@ -709,11 +715,13 @@ case $state in
|
||||||
'-memprofile[write a memory profile to file]:mem' \
|
'-memprofile[write a memory profile to file]:mem' \
|
||||||
'-memprofilerate[enable more precise memory profiles]:n' \
|
'-memprofilerate[enable more precise memory profiles]:n' \
|
||||||
'-mutexprofile[write a mutex contention profile to the specified file]:file:_files' \
|
'-mutexprofile[write a mutex contention profile to the specified file]:file:_files' \
|
||||||
'-outputdir[place output files from profiling in output dir]:dir' \
|
'-mutexprofilefraction[sample 1 in n stack traces of goroutines holding a contended mutex]:n' \
|
||||||
|
'-outputdir[place output files from profiling in output dir]:dir:_path_files -/' \
|
||||||
'-parallel[allow parallel execution of test functions]:n' \
|
'-parallel[allow parallel execution of test functions]:n' \
|
||||||
'-run[run tests and examples matching the regular expression]:regexp' \
|
'-run[run tests and examples matching the regular expression]:regexp' \
|
||||||
'-short[tell long-running tests to shorten their run time]' \
|
'-short[tell long-running tests to shorten their run time]' \
|
||||||
'-shuffle[randomize the execution order of tests and benchmarks]:type:(off on)' \
|
'-shuffle[randomize the execution order of tests and benchmarks]:type:(off on)' \
|
||||||
|
'-skip[run only tests that do not match the regular expression]:pattern' \
|
||||||
'-test.-[specify options for test running]:test running options:' \
|
'-test.-[specify options for test running]:test running options:' \
|
||||||
'-timeout[timeout long running tests]:t' \
|
'-timeout[timeout long running tests]:t' \
|
||||||
'-trace[write an execution trace to the specified file]:trace' \
|
'-trace[write an execution trace to the specified file]:trace' \
|
||||||
|
|
@ -724,11 +732,10 @@ case $state in
|
||||||
'-o[compile test binary to named file]:file:_files' \
|
'-o[compile test binary to named file]:file:_files' \
|
||||||
'*:importpaths:__go_packages'
|
'*:importpaths:__go_packages'
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
tool)
|
(tool)
|
||||||
local -a tools
|
local -a tools=($(go tool))
|
||||||
tools=($(go tool))
|
|
||||||
|
|
||||||
_arguments \
|
_arguments \
|
||||||
'-n[print command that would be executed]' \
|
'-n[print command that would be executed]' \
|
||||||
|
|
@ -736,62 +743,61 @@ case $state in
|
||||||
'*:: :->args'
|
'*:: :->args'
|
||||||
|
|
||||||
case $state in
|
case $state in
|
||||||
args)
|
(args)
|
||||||
case $words[1] in
|
case $words[1] in
|
||||||
addr2line)
|
(addr2line)
|
||||||
_files
|
_files
|
||||||
;;
|
;;
|
||||||
|
|
||||||
asm)
|
(asm)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-D[predefined symbol with optional simple value]:value' \
|
'*-D[predefined symbol with optional simple value]:value' \
|
||||||
'-I[include directory]:value' \
|
'*-I[include directory]:value' \
|
||||||
'-S[print assembly and machine code]' \
|
'-S[print assembly and machine code]' \
|
||||||
|
'(- *)-V[print assembler version and exit]' \
|
||||||
'-debug[dump instructions as they are parsed]' \
|
'-debug[dump instructions as they are parsed]' \
|
||||||
'-dynlink[support references to Go symbols]' \
|
'-dynlink[support references to Go symbols]' \
|
||||||
'-o[output file]:string' \
|
'-e[no limit on number of errors reported]' \
|
||||||
|
'-gensymabis[write symbol ABI information to output file. Do not assemble]' \
|
||||||
|
'-o[output file]:string:_files' \
|
||||||
|
'-p[set expected package import to pkgpath]:pkgpath' \
|
||||||
'-shared[generate code that can be linked into a shared lib]' \
|
'-shared[generate code that can be linked into a shared lib]' \
|
||||||
'-trimpath[remove prefix from recorded source file paths]:string'
|
'-spectre[enable spectre mitigations in list]:list:(all ret)' \
|
||||||
|
'-trimpath[remove prefix from recorded source file paths]:string' \
|
||||||
|
'-v[print debug output]' \
|
||||||
|
'*:file:_files'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
callgraph)
|
(buildid)
|
||||||
local -a algos=(
|
|
||||||
'static:static calls only'
|
|
||||||
'cha:Class Hierarchy Analysis'
|
|
||||||
'rta:Rapid Type Analysis'
|
|
||||||
'pta:inclusion-based Points-To Analysis'
|
|
||||||
)
|
|
||||||
local -a graphs=(
|
|
||||||
'digraph:output in digraph format'
|
|
||||||
'graphviz:output in AT&T GraphViz (.dot) format'
|
|
||||||
)
|
|
||||||
|
|
||||||
_arguments \
|
_arguments \
|
||||||
'-algo=[call-graph construction algorithm]:algos:{ _describe "algos" algos }' \
|
'-w[rewrite the build ID found in the file]' \
|
||||||
"-test[include the package's tests in the analysis]" \
|
'*:file:_files'
|
||||||
'-format=[format in which each call graph edge is displayed]:graphs:{ _describe "graphs" graphs }'
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
cgo)
|
(cgo)
|
||||||
_arguments \
|
_arguments \
|
||||||
|
'(- *)-V[print cgo version and exit]' \
|
||||||
'-debug-define[print relevant #defines]' \
|
'-debug-define[print relevant #defines]' \
|
||||||
'-debug-gcc[print gcc invocations]' \
|
'-debug-gcc[print gcc invocations]' \
|
||||||
'-dynimport[if non-empty, print dynamic import data]:string' \
|
'-dynimport[if non-empty, print dynamic import data]:string' \
|
||||||
'-dynlinker[record dynamic linker information]' \
|
'-dynlinker[record dynamic linker information]' \
|
||||||
'-dynout[write -dynimport output to file]:file' \
|
'-dynout[write -dynimport output to file]:file:_files' \
|
||||||
'-dynpackage[set Go package for -dynimport output]:string' \
|
'-dynpackage[set Go package for -dynimport output]:string' \
|
||||||
'-exportheader[where to write export header]:string' \
|
'-exportheader[where to write export header]:string' \
|
||||||
'-gccgo[generate files for use with gccgo]' \
|
'-importpath[the import path for the Go package]:package' \
|
||||||
'-gccgopkgpath[-fgo-pkgpath option used with gccgo]:string' \
|
|
||||||
'-gccgoprefix[-fgo-prefix option used with gccgo]:string' \
|
|
||||||
'-godefs[write Go definitions for C file to stdout]' \
|
|
||||||
'-import_runtime_cgo[import runtime/cgo in generated code]' \
|
'-import_runtime_cgo[import runtime/cgo in generated code]' \
|
||||||
'-import_syscall[import syscall in generated code]' \
|
'-import_syscall[import syscall in generated code]' \
|
||||||
'-importpath[import path of package being built]:path' \
|
'-gccgo[generate files for use with gccgo]' \
|
||||||
'-objdir[object directory]:dir'
|
'-gccgoprefix[-fgo-prefix option used with gccgo]:string' \
|
||||||
|
'-gccgopkgpath[-fgo-pkgpath option used with gccgo]:string:_path_files -/' \
|
||||||
|
'-gccgo_define_cgoincomplete[define cgo.Incomplete locally rather than importing it from "runtime/cgo" package]' \
|
||||||
|
'-godefs[write Go definitions for C file to stdout]' \
|
||||||
|
'-objdir[object directory]:dir:_path_files -/' \
|
||||||
|
'-srcdir[source directory]:dir:_path_files -/' \
|
||||||
|
'*:file:_files'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
compile)
|
(compile)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-%[debug non-static initializers]' \
|
'-%[debug non-static initializers]' \
|
||||||
'-+[compiling runtime]' \
|
'-+[compiling runtime]' \
|
||||||
|
|
@ -799,35 +805,47 @@ case $state in
|
||||||
'-B[disable bounds checking]' \
|
'-B[disable bounds checking]' \
|
||||||
'-D[set relative path for local imports]:path' \
|
'-D[set relative path for local imports]:path' \
|
||||||
'-E[debug symbol export]' \
|
'-E[debug symbol export]' \
|
||||||
'-I[add directory to import search path]:directory' \
|
'*-I[add directory to import search path]:directory' \
|
||||||
'-K[debug missing line numbers]' \
|
'-K[debug missing line numbers]' \
|
||||||
'-L[use full (long) path in error messages]' \
|
'-L[use full (long) path in error messages]' \
|
||||||
'-M[debug move generation]' \
|
'-M[debug move generation]' \
|
||||||
'-N[disable optimizations]' \
|
'-N[disable optimizations]' \
|
||||||
'-P[debug peephole optimizer]' \
|
'-P[debug peephole optimizer]' \
|
||||||
'-R[debug register optimizer]' \
|
'-R[debug register optimizer]' \
|
||||||
'-S[print assembly listing]' \
|
'*-S[print assembly listing]' \
|
||||||
'-V[print compiler version]' \
|
'(- *)-V[print compiler version and exit]' \
|
||||||
'-W[debug parse tree after type checking]' \
|
'-W[debug parse tree after type checking]' \
|
||||||
'-asmhdr[write assembly header to file]:file' \
|
'-asmhdr[write assembly header to file]:file' \
|
||||||
|
'-asan[insert calls to C/C++ address sanitizer]' \
|
||||||
'-buildid[record id as the build id in the export metadata]:id' \
|
'-buildid[record id as the build id in the export metadata]:id' \
|
||||||
|
'-blockprofile[write block profile for the compilation to file]:file:_files' \
|
||||||
|
'-c[concurrency during compilation]:concurrency' \
|
||||||
'-complete[compiling complete package (no C or assembly)]' \
|
'-complete[compiling complete package (no C or assembly)]' \
|
||||||
'-cpuprofile[write cpu profile to file]:file' \
|
'-cpuprofile[write cpu profile to file]:file:_files' \
|
||||||
'-d[print debug information about items in list]:list' \
|
'-d[print debug information about items in list]:list' \
|
||||||
|
'-dwarf[generate DWARF symbols]' \
|
||||||
|
'-dwarflocationlists[add location lists to DWARF in optimized mode]' \
|
||||||
|
'-gendwarfinl[generate DWARF inline info records]:num' \
|
||||||
'-dynlink[support references to Go symbols]' \
|
'-dynlink[support references to Go symbols]' \
|
||||||
'-e[no limit on number of errors reported]' \
|
'-e[no limit on number of errors reported]' \
|
||||||
'-f[debug stack frames]' \
|
'-f[debug stack frames]' \
|
||||||
'-g[debug code generation]' \
|
'-g[debug code generation]' \
|
||||||
|
'-goversion[specify required go tool version of the runtime]:version' \
|
||||||
'-h[halt on error]' \
|
'-h[halt on error]' \
|
||||||
'-i[debug line number stack]' \
|
'-i[debug line number stack]' \
|
||||||
|
'-importcfg[read import configuration from file]:config:_files' \
|
||||||
'-installsuffix[set pkg directory suffix]:suffix' \
|
'-installsuffix[set pkg directory suffix]:suffix' \
|
||||||
'-j[debug runtime-initialized variables]' \
|
'-j[debug runtime-initialized variables]' \
|
||||||
'-l[disable inlining]' \
|
'-l[disable inlining]' \
|
||||||
|
'-lang[set language version to compile]:version' \
|
||||||
'-largemodel[generate code that assumes a large memory model]' \
|
'-largemodel[generate code that assumes a large memory model]' \
|
||||||
|
'-linjobj[write linker-specific object to file and compiler-specific object to usual output file]:file:_files' \
|
||||||
'-live[debug liveness analysis]' \
|
'-live[debug liveness analysis]' \
|
||||||
'-m[print optimization decisions]' \
|
'-m[print optimization decisions]' \
|
||||||
'-memprofile[write memory profile to file]:file' \
|
'-memprofile[write memory profile to file]:file' \
|
||||||
'-memprofilerate[set runtime.MemProfileRate to rate]:rate' \
|
'-memprofilerate[set runtime.MemProfileRate to rate]:rate' \
|
||||||
|
'-msan[insert calls to C/C++ memory sanitizer]' \
|
||||||
|
'-mutexprofile[write mutex profile for the compilation to file]:file:_files' \
|
||||||
'-nolocalimports[reject local (relative) imports]' \
|
'-nolocalimports[reject local (relative) imports]' \
|
||||||
'-o[write output to file]:file' \
|
'-o[write output to file]:file' \
|
||||||
'-p[set expected package import path]:path' \
|
'-p[set expected package import path]:path' \
|
||||||
|
|
@ -836,6 +854,8 @@ case $state in
|
||||||
'-race[enable race detector]' \
|
'-race[enable race detector]' \
|
||||||
'-s[warn about composite literals that can be simplified]' \
|
'-s[warn about composite literals that can be simplified]' \
|
||||||
'-shared[generate code that can be linked into a shared library]' \
|
'-shared[generate code that can be linked into a shared library]' \
|
||||||
|
'-spectre[enable spectre mitigations in list]:type:(all index ret)' \
|
||||||
|
'-traceprofile[write an execution trace to file]:file:_files' \
|
||||||
'-trimpath[remove prefix from recorded source file paths]:prefix' \
|
'-trimpath[remove prefix from recorded source file paths]:prefix' \
|
||||||
'-u[reject unsafe code]' \
|
'-u[reject unsafe code]' \
|
||||||
'-v[increase debug verbosity]' \
|
'-v[increase debug verbosity]' \
|
||||||
|
|
@ -861,18 +881,19 @@ case $state in
|
||||||
'*:file:_files -g "*.go(-.)"'
|
'*:file:_files -g "*.go(-.)"'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
doc)
|
(doc)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-c[respect case when matching symbols]' \
|
'-c[respect case when matching symbols]' \
|
||||||
'-cmd[treat a command (package main) like a regular package]' \
|
'-cmd[treat a command (package main) like a regular package]' \
|
||||||
'-u[show docs for unexported and exported symbols and methods]' \
|
'-u[show docs for unexported and exported symbols and methods]'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
fix)
|
(fix)
|
||||||
_arguments \
|
_arguments \
|
||||||
|
'(* -)-help[show help message]' \
|
||||||
'-diff[display diffs instead of rewriting files]' \
|
'-diff[display diffs instead of rewriting files]' \
|
||||||
'-force[force fixes to run even if the code looks updated]:string' \
|
'-force[force fixes to run even if the code looks updated]:string:__go_fix_names' \
|
||||||
'-r[restrict the rewrites]:string' \
|
'-r[restrict the rewrites]:string:__go_fix_names' \
|
||||||
'*:files:_files'
|
'*:files:_files'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
@ -920,14 +941,25 @@ case $state in
|
||||||
'*:files:_files'
|
'*:files:_files'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
objdump)
|
(objdump)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-s[only dump symbols matching this regexp]:regexp' \
|
'-s[only dump symbols matching this regexp]:regexp' \
|
||||||
'*:files:_files'
|
'*:files:_files'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
pack)
|
(pack)
|
||||||
_arguments '1:ops:(c p r t x)' '::verbose:(v)' ':files:_files'
|
local -a pack_ops=(
|
||||||
|
'c:append files to a new archive'
|
||||||
|
'p:print files from the archive'
|
||||||
|
'r:append files to the archive'
|
||||||
|
't:list files from the archive'
|
||||||
|
'x:extract files from the archive'
|
||||||
|
)
|
||||||
|
|
||||||
|
_arguments \
|
||||||
|
'1:ops:{_describe "ops" pack_ops}' \
|
||||||
|
'::verbose:(v)' \
|
||||||
|
':files:_files'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
pprof)
|
pprof)
|
||||||
|
|
@ -988,47 +1020,63 @@ case $state in
|
||||||
'*:files:_files'
|
'*:files:_files'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
trace)
|
(trace)
|
||||||
|
local -a trace_types=(
|
||||||
|
"net:network blocking profile"
|
||||||
|
"sync:synchronization blocking profile"
|
||||||
|
"syscall:syscall blocking profile"
|
||||||
|
"scheduler:latency profile"
|
||||||
|
)
|
||||||
|
|
||||||
_arguments \
|
_arguments \
|
||||||
|
'-pprof=[profile type]:type:{_describe "type" trace_types}' \
|
||||||
'-http=[HTTP service address]:addr' \
|
'-http=[HTTP service address]:addr' \
|
||||||
|
'-d=[print debug info such as parsed events]:level:((1\:"high-level" 2\:"low-level"))' \
|
||||||
'*:files:_files'
|
'*:files:_files'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
vet)
|
(vet)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-all[check everything]' \
|
'(- *)-V[print version and exit]'\
|
||||||
|
'-appends[enable appends analysis]' \
|
||||||
'-asmdecl[check assembly against Go declarations]' \
|
'-asmdecl[check assembly against Go declarations]' \
|
||||||
'-assign[check for useless assignments]' \
|
'-assign[check for useless assignments]' \
|
||||||
'-atomic[check for common mistaken usages of the sync/atomic]' \
|
'-atomic[check for common mistaken usages of the sync/atomic]' \
|
||||||
'-bool[check for mistakes involving boolean operators]' \
|
'-bools[enable bools analysis]' \
|
||||||
'-buildtags[check that +build tags are valid]' \
|
'-buildtag[check that +build tags are valid]' \
|
||||||
|
'-cgocall[enable cgocall analysis]' \
|
||||||
'-composites[check that composite literals used field-keyed elements]' \
|
'-composites[check that composite literals used field-keyed elements]' \
|
||||||
'-compositewhitelist[use composite white list]' \
|
'-compositewhitelist[use composite white list]' \
|
||||||
'-copylocks[check that locks are not passed by value]' \
|
'-copylocks[check that locks are not passed by value]' \
|
||||||
|
'-defers[enable defers analysis]' \
|
||||||
|
'-directive[enable directive analysis]' \
|
||||||
|
'-errorsas[enable errorsas analysis]' \
|
||||||
|
'-flags[print analysis flags in JSON]' \
|
||||||
|
'-framepointer[enable framepointer analysis]' \
|
||||||
|
'-httpresponse[enable httpresponse analysis]' \
|
||||||
|
'-ifaceassert[enable ifaceassert analysis]' \
|
||||||
|
'-json[emit JSON output]' \
|
||||||
|
'-loopclosure[enable loopclosure analysis]' \
|
||||||
|
'-lostcancel[enable lostcancel analysis]' \
|
||||||
'-methods[check that canonically named methods are canonically defined]' \
|
'-methods[check that canonically named methods are canonically defined]' \
|
||||||
'-nilfunc[check for comparisons between functions and nil]' \
|
'-nilfunc[check for comparisons between functions and nil]' \
|
||||||
'-printf[check printf-like invocations]' \
|
'-printf[check printf-like invocations]' \
|
||||||
'-printfuncs[print function names to check]:string' \
|
'-printfuncs[print function names to check]:string' \
|
||||||
'-rangeloops[check that range loop variables are used correctly]' \
|
'-rangeloops[check that range loop variables are used correctly]' \
|
||||||
'-shadow[check for shadowed variables]' \
|
'-shift[enable shift analysis]' \
|
||||||
'-shadowstrict[whether to be strict about shadowing]' \
|
'-sigchanyzer[enable sigchanyzer analysis]' \
|
||||||
'-shift[check for useless shifts]' \
|
'-slog[enable slog analysis]' \
|
||||||
|
'-stdmethods[enable stdmethods analysis]' \
|
||||||
|
'-stringintconv[enable stringintconv analysis]' \
|
||||||
'-structtags[check that struct field tags have canonical format]' \
|
'-structtags[check that struct field tags have canonical format]' \
|
||||||
'-tags[list of build tags to apply when parsing]:list' \
|
'-tests[enable tests analysis]' \
|
||||||
'-test[for testing only: sets -all and -shadow]' \
|
'-timeformat[enable time format analysis]' \
|
||||||
|
'-unmarshal[enable unmarshal analysis]' \
|
||||||
'-unreachable[check for unreachable code]' \
|
'-unreachable[check for unreachable code]' \
|
||||||
'-unsafeptr[check for misuse of unsafe.Pointer]' \
|
'-unsafeptr[check for misuse of unsafe.Pointer]' \
|
||||||
'-unusedfuncs[list of functions whose results must be used]:string' \
|
'-unusedfuncs[list of functions whose results must be used]:string' \
|
||||||
'-unusedresult[check for unused result of calls to functions in -unusedfuncs]' \
|
'-unusedresult[check for unused result of calls to functions in -unusedfuncs]' \
|
||||||
'-unusedstringmethods[list of methods whose results must be used]:string' \
|
'-unusedstringmethods[list of methods whose results must be used]:string' \
|
||||||
'-v[verbose]' \
|
|
||||||
'*:files:_files'
|
|
||||||
;;
|
|
||||||
|
|
||||||
yacc)
|
|
||||||
_arguments \
|
|
||||||
'-o[output]:output' \
|
|
||||||
'-v[parsetable]:parsetable' \
|
|
||||||
'*:files:_files'
|
'*:files:_files'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
@ -1036,27 +1084,29 @@ case $state in
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
version)
|
(version)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-m[print each executable embedded module version information]' \
|
'-m[print each executable embedded module version information]' \
|
||||||
'-v[report unrecognized files]' \
|
'-v[report unrecognized files]' \
|
||||||
'*:files:_files'
|
'*:files:_files'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
vet)
|
(vet)
|
||||||
_arguments \
|
_arguments \
|
||||||
'-n[print commands that would be executed]' \
|
'-n[print commands that would be executed]' \
|
||||||
'-x[prints commands as they are executed]' \
|
'-x[prints commands as they are executed]' \
|
||||||
|
'-vettool[set a different analysis tool with alternative or additional checks]:prog:_files' \
|
||||||
${build_flags[@]} \
|
${build_flags[@]} \
|
||||||
'*:importpaths:__go_packages'
|
'*:importpaths:__go_packages'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
work)
|
(work)
|
||||||
local -a work_commands=(
|
local -a work_commands=(
|
||||||
'edit:edit go.work from tools or scripts'
|
'edit:edit go.work from tools or scripts'
|
||||||
'init:initialize workspace file'
|
'init:initialize workspace file'
|
||||||
'sync:sync workspace build list to modules'
|
'sync:sync workspace build list to modules'
|
||||||
'use:add modules to workspace file'
|
'use:add modules to workspace file'
|
||||||
|
'vendor:make vendored copy of dependencies'
|
||||||
)
|
)
|
||||||
|
|
||||||
_arguments \
|
_arguments \
|
||||||
|
|
@ -1064,9 +1114,9 @@ case $state in
|
||||||
'*:: :->args'
|
'*:: :->args'
|
||||||
|
|
||||||
case $state in
|
case $state in
|
||||||
args)
|
(args)
|
||||||
case $words[1] in
|
case $words[1] in
|
||||||
edit)
|
(edit)
|
||||||
_arguments \
|
_arguments \
|
||||||
${edit_flags[@]} \
|
${edit_flags[@]} \
|
||||||
'*-use[add use directive from the go.work set of module directories]' \
|
'*-use[add use directive from the go.work set of module directories]' \
|
||||||
|
|
@ -1074,25 +1124,29 @@ case $state in
|
||||||
':go.work:_path_files -g "go.work"'
|
':go.work:_path_files -g "go.work"'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
init)
|
(init)
|
||||||
_arguments \
|
_arguments \
|
||||||
'*:directory: _path_files -/'
|
'*:directory: _path_files -/'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
sync)
|
(use)
|
||||||
;;
|
|
||||||
|
|
||||||
use)
|
|
||||||
_arguments \
|
_arguments \
|
||||||
'-r[searches recursively for modules in the argumentdirectories]' \
|
'-r[searches recursively for modules in the argumentdirectories]' \
|
||||||
'*:directory: _path_files -/'
|
'*:directory: _path_files -/'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
(vendor)
|
||||||
|
_arguments \
|
||||||
|
'-v[print the names of vendored modules and packages to standard error]' \
|
||||||
|
'-e[attempt to proceed despite errors encountered while loading packages]' \
|
||||||
|
'-o[create the vendor directory at the given path instead of vendor]:outdir:_path_files -/'
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
help)
|
(help)
|
||||||
local -a topics=(
|
local -a topics=(
|
||||||
'buildconstraint:build constraints'
|
'buildconstraint:build constraints'
|
||||||
'buildmode:build modes'
|
'buildmode:build modes'
|
||||||
|
|
@ -1102,11 +1156,9 @@ case $state in
|
||||||
'filetype:file types'
|
'filetype:file types'
|
||||||
'go.mod:the go.mod file'
|
'go.mod:the go.mod file'
|
||||||
'gopath:GOPATH environment variable'
|
'gopath:GOPATH environment variable'
|
||||||
'gopath-get:legacy GOPATH go get'
|
|
||||||
'goproxy:module proxy protocol'
|
'goproxy:module proxy protocol'
|
||||||
'importpath:import path syntax'
|
'importpath:import path syntax'
|
||||||
'modules:modules, module versions, and more'
|
'modules:modules, module versions, and more'
|
||||||
'module-get:module-aware go get'
|
|
||||||
'module-auth:module authentication using go.sum'
|
'module-auth:module authentication using go.sum'
|
||||||
'packages:package lists and patterns'
|
'packages:package lists and patterns'
|
||||||
'private:configuration for downloading non-public code'
|
'private:configuration for downloading non-public code'
|
||||||
|
|
@ -1115,7 +1167,14 @@ case $state in
|
||||||
'vcs:controlling version control with GOVCS'
|
'vcs:controlling version control with GOVCS'
|
||||||
)
|
)
|
||||||
|
|
||||||
_arguments "1: :{_describe 'command' commands -- topics}"
|
case "$words[2]" in
|
||||||
|
(mod)
|
||||||
|
_arguments "2: :{_describe 'command' mod_commands}"
|
||||||
|
;;
|
||||||
|
(*)
|
||||||
|
_arguments "1: :{_describe 'command' commands -- topics}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue