|
@@ -28,6 +28,7 @@ __go_tool_complete() {
|
|
|
'help[display help]'
|
|
|
'install[compile and install packages and dependencies]'
|
|
|
'list[list packages]'
|
|
|
+ 'mod[modules maintenance]'
|
|
|
'run[compile and run Go program]'
|
|
|
'test[test packages]'
|
|
|
'tool[run specified go tool]'
|
|
@@ -83,7 +84,7 @@ __go_tool_complete() {
|
|
|
"-x[print remove commands as it executes them]" \
|
|
|
"*:importpaths:__go_packages"
|
|
|
;;
|
|
|
- fix|fmt|list|vet)
|
|
|
+ fix|fmt|vet)
|
|
|
_alternative ':importpaths:__go_packages' ':files:_path_files -g "*.go"'
|
|
|
;;
|
|
|
install)
|
|
@@ -124,6 +125,81 @@ __go_tool_complete() {
|
|
|
"-memprofilerate[set heap profiling rate]:number" \
|
|
|
"*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }"
|
|
|
;;
|
|
|
+ list)
|
|
|
+ _arguments -s -w : \
|
|
|
+ "-f[alternative format for the list]:format" \
|
|
|
+ "-json[print data in json format]" \
|
|
|
+ "-compiled[set CompiledGoFiles to the Go source files presented to the compiler]" \
|
|
|
+ "-deps[iterate over not just the named packages but also all their dependencies]" \
|
|
|
+ "-e[change the handling of erroneous packages]" \
|
|
|
+ "-export[set the Export field to the name of a file containing up-to-date export information for the given package]" \
|
|
|
+ "-find[identify the named packages but not resolve their dependencies]" \
|
|
|
+ "-test[report not only the named packages but also their test binaries]" \
|
|
|
+ "-m[list modules instead of packages]" \
|
|
|
+ "-u[adds information about available upgrades]" \
|
|
|
+ "-versions[set the Module's Versions field to a list of all known versions of that module]:number" \
|
|
|
+ "*:importpaths:__go_packages"
|
|
|
+ ;;
|
|
|
+ mod)
|
|
|
+ typeset -a mod_commands
|
|
|
+ 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]'
|
|
|
+ )
|
|
|
+ if (( CURRENT == 3 )); then
|
|
|
+ _values 'go mod commands' ${mod_commands[@]} "help[display help]"
|
|
|
+ return
|
|
|
+ fi
|
|
|
+ case ${words[3]} in
|
|
|
+ help)
|
|
|
+ _values 'go mod commands' ${mod_commands[@]}
|
|
|
+ ;;
|
|
|
+ download)
|
|
|
+ _arguments -s -w : \
|
|
|
+ "-json[print a sequence of JSON objects standard output]" \
|
|
|
+ "*:flags"
|
|
|
+ ;;
|
|
|
+ edit)
|
|
|
+ _arguments -s -w : \
|
|
|
+ "-fmt[reformat the go.mod file]" \
|
|
|
+ "-module[change the module's path]" \
|
|
|
+ "-replace[=old{@v}=new{@v} add a replacement of the given module path and version pair]:name" \
|
|
|
+ "-dropreplace[=old{@v}=new{@v} drop a replacement of the given module path and version pair]:name" \
|
|
|
+ "-go[={version} set the expected Go language version]:number" \
|
|
|
+ "-print[print the final go.mod in its text format]" \
|
|
|
+ "-json[print the final go.mod file in JSON format]" \
|
|
|
+ "*:flags"
|
|
|
+ ;;
|
|
|
+ graph)
|
|
|
+ ;;
|
|
|
+ init)
|
|
|
+ ;;
|
|
|
+ tidy)
|
|
|
+ _arguments -s -w : \
|
|
|
+ "-v[print information about removed modules]" \
|
|
|
+ "*:flags"
|
|
|
+ ;;
|
|
|
+ vendor)
|
|
|
+ _arguments -s -w : \
|
|
|
+ "-v[print the names of vendored]" \
|
|
|
+ "*:flags"
|
|
|
+ ;;
|
|
|
+ verify)
|
|
|
+ ;;
|
|
|
+ why)
|
|
|
+ _arguments -s -w : \
|
|
|
+ "-m[treats the arguments as a list of modules and finds a path to any package in each of the modules]" \
|
|
|
+ "-vendor[exclude tests of dependencies]" \
|
|
|
+ "*:importpaths:__go_packages"
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
+ ;;
|
|
|
help)
|
|
|
_values "${commands[@]}" \
|
|
|
'environment[show Go environment variables available]' \
|
|
@@ -189,6 +265,7 @@ alias gofa='go fmt ./...'
|
|
|
alias gog='go get'
|
|
|
alias goi='go install'
|
|
|
alias gol='go list'
|
|
|
+alias gom='go mod'
|
|
|
alias gop='cd $GOPATH'
|
|
|
alias gopb='cd $GOPATH/bin'
|
|
|
alias gops='cd $GOPATH/src'
|