ABCDEFGHIJKL
1
FlagTypeUsageArgumentUsageLong DocBuild Time?Run Time?Include?SectionNew NameNeeds binary?Comments
2
Flags from go build (SOURCE: go help build)
3
-aboolforce rebuilding of packages that are already up-to-date.YESNOYESgo-build
4
-nboolprint the commands but do not run them.YESNOYESgo-buildTest
6
-raceboolenable data race detection. Supported only on linux/amd64, freebsd/amd64, darwin/amd64, windows/amd64, linux/ppc64le and linux/arm64 (only for 48-bit VMA).YESNOYEScode-and-coverage-analysis
7
-msanboolenable interoperation with memory sanitizer. Supported only on linux/amd64, linux/arm64 and only with Clang/LLVM as the host C compiler. On linux/arm64, pie build mode will be used.YESNOYESgo-build
9
-workboolprint the name of the temporary work directory and do not delete it when exiting.YESNOYESgo-build
10
-xboolprint the commands.YESNOYESgo-buildTest this to make sure it works
11
-asmflagsstring '[pattern=]arg list'arguments to pass on each go tool asm invocation.YESNOYESgo-build
12
-buildmodestringmodebuild mode to use. See 'go help buildmode' for more.YESNOYESgo-build
13
-compilerstringnamename of compiler to use, as in runtime.Compiler (gccgo or gc).YESNOYESgo-build
14
-gccgoflagsstring '[pattern=]arg list'arguments to pass on each gccgo compiler/linker invocation.YESNOYESgo-build
15
-gcflagsstring '[pattern=]arg list'arguments to pass on each go tool compile invocation.YESNOYESgo-build
16
-installsuffixstringa suffix to use in the name of the package installation directory, in order to keep output separate from default builds. If using the -race flag, the install suffix is automatically set to raceor, if set explicitly, has _race appended to it. Likewise for the -msan flag. Using a -buildmode option that requires non-default compile flags has a similar effect.YESNOYESgo-build
17
-ldflagsstring '[pattern=]arg list'arguments to pass on each go tool link invocation.YESNOYESgo-build
18
-linksharedboolbuild code that will be linked against shared libraries previously created with -buildmode=shared.YESNOYESgo-build
19
-mod modestringmode (readonly, vender, or mod)module download mode to use: readonly, vendor, or mod. See 'go help modules' for more.YESNOYESgo-build
20
-modcacherwboolleave newly-created directories in the module cache read-write instead of making them read-only.YESNOYESgo-build
21
-modfilestringfilein module aware mode, read (and possibly write) an alternate go.mod file instead of the one in the module root directory. A file named go.mod must still be present in order to determine the module root directory, but it is not accessed. When -modfile is specified, an alternate go.sum file is also used: its path is derived from the -modfile flag by trimming the ".mod" extension and appending ".sum".YESNOYESgo-build
22
-pkgdirstringdirinstall and load all packages from dir instead of the usual locations. For example, when building with a non-standard configuration, use -pkgdir to keep generated packages in a separate location.YESNOYESgo-build
23
-tagsstringtag,lista comma-separated list of build tags to consider satisfied during the build. For more information about build tags, see the description of build constraints in the documentation for the go/build package. (Earlier versions of Go used a space-separated list, and that form is deprecated but still recognized.)YESNOYESgo-build
24
-trimpathboolremove all file system paths from the resulting executable. Instead of absolute file system paths, the recorded file names will begin with either "go" (for the standard library), or a module path@version (when using modules), or a plain import path (when using GOPATH).YESNOYESgo-build
25
-toolexecstring 'cmd args'a program to use to invoke toolchain programs like vet and asm. For example, instead of running asm, the go command will run cmd args /path/to/asm <arguments for asm>'.YESNOYESgo-build
26
Flags from go test (SOURCE: go test -asdf, with docs from go help testflag merged in)
30
-test.blockprofilestringfilewrite a goroutine blocking profile to fileWrite a goroutine blocking profile to the specified file when all tests are complete. Writes test binary as -c would.NOYESYESperformance-analysisYESGo test does not support multiple packages.
31
-test.blockprofilerateintrateset blocking profile rate (see runtime.SetBlockProfileRate)Control the detail provided in goroutine blocking profiles by calling runtime.SetBlockProfileRate with rate. See 'go doc runtime.SetBlockProfileRate'. The profiler aims to sample, on average, one blocking event every n nanoseconds the program spends blocked. By default, if -test.blockprofile is set without this flag, all blocking events are recorded, equivalent to -test.blockprofilerate=1.NOYESYESperformance-analysis
33
-test.coverprofilestringfilewrite a coverage profile to fileWrite a coverage profile to the file after all tests have passed. Sets -cover.NOYESYEScode-and-coverage-analysis
35
-test.cpuprofilestringfilewrite a cpu profile to fileWrite a CPU profile to the specified file before exiting. Writes test binary as -c would.NOYESYESperformance-analysisYESGo test does not support multiple packages.
38
-test.memprofilestringfilewrite an allocation profile to fileWrite an allocation profile to the file after all tests have passed. Writes test binary as -c would.NOYESYESperformance-analysisYESGo test does not support multiple packages.
39
-test.memprofilerateintrateset memory allocation profiling rate (see runtime.MemProfileRate)Enable more precise (and expensive) memory allocation profiles by setting runtime.MemProfileRate. See 'go doc runtime.MemProfileRate'. To profile all memory allocations, use -test.memprofilerate=1.NOYESYESperformance-analysis
40
-test.mutexprofilestringfilewrite a mutex contention profile to the named file after executionWrite a mutex contention profile to the specified file when all tests are complete. Writes test binary as -c would.NOYESYESperformance-analysisYESGo test does not support multiple packages.
41
-test.mutexprofilefraction intnif >= 0, calls runtime.SetMutexProfileFraction()Sample 1 in n stack traces of goroutines holding a contended mutex.NOYESYESperformance-analysis
48
-test.tracestringfilewrite an execution trace to fileWrite an execution trace to the specified file before exiting.NOYESYESperformance-analysisexecution-traceGo test does not support multiple packages.
50
Additional go test flags from go help testflag (SOURCE: go help testflag)
51
-coverboolEnable coverage analysis.Note that because coverage works by annotating the source code before compilation, compilation and test failures with coverage enabled may report line numbers that don't correspond to the original sources.YESNOYEScode-and-coverage-analysis
52
-covermodestringset,count,atomicSet the mode for coverage analysis for the package[s] being tested. The default is "set" unless -race is enabled, in which case it is "atomic". The values:
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.
Sets -cover
YESNOYEScode-and-coverage-analysis
53
-coverpkgstringpattern1,pattern2,pattern3Apply coverage analysis in each test to packages matching the patterns. The default is for each test to analyze only the package being tested. See 'go help packages' for a description of package patterns. Sets -cover.YESNOYEScode-and-coverage-analysis
54
-vetstringlistConfigure the invocation of "go vet" during "go test" to use the comma-separated list of vet checks.If list is empty, "go test" runs "go vet" with a curated list of checks believed to be always worth addressing. If list is "off", "go test" does not run "go vet" at all.YESNOYEScode-and-coverage-analysis
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