-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy path_go
5675 lines (5592 loc) · 252 KB
/
_go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#compdef go,-P go[0-9.]# -P -value-,GO*,-default- -P -value-,CGO*,-default-
# ------------------------------------------------------------------------------
# Copyright (c) 2017- The Go Authors
# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users
# Copyright (c) 2013-2015 Robby Russell and contributors (see
# https://github.com/robbyrussell/oh-my-zsh/contributors)
# Copyright (c) 2010-2014 Go authors
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the zsh-users nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for go (http://golang.org).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Mikkel Oscar Lyderik <[email protected]>
# * oh-my-zsh authors:
# https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/golang/golang.plugin.zsh
# * Go Authors
#
# ------------------------------------------------------------------------------
#
# go.googlesource.com/go
#
# ------------------------------------------------------------------------------
local context curcontext=$curcontext state line ret=1
declare -A opt_args
_go() {
local -a commands
commands=(
"build:compile packages and dependencies"
"clean:remove object files and cached files"
"doc:show documentation for package or symbol"
"env:print Go environment information"
"fix:update packages to use new APIs"
"fmt:gofmt (reformat) package sources"
"generate:generate Go files by processing source"
"get:add dependencies to current module and install them"
"install:compile and install packages and dependencies"
"list:list packages or modules"
"mod:module maintenance"
"work:workspace maintenance"
"run:compile and run Go program"
"telemetry:manage telemetry data and settings"
"test:test packages"
"tool:run specified go tool"
"version:print Go version"
"vet:report likely mistakes in packages"
"help:more information about a command"
)
_go_files() {
_alternative '*:go file:_path_files -g "*.go(-.)"'
}
_go_packages() {
local -a gopaths
gopaths=("${(s/:/)$(go env GOPATH)}")
gopaths+=("$(go env GOROOT)")
for p in $gopaths; do
_alternative ':go packages:_path_files -W "$p/src" -/'
done
_alternative "*: :_go_files"
}
_go_mod_vendor_packages() {
for p in $(go list -u -m -mod=readonly -f='{{ if and (.Indirect) (not .Indirect) (not .Main) }}{{ .Path }}{{ end }}' all | xargs -P $(nproc) -I {} go list -mod=vendor ./vendor/{}/...); do
_alternative ":module packages:($p)"
done
}
_go_file() {
_alternative ": :_go_packages" _files
}
_build_flags() {
_arguments \
"-C[Change to dir before running the command.]" \
"-a[force rebuilding of packages that are already up-to-date]" \
"-n[print the commands but do not run them]" \
"-p[number of builds that can be run in parallel]:number" \
"-race[enable data race detection]" \
"-msan[Insert calls to C/C++ memory sanitizer.]" \
"-asan[enable interoperation with address sanitizer.]" \
"-cover[enable code coverage instrumentation.]" \
"-covermode[Set the mode for coverage analysis.]:covermode:(set count atomic)" \
"-coverpkg[Apply coverage analysis in each test to the given list of packages]: :_go_packages" \
"-v[print the names of packages as they are compiled]" \
"-work[print temporary work directory and keep it]" \
"-x[print the commands]" \
"-asmflags=[arguments for each go tool asm invocation]: :->asmflags" \
"-buildinfo=[Whether to stamp binaries with build flags.]" \
"-buildmode=[build mode to use]: :->buildmode" \
"-buildvcs=[Whether to stamp binaries with version control information.]:whether the use buildvcs:(auto true false)" \
"-compiler[name of compiler to use]:name" \
"-gccgoflags[arguments for gccgo]:args" \
"-gcflags=[arguments to pass on each go tool compile invocation]: :->gcflags" \
"-installsuffix[suffix to add to package directory]:suffix" \
"-json[Emit build output in JSON suitable for automated processing.]" \
"-ldflags=[arguments to pass on each go tool link invocation]: :->ldflags" \
"-linkshared[link against shared libraries]" \
"-mod=[module download mode to use]:mode:(readonly vendor mod)" \
"-modcacherw[leave newly-created directories in the module cache read-write instead of making them read-only.]" \
"-modfile=[in module aware mode, read (and possibly write) an alternate go.mod file instead of the one in the module root directory.]:go.mod file:_files" \
"-workfile=[in module aware mode, use the given go.work file as a workspace file.]" \
"-overlay=[read a JSON config file that provides an overlay for build operations.]:overlay json file:_files" \
"-pgo[specify the file path of a profile for profile-guided optimization (PGO).]:pgo file:_files" \
"-pkgdir[install and load all packages from dir]:dir" \
"-tags=[list of build tags to consider satisfied]:tags" \
"-toolexec[program to use to invoke toolchain programs]:args"
# "-covermode[set the mode for coverage analysis.]: :->covermode" \
# covermode)
# local -a _covermode
# _covermode=(
# "set:bool: does this statement run?"
# "count:int: how many times does this statement run?"
# "atomic:int: count, but correct in multithreaded tests; significantly more expensive."
# )
# _values \
# "covermode" \
# ${_covermode[@]}
# ;;
case $state in
asmflags)
local -a _asm_flags
_asm_flags=(
"-D[predefined symbol with optional simple value -D=identifier=value; can be set multiple times]:value"
"-I[include directory; can be set multiple times]:value"
"-S[print assembly and machine code]"
"-V[print version and exit]"
"-d[enable debugging settings; try -d help]:value]"
"-debug[dump instructions as they are parsed]"
"-dynlink[support references to Go symbols defined in other shared libraries]"
"-e[no limit on number of errors reported]"
"-gensymabis[write symbol ABI information to output file, don't assemble]"
"-linkshared[generate code that will be linked against Go shared libraries]"
"-o[output file; default foo.o for /a/b/c/foo.s as first argument]:output:_files"
"-p[[set expected package import to path]:expected package import path'"
"-shared[generate code that can be linked into a shared library]"
"-spectre[enable spectre mitigations]:mode:(all ret)"
"-trimpath[remove prefix from recorded source file paths]:paths"
"-v[print debug output]"
)
_values \
"asmflags" \
${_asm_flags[@]}
;;
buildmode)
local -a _buildmode
_buildmode=(
"archive[Build the listed non-main packages into .a files]"
"c-archive[Build the listed main package, plus all packages it imports, into a C archive file]"
"c-shared[Build the listed main packages, plus all packages that they import, into C shared libraries]"
"default[Listed main packages are built into executables and listed non-main packages are built into .a files]"
"shared[Combine all the listed non-main packages into a single shared library that will be used when building with the -linkshared option]"
"exe[Build the listed main packages and everything they import into executables]"
"pie[Build the listed main packages and everything they import into position independent executables (PIE)]"
"plugin[Build the listed main packages, plus all packages that they import, into a Go plugin]"
)
_values \
"buildmode" \
${_buildmode[@]}
;;
gcflags)
# go tool compile
# https://golang.org/cmd/compile/#hdr-Command_Line
local -a _gcflags
_gcflags=(
"-D[Set relative path for local imports.]:relative import path"
"-G[accept generic code]"
"-I[Search for imported packages]:import directories:_directories"
"-L[Show complete file path in error messages.]"
"-N[Disable optimizations.]"
"-S[Print assembly listing to standard output (code only).]"
"-SS[Print assembly listing to standard output (code and data).]"
"-V[Print compiler version and exit.]"
"-abiwraplimit[emit at most N ABI wrappers (for debugging)]:abiwraplimit"
"-asmhdr[Write assembly header to file.]:output path:_files"
"-buildid[Record id as the build id in the export metadata.]:build id"
"-blockprofile[Write block profile for the compilation to file.]:output path:_files"
"-c[Concurrency during compilation. Set 1 for no concurrency (default is 1).]:num of concurrency"
"-clobberdead[clobber dead stack slots (for debugging)]"
"-clobberdeadreg[clobber dead registers (for debugging)]"
"-complete[Assume package has no non-Go components.]"
"-cpuprofile[Write a CPU profile for the compilation to file.]:output path:_files"
"-dynlink[Allow references to Go symbols in shared libraries (experimental).]"
"-e[Remove the limit on the number of errors reported (default limit is 10).]:limit to num of errors"
"-goversion[Specify required go tool version of the runtime.]:go version"
"-h[Halt with a stack trace at the first error detected.]"
"-importcfg[Read import configuration from file.]:import configuration file:_files"
"-installsuffix[set pkg directory suffix]:install suffix"
"-l[Disable inlining.]"
"-lang[Set language version to compile, as in -lang=go1.12. Default is current version.]:lang version"
"-largemodel[Generate code that assumes a large memory model.]"
"-linkobj[Write linker-specific object to file and compiler-specific object to usual output file (as specified by -o).]:output path:_files"
"-m[Print optimization decisions.]"
"-memprofile[Write memory profile for the compilation to file.]:output path:_files"
"-memprofilerate[Set runtime.MemProfileRate for the compilation to rate.]:memory profiling rate"
"-mutexprofile[Write mutex profile for the compilation to file.]:output path:_files"
"-nolocalimports[Disallow local (relative) imports.]"
"-o[Write object to file.]:output path:_files"
"-p[Set expected package import path for the code being compiled, and diagnose imports that would cause a circular dependency.]:expected import path"
"-pack[Write a package (archive) file rather than an object file]"
"-race[Compile with race detector enabled.]"
"-s[Warn about composite literals that can be simplified.]"
"-shared[Generate code that can be linked into a shared library.]"
"-t[enable tracing for debugging the compiler]"
"-traceprofile[Write an execution trace to file.]:output path:_files"
"-trimpath[Remove prefix from recorded source file paths.]:trim filepath prefixs"
"-dwarf[Generate DWARF symbols. (default true)]"
"-dwarflocationlists[Add location lists to DWARF in optimized mode. (default true)]"
"-gendwarfinl[Generate DWARF inline info records (default 2).]:num of DWARF inlines"
"-E[Debug symbol export.]"
"-K[Debug missing line numbers.]"
"-d[enable debugging settings; try -d help]:items list"
"-live[Debug liveness analysis.]"
"-v[Increase debug verbosity.]"
"-%[Debug non-static initializers.]"
"-W[Debug parse tree after type checking.]"
"-f[Debug stack frames.]"
"-i[Debug line number stack.]"
"-j[Debug runtime-initialized variables.]"
"-json=[version,file for JSON compiler/optimizer detail output]:output:_files"
"-r[Debug generated wrappers.]"
"-w[Debug type checking.]"
"-wb[enable write barrier (default true)]"
"-+[compiling runtime]"
"-B[disable bounds checking]"
"-C[disable printing of columns in error messages]"
"-allabis[generate ABI wrappers for all symbols (for bootstrap)]"
"-bench[append benchmark times to file]:output path:_files"
"-newescape[enable new escape analysis (default true)]"
"-std[compiling standard library]"
"-symabis[read symbol ABIs from file]:symbol ABIs file:_files"
"-w[debug type checking]"
)
_values \
"gcflags" \
${_gcflags[@]}
;;
ldflags)
local -a _ldflags
_ldflags=(
"-B[add an ELF NT_GNU_BUILD_ID note when using ELF]:note"
"-E[set entry symbol name]:entry"
"-H[set header type]:type"
"-I[use linker as ELF dynamic linker]:linker"
"-L[add specified directory to library path]:directory:_path_files -/"
"-R[set address rounding quantum (default -1)]:quantum"
"-T[set text segment address (default -1)]:address"
"-V[print version and exit]"
"-X[add string value definition of the form importpath.name=value]:definition"
"-asan[enable ASan interface]"
"-aslr[enable ASLR for buildmode=c-shared on windows (default true)]"
"-benchmark[set to 'mem' or 'cpu' to enable phase benchmarking]:mode:(mem cpu)"
"-benchmarkprofile[emit phase profiles to base_phase.]:base"
"-buildid[record id as Go toolchain build id]:id"
"-buildmode[set build mode]:mode:(archive c-archive c-shared default shared exe pie)"
"-c[dump call graph]"
"-compressdwarf[compress DWARF if possible (default true)]"
"-cpuprofile[write cpu profile to file]:file:_files"
"-d[disable dynamic executable]"
"-debugnosplit[dump nosplit call graph]"
"-debugtextsize=[debug text section max size]:size"
"-debugtramp[debug trampolines]:trampolines"
"-dumpdep[dump symbol dependency graph]"
"-extar[archive program for buildmode=c-archive]:string"
"-extld[use linker when linking in external mode]:linker"
"-extldflags[pass flags to external linker]:flags"
"-f[ignore version mismatch]"
"-g[disable go package data checks]"
"-h[halt on error]"
"-importcfg[read import configuration from file]:file:_files"
"-installsuffix[\[suffix\]: set package directory suffix]:suffix"
"-k[set field tracking symbol]:symbol"
"-libgcc[compiler support lib for internal linking; use \"none\" to disable]:string"
"-linkmode[set link mode]:mode(internal external auto)"
"-linkshared[link against installed Go shared libraries]"
"-memprofile[write memory profile to file]:file:_files"
"-memprofilerate[set runtime.MemProfileRate to rate]:rate"
"-msan[enable MSan interface]"
"-n[dump symbol table]"
"-o[write output to file]:file:_files"
"-pluginpath[full path name for plugin]:path:_files"
"-pruneweakmap[prune weak mapinit refs (default true)]"
"-r[set the ELF dynamic linker search path to dir1:dir2:...]:path:_path_files"
"-race[enable race detector]"
"-s[disable symbol table]"
"-strictdups[sanity check duplicate symbol contents during object file reading (1=warn 2=err).]"
"-tmpdir[use directory for temporary files]:directory:_path_files -/"
"-v[print link trace]"
"-w[disable DWARF generation]"
)
_values \
"ldflags" \
${_ldflags[@]}
;;
esac
}
_maintenance_flags() {
_arguments \
"-init[initializes and writes a new go.mod to the current directory]" \
"-module[changes (or, with -init, sets) the module's path]" \
"-require[add a requirement on the given module path and version.]:path@version:_go_packages" \
"-droprequire[drop a requirement on the given module path and version.]:path:_go_packages" \
"-exclude[add an exclusion for the given module path and version.]:path@version:_go_packages" \
"-dropexclude[drop an exclusion for the given module path and version.]:path@version:_go_packages" \
"-replace[add a replacement of the given module path and version pair.]:old@v=new@w:_go_packages" \
"-dropreplace[drop a replacement of the given module path and version pair.]:old@v:_go_packages" \
"-fmt[reformats the go.mod file without making other changes.]" \
"-graph[prints the module requirement graph (with replacements applied) in text form.]" \
"-json[prints the go.mod file in JSON format with Go types.]" \
"-packages[prints a list of packages in the module.]" \
"-fix[updates go.mod to use canonical version identifiers and to be semantically consistent.]" \
"-sync[synchronizes go.mod with the source code in the module.]" \
"-vendor[resets the module's vendor directory to include all packages needed to build and test all the module's packages.]" \
"-verify[checks that the dependencies of the current module, which are stored in a local downloaded source cache, have not been modified since being downloaded.]"
}
# TODO(zchee): Support for regexp keyword
_test_binary_flags() {
local -a _test_flags
_test_flags=(
"-bench[Run (sub)benchmarks matching a regular expression]:regexp of Benchmark functions:(.)"
"-benchtime[Run enough iterations of each benchmark to take t, specified as a time.Duration]"
"-count[Run each test and benchmark n times (default: 1)]:count"
"-cover[Enable coverage analysis]"
"-covermode[Set the mode for coverage analysis for the packages being tested (default: set)]:covermode:(set count atomic)"
"-coverpkg[Apply coverage analysis in each test to the given list of packages]: :_go_packages"
"-cpu[Specify a list of GOMAXPROCS values for which the tests or benchmarks should be executed]:cpus:(1 2 4 8 16)"
"-failfast[Do not start new tests after the first test failure.]"
"-fullpath[Show full file names in the error messages.]"
"-fuzz[Run the fuzz test matching the regular expression.]:regexp"
"-fuzzminimizetime[Run enough iterations of the fuzz target during each minimization attempt to take t, as specified as a time.Duration. The default is 60s.]:duration"
"-fuzztime[Run enough iterations of the fuzz target during fuzzing to take t, specified as a time.Duration]:duration"
"-json[Convert test output to JSON suitable for automated processing. See 'go doc test2json' for the encoding details]"
"-list[List tests, benchmarks, or examples matching the regular expression. No tests, benchmarks or examples will be run.]:regexp"
"-parallel[Allow parallel execution of test functions that call t.Parallel]:number of parallel"
"-run[Run only those tests and examples matching the regular expression]:regexp of Tests or Examples"
"-short[Tell long-running tests to shorten their run time]"
"-shuffle[Randomize the execution order of tests and benchmarks.]:shuffle value:(off on N)"
"-timeout[If a test runs longer than arg time, panic \(default: 10m\)]:timeout"
"-v[output log all tests as they are run and print all text from Log and Logf]"
"-vet[Configure the invocation of \"go vet\" during \"go test\" to use the comma-separated list of vet checks.]:list"
"-args[Pass the remainder of the command line to the test binary]"
"-c[Compile the test binary to pkg.test but do not run it]"
"-exec=[Run the test binary using 'xprog']:xprog"
"-i[Install packages that are dependencies of the test]"
"-o[Compile the test binary to the named file]:binary file name:_files"
"-benchmem[Print memory allocation statistics for benchmarks.]"
"-blockprofile[Write a goroutine blocking profile to the specified file]:profile file path:_files"
"-blockprofilerate[Control the detail provided in goroutine blocking profiles by calling runtime.SetBlockProfileRate]:block profile rate"
"-coverprofile[Write a coverage profile to the file after all tests have passed]:output filename:_files"
"-cpuprofile[Write a CPU profile to the specified file before exiting]:cpu profile file path:_files"
"-memprofile[Write a memory profile to the file after all tests have passed]:memory profile file:_files"
"-memprofilerate[Enable more precise memory profiles by setting runtime.MemProfileRate]:memory profile rate"
"-mutexprofile[Enable more precise (and expensive) memory profiles]:mutex profile file:_files"
"-mutexprofilefraction[Sample 1 in n stack traces of goroutines holding a contended mutex]:mutex fraction"
"-outputdir[Place output files from profiling in the specified directory]:output directory:_path_files -/"
"-trace[Write an execution trace to the specified file before exiting]:output trace file path:_files"
)
_values \
"test flags" \
${_test_flags[@]}
}
_arguments \
"1: :{_describe 'command' commands}" \
"*:: :->args"
case $state in
args)
case $words[1] in
bug)
;;
build)
_arguments \
"-o[force build to write to named output file]:file:_files" \
"-i[installs the packages that are dependencies of the target]" \
"::build flags:_build_flags" \
"*: :_go_packages" \
;;
clean)
_arguments \
"-i[clean to remove the corresponding installed archive or binary what 'go install' would create.]" \
"-n[print the remove commands it would execute, but not run them.]" \
"-r[clean to be applied recursively to all the dependencies of the packages named by the import paths.]" \
"-x[clean to print remove commands as it executes them.]" \
"-cache[clean to remove the entire go build cache.]" \
"-testcache[clean to expire all test results in the go build cache.]" \
"-modcache[clean to remove the entire module download cache, including unpacked source code of versioned dependencies.]" \
"-fuzzcache[clean to remove files stored in the Go build cache for fuzz testing.]" \
"*:go packages:_go_packages"
_alternative ":build flags:_build_flags"
;;
doc)
_arguments \
"-c[respect case when matching symbols]" \
"-cmd[treat a command (package main) like a regular package]" \
"-u[show docs for unexported and exported symbols and methods]" \
"*: :_go_packages"
;;
env)
local -a _envs
_envs=(
"GCCGO:The gccgo command to run for 'go build -compiler=gccgo'."
"GOAUTH:Controls authentication for go-import and HTTPS module mirror interactions."
"GOARCH:The architecture, or processor, for which to compile code."
"GOBIN:The directory where 'go install' will install a command."
"GOCACHE:The directory where the go command will store cached information for reuse in future builds."
"GODEBUG:Enable various debugging facilities. See 'go doc runtime' for details."
"GOENV: The location of the Go environment configuration file."
"GOFLAGS:A space-separated list of -flag=value settings to apply to go commands by default."
"GOINSECURE:Comma-separated list of glob patterns of module path prefixes that should always be fetched in an insecure manner."
"GOMODCACHE:The directory where the go command will store downloaded modules."
"GOOS:The operating system for which to compile code."
"GOPATH:For more details see: 'go help gopath'."
"GOPROXY:URL of Go module proxy. See 'go help modules'."
{GOPRIVATE,GONOPROXY,GONOSUMDB}:"Comma-separated list of glob patterns of module path prefixes that should always be fetched directly or that should not be compared against the checksum database."
"GOROOT:The root of the go tree."
"GOSUMDB:The name of checksum database to use and optionally its public key and URL."
"GOTMPDIR:The directory where the go command will write temporary source files, packages, and binaries."
"GOTOOLCHAIN:Controls which Go toolchain is used."
"GOVCS:Lists version control commands that may be used with matching servers."
"GOWORK:In module aware mode, use the given go.work file as a workspace file."
"AR:The command to use to manipulate library archives when building with the gccgo compiler."
"CC:The command to use to compile C code."
"CGO_ENABLED:Whether the cgo command is supported. Either 0 or 1."
"CGO_CFLAGS:Flags that cgo will pass to the compiler when compiling C code."
"CGO_CFLAGS_ALLOW:A regular expression specifying additional flags to allow to appear in #cgo CFLAGS source code directives."
"CGO_CFLAGS_DISALLOW:A regular expression specifying flags that must be disallowed from appearing in #cgo CFLAGS source code directives."
{CGO_CPPFLAGS,CGO_CPPFLAGS_ALLOW,CGO_CPPFLAGS_DISALLOW}:"Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW, but for the C preprocessor."
{CGO_CXXFLAGS,CGO_CXXFLAGS_ALLOW,CGO_CXXFLAGS_DISALLOW}:"Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW, but for the C++ compiler."
{CGO_FFLAGS,CGO_FFLAGS_ALLOW,CGO_FFLAGS_DISALLOW}:"Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW, but for the Fortran compiler."
{CGO_LDFLAGS,CGO_LDFLAGS_ALLOW,CGO_LDFLAGS_DISALLOW}:"Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW, but for the linker."
"CXX:The command to use to compile C++ code."
"FC:The command to use to compile Fortran code."
"PKG_CONFIG:Path to pkg-config tool."
"GO386:For GOARCH=386, the floating point instruction set."
"GOAMD64:For GOARCH=amd64, the microarchitecture level for which to compile."
"GOARM:For GOARCH=arm, the ARM architecture for which to compile."
"GOARM64:For GOARCH=arm64, the ARM64 architecture for which to compile."
"GOMIPS:For GOARCH=mips{,le}, whether to use floating point instructions."
"GOMIPS64:For GOARCH=mips64{,le}, whether to use floating point instructions."
"GOWASM:For GOARCH=wasm, comma-separated list of experimental WebAssembly features to use."
"GOCOVERDIR:Directory into which to write code coverage data files generated by running a \"go build -cover\" binary."
"GCCGOTOOLDIR:If set, where to find gccgo tools, such as cgo."
"GOEXPERIMENT:Comma-separated list of toolchain experiments to enable or disable."
"GOFIPS140:The FIPS-140 cryptography mode to use when building binaries."
"GO_EXTLINK_ENABLED:Whether the linker should use external linking mode when using -linkmode=auto with code that uses cgo."
"GIT_ALLOW_PROTOCOL:Defined by Git. A colon-separated list of schemes that are allowed to be used with git fetch/clone."
"GOEXE:The executable file name suffix (\".exe\" on Windows, "" on other systems)."
"GOGCCFLAGS:A space-separated list of arguments supplied to the CC command."
"GOHOSTARCH:The architecture (GOARCH) of the Go toolchain binaries."
"GOHOSTOS:The operating system (GOOS) of the Go toolchain binaries."
"GOMOD:The absolute path to the go.mod of the main module."
"GOTELEMETRY:The current Go telemetry mode."
"GOTELEMETRYDIR:The directory Go telemetry data is written is written to."
"GOTOOLDIR:The directory where the go tools are installed."
"GOVERSION:The version of the installed Go tree, as reported by runtime.Version."
)
_arguments \
"-json[prints the environment in JSON format instead of as a shell script.]" \
"-u[unsets the default setting for the named environment variables]" \
"-w[changes the default settings of the named environment variables to the given values]" \
"-changed[prints only those settings whose effective value differs from the default value that would be obtained in an empty environment with no prior uses of the -w flag.]" \
"*: :{_describe 'envs' _envs}"
;;
fix)
_arguments \
"-fix=[fix list]" \
"*: :_go_packages"
;;
fmt)
_arguments \
"-n[prints commands that would be executed]" \
"-x[prints commands as they are executed]" \
"*: :_go_packages"
;;
generate)
_arguments \
"-run=[specifies a regular expression to select directives]:regex" \
"-skip=[specifies a regular expression to suppress directives whose full original source text]:regex" \
"-x[print the commands]" \
"-n[print the commands but do not run them]" \
"-v[print the names of packages as they are compiled]" \
"*:args:{ _alternative ': :_go_packages' _files }"
;;
get)
local -a get_flags
get_flags=(
"-d[instructs get to stop after downloading the packages]"
"-f[force get -u not to verify that each package has been checked from vcs]"
"-fix[run the fix tool on the downloaded packages]"
"-insecure[permit fetching/resolving custom domains]"
"-u=[instructs get to update dependencies to use newer patch releases when available.]"
"-t[also download the packages required to build tests]"
"-tool[instructs go to add a matching tool line to go.mod for each listed package]"
"*: :_go_packages"
)
_arguments \
${get_flags[@]} \
"::build flags:_build_flags"
;;
install)
_arguments \
"*: :_go_packages"
_alternative ":build flags:_build_flags"
;;
list)
_arguments \
"-f[specifies an alternate format for the list]:format" \
"-json[causes package data to be printed in JSON format.]" \
"-reuse=[accepts the name of file containing the JSON output of a previous 'go list -m -json' invocation with the same set of modifier flags]:old json file:_files" \
"-compiled[list to set CompiledGoFiles to the Go source files presented to the compiler.]" \
"-deps[list to iterate over not just the named packages but also all their dependencies.]" \
"-e[changes the handling of erroneous packages, those that cannot be found or are malformed.]" \
"-export[list to set the Export field to the name of a file containing up-to-date export information for the given package.]" \
"-find[list to identify the named packages but not resolve their dependencies]" \
"-test[list to report not only the named packages but also their test binaries]" \
"-m[list to list modules instead of packages.]" \
"-u[adds information about available upgrades.]" \
"-versions[list to set the Module's Versions field to a list of all known versions of that module, ordered according to semantic versioning, earliest to latest.]" \
"*: :_go_file"
;;
mod)
local -a mod_cmds
mod_cmds=(
"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:more information about a command"
)
_arguments \
"1: :{_describe 'mod subcommands' mod_cmds}" \
"*:: :->args"
case $words[1] in
download)
_arguments \
"-json[download to print a sequence of JSON objects to standard output, describing each downloaded module]" \
"-reuse=[accepts the name of file containing the JSON output of a previous 'go list -m -json' invocation with the same set of modifier flags]:old json file:_files" \
"-x[download to print the commands download executes.]" \
"*: :_go_packages"
;;
edit)
_arguments \
"-fmt[reformats the go.mod file without making other changes.]:go.mod:_path_files -g go.mod(-.)" \
"-module[changes the module's path (the go.mod file's module line).]" \
"-require=[add a requirement on the given module path and version.]:path@version:_go_packages" \
"-droprequire=[drop a requirement on the given module path and version.]:path:_go_packages" \
"-exclude=[add a exclude of the given module path and version pair.]:old[@v]=new[@v]" \
"-dropexclude=[drop a exclude of the given module path and version pair.]:old[@v]=new[@v]" \
"-replace=[add a replacement of the given module path and version pair.]:old[@v]=new[@v]" \
"-dropreplace=[drop a replacement of the given module path and version pair.]:old[@v]" \
"-retract=[add a retraction on the given version. single version like \"v1.2.3\" or a closed interval like \"\[v1.1.0-v1.1.9\]\"]:version" \
"-dropretract=[drop a retraction on the given version. single version like \"v1.2.3\" or a closed interval like \"\[v1.1.0-v1.1.9\]\"]:version" \
"-godebug=[adds a godebug key=value line, replacing any existing godebug lines with the given key.]:godebug flag" \
"-dropgodebug=[drops any existing godebug lines with the given key.]:godebug flag" \
"-tool=[add a tool declaration for the given path.]:tools path:_files" \
"-droptool=[drop a tool declaration for the given path.]:tools path:_files" \
"-go[sets the expected Go language version.]:go version:(1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.20 1.21 1.22)" \
"-toolchain[sets the Go toolchain to use.]:go toolchain" \
"-print[prints the final go.mod in its text format instead of writing it back to go.mod.]" \
"-json[prints the final go.mod in its json format instead of writing it back to go.mod.]" \
"-C[Change to dir before running the command.]" \
"-n[print the commands but do not run them]" \
"-x[print the commands]"
;;
graph)
_arguments \
"-go=[sets the expected Go language version.]:go version:(1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.20)" \
"-x[graph to print the commands graph executes.]"
;;
init)
_arguments \
"*: :_go_packages"
;;
tidy)
_arguments \
"-v[print information about removed modules to standard error.]" \
"-e[attempt to proceed despite errors encountered while loading packages.]" \
"-go=[update the 'go' directive in the go.mod file to the given version.]:go version:(1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.20)" \
"-compat=[preserves any additional checksums needed for the 'go' command from the indicated major Go release to successfully]:go version:(1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.20)" \
"-x[tidy to print the commands download executes.]" \
"-diff[print the necessary changes as a unified diff]"
;;
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'.]:path:_files"
;;
verify)
;;
why)
_arguments \
"-m[why treats the arguments as a list of modules and finds a path to any package in each of the modules.]" \
"-vendor[why to exclude tests of dependencies.]" \
"*: :_go_mod_vendor_packages"
;;
help)
_arguments \
"1: :{_describe 'mod commands' mod_cmds}"
;;
esac
;;
work)
local -a work_cmds
work_cmds=(
"edit:edit go.work from tools or scripts"
"init:initialize workspace file"
"sync:sync workspace build list to modules"
"use:add modules to workspace file"
"vendor:make vendored copy of dependencies"
)
_arguments \
"1: :{_describe 'work subcommands' work_cmds}" \
"*:: :->args"
case $words[1] in
edit)
_arguments \
"-fmt[reformats the go.work file without making other changes.]:go.work:_path_files -g go.work(-.)" \
"-use=[add a use directive from the go.work file's set of module directories.]:path@version:_go_packages" \
"-dropuse=[drop a use directive from the go.work file's set of module directories.]:path:_go_packages" \
"-replace=[adds a replacement of the given module path and version pair.]:old[@v]=new[@v]" \
"-dropreplace=[drops a replacement of the given module path and version pair.]:old[@v]" \
"-godebug=[adds a godebug key=value line, replacing any existing godebug lines with the given key.]:godebug flag" \
"-dropgodebug=[drops any existing godebug lines with the given key.]:godebug flag" \
"-go=[sets the expected Go language version.]:go version:(1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.20 1.21 1.22 1.23)" \
"-toolchain=[sets the Go toolchain to use.]:go toolchain" \
"-print[prints the final go.mod in its text format instead of writing it back to go.mod.]" \
"-json[prints the final go.mod in its json format instead of writing it back to go.mod.]" \
"*:go.work:_files"
;;
init)
_arguments \
"*:moddirs:_files"
;;
sync)
_arguments \
"*:moddirs:_files"
;;
use)
_arguments \
"-r[searches recursively for modules in the argument directories.]" \
"*:moddirs:_files"
;;
vendor)
_arguments \
"-v[print the names of vendored modules and packages to standard error.]" \
"-v[attempt to proceed despite errors encountered while loading packages.]" \
"-o[create the vendor directory at the given path instead of \"vendor\".]"
;;
help)
_arguments \
"1: :{_describe 'work commands' work_cmds}"
;;
esac
;;
run)
_arguments \
"-exec[invoke the binary using xprog]:xporg" \
"1:go file:_files" \
"*:args:_files"
_alternative ":build flags:_build_flags"
;;
test)
_arguments \
"*: :_go_packages"
_alternative ":test flags:_test_binary_flags"
_alternative ":build flags:_build_flags"
;;
tool)
local -a tools
tools=(
"addr2line:minimal simulation of the GNU addr2line tool"
"api:computes the exported API of a set of Go packages"
"asm:assembles the source file into an object file"
"buildid:Buildid displays or updates the build ID stored in a Go package or binary. By default, buildid prints the build ID found in the named file"
"cgo:enables the creation of Go packages that call C code"
"compile:compiles a single Go package comprising the files named on the command line"
"cover:analyzing the coverage profiles generated by go test -coverprofile"
"dist:bootstrapping tool for the Go distribution"
"doc:Show the documentation for the package, symbol, and method"
"fix:finds Go programs that use old APIs and rewrites them to use newer ones"
"link:reads the Go archive or object for a package, and combines them into an executable binary"
"nm:lists the symbols defined or used by an object file, archive, or executable"
"objdump:disassembles executable files"
"oldlink:reads the Go archive or object for a package main, along with its dependencies, and combines them into an executable binary."
"pack:simple version of the traditional Unix ar tool"
"pprof:interprets and displays profiles of Go programs"
"test2json:converts go test output to a machine-readable JSON stream"
"trace:viewing trace files"
"vet:examines Go source code and reports suspicious constructs"
)
_arguments \
"-n[print command that would be executed]" \
"1: :{_describe "tool" tools}" \
"*:: :->args"
case $state in
args)
case $words[1] in
addr2line)
_arguments \
"*:binary:_object_files"
;;
api)
_arguments \
"-allow_new[allow API additions (default true)]" \
"-approval[require approvals in comma-separated list of files]:file:_files" \
"-c[optional comma-separated filename(s) to check API against]:string" \
"-contexts[optional comma-separated list of <goos>-<goarch>[-cgo] to override default contexts]:string" \
"-except[optional filename of packages that are allowed to change without triggering a failure in the tool]:string" \
"-next[comma-separated list of files for upcoming API features for the next release. These files can be lazily maintained.]:file:_files" \
"-v[verbose debugging]"
;;
asm)
_arguments \
${_asm_flags[@]}
;;
buildid)
_arguments \
"-w[rewrites the build ID found in the file to accurately record a content hash of the file]:_files"
;;
cgo)
_arguments \
"-V[print version and exit]" \
"-debug-define[print relevant #defines]" \
"-debug-gcc[print gcc invocations]" \
"-dynimport[if non-empty, print dynamic import data for that file]:string" \
"-dynlinker[record dynamic linker information in -dynimport mode]" \
"-dynout[write -dynimport output to this file]:string" \
"-dynpackage[set Go package for -dynimport output (default \"main\")]:string" \
"-exportheader[where to write export header if any exported functions]:string" \
"-gccgo[generate files for use with gccgo]" \
"-gccgo_define_cgoincomplete[define cgo.Incomplete for older gccgo/GoLLVM]" \
"-gccgopkgpath[-fgo-pkgpath option used with gccgo]:string" \
"-gccgoprefix[-fgo-prefix option used with gccgo]:string" \
"-godefs[for bootstrap: write Go definitions for C file to standard output]" \
"-import_runtime_cgo[import runtime/cgo in generated code (default true)]" \
"-import_syscall[import syscall in generated code (default true)]" \
"-importpath[import path of package being built (for comments in generated files)]:string" \
"-objdir[object directory]:string" \
"-srcdir[source directory]:string" \
"-trimpath[applies supplied rewrites or trims prefixes to recorded source file paths]:string" \
'*:go file:_files -g "*.go(-.)"'
;;
compile)
_arguments \
"-%[debug non-static initializers]" \
"-+[compiling runtime]" \
"-B[disable bounds checking]" \
"-C[disable printing of columns in error messages]" \
"-D[path set relative path for local imports]" \
"-E[debug symbol export]" \
"-I[directory add directory to import search path]" \
"-K[debug missing line numbers]" \
"-L[show full file names in error messages]" \
"-N[disable optimizations]" \
"-S[print assembly listing]" \
"-V[print version and exit]" \
"-W[debug parse tree after type checking]" \
"-asan[build code compatible with C/C++ address sanitizer]" \
"-asmhdr[write assembly header to file]:output file:_files" \
"-bench[append benchmark times to file]:output file:_files" \
"-blockprofile[write block profile to file]:output file:_files" \
"-buildid[record id as the build id in the export metadata]:buildid" \
"-c[concurrency during compilation, 1 means no concurrency (default 1)]:number of concurrency" \
"-clobberdead[clobber dead stack slots (for debugging)]" \
"-clobberdeadreg[clobber dead registers (for debugging)]" \
"-complete[compiling complete package (no C or assembly)]" \
"-coveragecfg[read coverage configuration from file]:coverage configuration:_files" \
"-cpuprofile[write cpu profile to file]:output file:_files" \
"-d[print debug information about items in list; try -d help]:debug information list" \
"-dwarf[generate DWARF symbols (default true)]" \
"-dwarfbasentries[use base address selection entries in DWARF]" \
"-dwarflocationlists[add location lists to DWARF in optimized mode (default true)]" \
"-dynlink[support references to Go symbols defined in other shared libraries]" \
"-e[no limit on number of errors reported]" \
"-embedcfg[read go:embed configuration from file]:file:_files" \
"-env[add definition of the form key=value to environment]:definition" \
"-errorurl[print explanatory URL with error message if applicable]" \
"-gendwarfinl[generate DWARF inline info records (default 2)]:DWARF inline info records" \
"-goversion[string required version of the runtime]:go runtime version" \
"-h[halt on error]" \
"-importcfg[file read import configuration from file]" \
"-installsuffix[set pkg directory suffix]:install suffix" \
"-j[debug runtime-initialized variables]" \
"-json[version,file for JSON compiler/optimizer detail output]:output:_files" \
"-l[disable inlining]" \
"-lang[release to compile for]" \
"-linkobj[write linker-specific object to file]:output file:_files" \
"-linkshared[generate code that will be linked against Go shared libraries]" \
"-live[debug liveness analysis]" \
"-m[print optimization decisions]" \
"-memprofile[write memory profile to file]:output file:_files" \
"-memprofilerate[set runtime.MemProfileRate to rate]:profile rate" \
"-msan[build code compatible with C/C++ memory sanitizer]" \
"-mutexprofile[write mutex profile to file]:output file:_files" \
"-nolocalimports[reject local (relative) imports]" \
"-o[write output to file]:output file:_files" \
"-p[set expected package import path]:package import path" \
"-pack[write to file.a instead of file.o]" \
"-pgoprofile[read profile from file]:file:_files" \
"-r[debug generated wrappers]" \
"-race[enable race detector]" \
"-shared[generate code that can be linked into a shared library]" \
"-smallframes[reduce the size limit for stack allocated objects]" \
"-spectre[enable spectre mitigations]:mode:(all index ret)" \
"-std[compiling standard library]" \
"-symabis[read symbol ABIs from file]:symbol ABIs file:_files" \
"-t[enable tracing for debugging the compiler]" \
"-traceprofile[write an execution trace to file]:output file:_files" \
"-trimpath[prefix remove prefix from recorded source file paths]" \
"-v[increase debug verbosity]" \
"-w[debug type checking]" \
"-wb[enable write barrier (default true)]" \
'*:file:_path_files -g "*.go"'
;;
covdata)
local -a covdata_cmds
covdata_cmds=(
"textfmt:convert coverage data to textual format"
"percent:output total percentage of statements covered"
"pkglist:output list of package import paths"
"func:output coverage profile information for each function"
"merge:merge data files together"
"subtract:subtract one set of data files from another set"
"intersect:generate intersection of two sets of data files"
"debugdump:dump data in human-readable format for debugging purposes"
)
_arguments \
"1: :{_describe 'covdata subcommands' covdata_cmds}" \
"*:: :->args"
case $words[1] in
(textfmt|percent|pkglist|func|merge|subtract|intersect|debugdump)
_arguments \
"-cpuprofile[write cpu profile to file]:output file:_files" \
"-h[Panic on fatal errors (for stack trace)]" \
"-hw[Panic on warnings (for stack trace)]" \
"-i[comma separated input dirs to examine]" \
"-memprofile[write memory profile to file]:output file:_files" \
"-memprofilerate[set runtime.MemProfileRate to rate]:profile rate" \
"-memprofilerate[set runtime.MemProfileRate to rate]:profile rate" \
"-o[write output to file]:output file:_files" \
"-pkg[Restrict output to package(s) matching specified package pattern.]:package pattern" \
"-v[Verbose trace output level]" \
"*:go.work:_files"
;;
esac
;;
cover)
if (( CURRENT == 2 )); then
_arguments \
"-func=[output coverage profile information for each function]:string" \
"-html=[generate HTML representation of coverage profile]:file:_files" \
"-mode=[coverage mode]:mode:(set count atomic)" \
"-outfilelist[file containing list of output files (one per line) if -pkgcfg is in use]" \
"-pkgcfg[enable full-package instrumentation mode using params from specified config file]"
fi
_arguments \
"-o[file for output]:file:_files" \
"-var=[name of coverage variable to generate]:coverage var name" \
'*:file:_path_files -g "*.go"'
;;
doc)
_arguments \
"-c[respect case when matching symbols]" \
"-cmd[treat a command (package main) like a regular package]" \
"-u[show docs for unexported and exported symbols and methods]" \
"-C[change to dir before running command]:dir:_directories"
;;
fix)
_arguments \
"-diff[display diffs instead of rewriting files]" \
"-force[force fixes to run even if the code looks updated]:string" \
"-r[restrict the rewrites]:string" \
"*:files:_files"
;;
link)
_arguments \
"-B[add an ELF NT_GNU_BUILD_ID note when using ELF; use \"gobuildid\" to generate it from the Go build ID]:note" \
"-C[check Go calls to C code]" \
"-D[set data segment address (default -1)]:address" \
"-E[set entry symbol name]:entry" \
"-H[set header type]:type" \
"-I[use linker as ELF dynamic linker]:linker" \
"-L[add specified directory to library path]:directory" \
"-R[set address rounding quantum (default -1)]:quantum" \
"-T[set the start address of text symbols (default -1)]:address" \
"-V[print version and exit]" \
"-W[disassemble input]" \
"-X[add string value definition]:definition" \
"-a[disassemble output]" \
"-buildid[record id as Go toolchain build id]:id" \
"-buildmode[set build mode]:mode" \
"-c[dump call graph]" \
"-capturehostobjs[capture host object files loaded during internal linking to specified dir]:dir:_directories" \
"-cpuprofile[write cpu profile to file]:file" \
"-d[disable dynamic executable]" \
"-extld[use linker when linking in external mode]:linker" \
"-extldflags[pass flags to external linker]:flags" \
"-f[ignore version mismatch]" \
"-g[disable go package data checks]" \
"-h[halt on error]" \
"-installsuffix[set package directory suffix]:suffix" \
"-k[set field tracking symbol]:symbol" \
"-linkmode[set link mode]:mode:(internal external auto)" \
"-linkshared[link against installed Go shared libraries]" \
"-memprofile[write memory profile to file]:file" \
"-memprofilerate[set runtime.MemProfileRate to rate]:rate" \
"-n[dump symbol table]" \
"-o[write output to file]:file" \