| 1 |
// Copyright 2011 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
// Code generated by 'go test cmd/go -v -run=^TestDocsUpToDate$ -fixdocs'; DO NOT EDIT. |
| 6 |
// Edit the documentation in other files and then execute 'go generate cmd/go' to generate this one. |
| 7 |
|
| 8 |
// Go is a tool for managing Go source code. |
| 9 |
// |
| 10 |
// Usage: |
| 11 |
// |
| 12 |
// go <command> [arguments] |
| 13 |
// |
| 14 |
// The commands are: |
| 15 |
// |
| 16 |
// bug start a bug report |
| 17 |
// build compile packages and dependencies |
| 18 |
// clean remove object files and cached files |
| 19 |
// doc show documentation for package or symbol |
| 20 |
// env print Go environment information |
| 21 |
// fix update packages to use new APIs |
| 22 |
// fmt gofmt (reformat) package sources |
| 23 |
// generate generate Go files by processing source |
| 24 |
// get add dependencies to current module and install them |
| 25 |
// install compile and install packages and dependencies |
| 26 |
// list list packages or modules |
| 27 |
// mod module maintenance |
| 28 |
// work workspace maintenance |
| 29 |
// run compile and run Go program |
| 30 |
// telemetry manage telemetry data and settings |
| 31 |
// test test packages |
| 32 |
// tool run specified go tool |
| 33 |
// version print Go version |
| 34 |
// vet report likely mistakes in packages |
| 35 |
// |
| 36 |
// Use "go help <command>" for more information about a command. |
| 37 |
// |
| 38 |
// Additional help topics: |
| 39 |
// |
| 40 |
// buildconstraint build constraints |
| 41 |
// buildjson build -json encoding |
| 42 |
// buildmode build modes |
| 43 |
// c calling between Go and C |
| 44 |
// cache build and test caching |
| 45 |
// environment environment variables |
| 46 |
// filetype file types |
| 47 |
// goauth GOAUTH environment variable |
| 48 |
// go.mod the go.mod file |
| 49 |
// gopath GOPATH environment variable |
| 50 |
// goproxy module proxy protocol |
| 51 |
// importpath import path syntax |
| 52 |
// modules modules, module versions, and more |
| 53 |
// module-auth module authentication using go.sum |
| 54 |
// packages package lists and patterns |
| 55 |
// private configuration for downloading non-public code |
| 56 |
// testflag testing flags |
| 57 |
// testfunc testing functions |
| 58 |
// vcs controlling version control with GOVCS |
| 59 |
// |
| 60 |
// Use "go help <topic>" for more information about that topic. |
| 61 |
// |
| 62 |
// # Start a bug report |
| 63 |
// |
| 64 |
// Usage: |
| 65 |
// |
| 66 |
// go bug |
| 67 |
// |
| 68 |
// Bug opens the default browser and starts a new bug report. |
| 69 |
// The report includes useful system information. |
| 70 |
// |
| 71 |
// # Compile packages and dependencies |
| 72 |
// |
| 73 |
// Usage: |
| 74 |
// |
| 75 |
// go build [-o output] [build flags] [packages] |
| 76 |
// |
| 77 |
// Build compiles the packages named by the import paths, |
| 78 |
// along with their dependencies, but it does not install the results. |
| 79 |
// |
| 80 |
// If the arguments to build are a list of .go files from a single directory, |
| 81 |
// build treats them as a list of source files specifying a single package. |
| 82 |
// |
| 83 |
// When compiling packages, build ignores files that end in '_test.go'. |
| 84 |
// |
| 85 |
// When compiling a single main package, build writes the resulting |
| 86 |
// executable to an output file named after the last non-major-version |
| 87 |
// component of the package import path. The '.exe' suffix is added |
| 88 |
// when writing a Windows executable. |
| 89 |
// So 'go build example/sam' writes 'sam' or 'sam.exe'. |
| 90 |
// 'go build example.com/foo/v2' writes 'foo' or 'foo.exe', not 'v2.exe'. |
| 91 |
// |
| 92 |
// When compiling a package from a list of .go files, the executable |
| 93 |
// is named after the first source file. |
| 94 |
// 'go build ed.go rx.go' writes 'ed' or 'ed.exe'. |
| 95 |
// |
| 96 |
// When compiling multiple packages or a single non-main package, |
| 97 |
// build compiles the packages but discards the resulting object, |
| 98 |
// serving only as a check that the packages can be built. |
| 99 |
// |
| 100 |
// The -o flag forces build to write the resulting executable or object |
| 101 |
// to the named output file or directory, instead of the default behavior described |
| 102 |
// in the last two paragraphs. If the named output is an existing directory or |
| 103 |
// ends with a slash or backslash, then any resulting executables |
| 104 |
// will be written to that directory. |
| 105 |
// |
| 106 |
// The build flags are shared by the build, clean, get, install, list, run, |
| 107 |
// and test commands: |
| 108 |
// |
| 109 |
// -C dir |
| 110 |
// Change to dir before running the command. |
| 111 |
// Any files named on the command line are interpreted after |
| 112 |
// changing directories. |
| 113 |
// If used, this flag must be the first one in the command line. |
| 114 |
// -a |
| 115 |
// force rebuilding of packages that are already up-to-date. |
| 116 |
// -n |
| 117 |
// print the commands but do not run them. |
| 118 |
// -p n |
| 119 |
// the number of programs, such as build commands or |
| 120 |
// test binaries, that can be run in parallel. |
| 121 |
// The default is GOMAXPROCS, normally the number of CPUs available. |
| 122 |
// -race |
| 123 |
// enable data race detection. |
| 124 |
// Supported only on linux/amd64, freebsd/amd64, darwin/amd64, darwin/arm64, windows/amd64, |
| 125 |
// linux/ppc64le and linux/arm64 (only for 48-bit VMA). |
| 126 |
// -msan |
| 127 |
// enable interoperation with memory sanitizer. |
| 128 |
// Supported only on linux/amd64, linux/arm64, linux/loong64, freebsd/amd64 |
| 129 |
// and only with Clang/LLVM as the host C compiler. |
| 130 |
// PIE build mode will be used on all platforms except linux/amd64. |
| 131 |
// -asan |
| 132 |
// enable interoperation with address sanitizer. |
| 133 |
// Supported only on linux/arm64, linux/amd64, linux/loong64. |
| 134 |
// Supported on linux/amd64 or linux/arm64 and only with GCC 7 and higher |
| 135 |
// or Clang/LLVM 9 and higher. |
| 136 |
// And supported on linux/loong64 only with Clang/LLVM 16 and higher. |
| 137 |
// -cover |
| 138 |
// enable code coverage instrumentation. |
| 139 |
// -covermode set,count,atomic |
| 140 |
// set the mode for coverage analysis. |
| 141 |
// The default is "set" unless -race is enabled, |
| 142 |
// in which case it is "atomic". |
| 143 |
// The values: |
| 144 |
// set: bool: does this statement run? |
| 145 |
// count: int: how many times does this statement run? |
| 146 |
// atomic: int: count, but correct in multithreaded tests; |
| 147 |
// significantly more expensive. |
| 148 |
// Sets -cover. |
| 149 |
// -coverpkg pattern1,pattern2,pattern3 |
| 150 |
// For a build that targets package 'main' (e.g. building a Go |
| 151 |
// executable), apply coverage analysis to each package whose |
| 152 |
// import path matches the patterns. The default is to apply |
| 153 |
// coverage analysis to packages in the main Go module. See |
| 154 |
// 'go help packages' for a description of package patterns. |
| 155 |
// Sets -cover. |
| 156 |
// -v |
| 157 |
// print the names of packages as they are compiled. |
| 158 |
// -work |
| 159 |
// print the name of the temporary work directory and |
| 160 |
// do not delete it when exiting. |
| 161 |
// -x |
| 162 |
// print the commands. |
| 163 |
// -asmflags '[pattern=]arg list' |
| 164 |
// arguments to pass on each go tool asm invocation. |
| 165 |
// -buildmode mode |
| 166 |
// build mode to use. See 'go help buildmode' for more. |
| 167 |
// -buildvcs |
| 168 |
// Whether to stamp binaries with version control information |
| 169 |
// ("true", "false", or "auto"). By default ("auto"), version control |
| 170 |
// information is stamped into a binary if the main package, the main module |
| 171 |
// containing it, and the current directory are all in the same repository. |
| 172 |
// Use -buildvcs=false to always omit version control information, or |
| 173 |
// -buildvcs=true to error out if version control information is available but |
| 174 |
// cannot be included due to a missing tool or ambiguous directory structure. |
| 175 |
// -compiler name |
| 176 |
// name of compiler to use, as in runtime.Compiler (gccgo or gc). |
| 177 |
// -gccgoflags '[pattern=]arg list' |
| 178 |
// arguments to pass on each gccgo compiler/linker invocation. |
| 179 |
// -gcflags '[pattern=]arg list' |
| 180 |
// arguments to pass on each go tool compile invocation. |
| 181 |
// -installsuffix suffix |
| 182 |
// a suffix to use in the name of the package installation directory, |
| 183 |
// in order to keep output separate from default builds. |
| 184 |
// If using the -race flag, the install suffix is automatically set to race |
| 185 |
// or, if set explicitly, has _race appended to it. Likewise for the -msan |
| 186 |
// and -asan flags. Using a -buildmode option that requires non-default compile |
| 187 |
// flags has a similar effect. |
| 188 |
// -json |
| 189 |
// Emit build output in JSON suitable for automated processing. |
| 190 |
// See 'go help buildjson' for the encoding details. |
| 191 |
// -ldflags '[pattern=]arg list' |
| 192 |
// arguments to pass on each go tool link invocation. |
| 193 |
// -linkshared |
| 194 |
// build code that will be linked against shared libraries previously |
| 195 |
// created with -buildmode=shared. |
| 196 |
// -mod mode |
| 197 |
// module download mode to use: readonly, vendor, or mod. |
| 198 |
// By default, if a vendor directory is present and the go version in go.mod |
| 199 |
// is 1.14 or higher, the go command acts as if -mod=vendor were set. |
| 200 |
// Otherwise, the go command acts as if -mod=readonly were set. |
| 201 |
// See https://golang.org/ref/mod#build-commands for details. |
| 202 |
// -modcacherw |
| 203 |
// leave newly-created directories in the module cache read-write |
| 204 |
// instead of making them read-only. |
| 205 |
// -modfile file |
| 206 |
// in module aware mode, read (and possibly write) an alternate go.mod |
| 207 |
// file instead of the one in the module root directory. A file named |
| 208 |
// "go.mod" must still be present in order to determine the module root |
| 209 |
// directory, but it is not accessed. When -modfile is specified, an |
| 210 |
// alternate go.sum file is also used: its path is derived from the |
| 211 |
// -modfile flag by trimming the ".mod" extension and appending ".sum". |
| 212 |
// -overlay file |
| 213 |
// read a JSON config file that provides an overlay for build operations. |
| 214 |
// The file is a JSON object with a single field, named 'Replace', that |
| 215 |
// maps each disk file path (a string) to its backing file path, so that |
| 216 |
// a build will run as if the disk file path exists with the contents |
| 217 |
// given by the backing file paths, or as if the disk file path does not |
| 218 |
// exist if its backing file path is empty. Support for the -overlay flag |
| 219 |
// has some limitations: importantly, cgo files included from outside the |
| 220 |
// include path must be in the same directory as the Go package they are |
| 221 |
// included from, overlays will not appear when binaries and tests are |
| 222 |
// run through go run and go test respectively, and files beneath |
| 223 |
// GOMODCACHE may not be replaced. |
| 224 |
// -pgo file |
| 225 |
// specify the file path of a profile for profile-guided optimization (PGO). |
| 226 |
// When the special name "auto" is specified, for each main package in the |
| 227 |
// build, the go command selects a file named "default.pgo" in the package's |
| 228 |
// directory if that file exists, and applies it to the (transitive) |
| 229 |
// dependencies of the main package (other packages are not affected). |
| 230 |
// Special name "off" turns off PGO. The default is "auto". |
| 231 |
// -pkgdir dir |
| 232 |
// install and load all packages from dir instead of the usual locations. |
| 233 |
// For example, when building with a non-standard configuration, |
| 234 |
// use -pkgdir to keep generated packages in a separate location. |
| 235 |
// -tags tag,list |
| 236 |
// a comma-separated list of additional build tags to consider satisfied |
| 237 |
// during the build. For more information about build tags, see |
| 238 |
// 'go help buildconstraint'. (Earlier versions of Go used a |
| 239 |
// space-separated list, and that form is deprecated but still recognized.) |
| 240 |
// -trimpath |
| 241 |
// remove all file system paths from the resulting executable. |
| 242 |
// Instead of absolute file system paths, the recorded file names |
| 243 |
// will begin either a module path@version (when using modules), |
| 244 |
// or a plain import path (when using the standard library, or GOPATH). |
| 245 |
// -toolexec 'cmd args' |
| 246 |
// a program to use to invoke toolchain programs like vet and asm. |
| 247 |
// For example, instead of running asm, the go command will run |
| 248 |
// 'cmd args /path/to/asm <arguments for asm>'. |
| 249 |
// The TOOLEXEC_IMPORTPATH environment variable will be set, |
| 250 |
// matching 'go list -f {{.ImportPath}}' for the package being built. |
| 251 |
// |
| 252 |
// The -asmflags, -gccgoflags, -gcflags, and -ldflags flags accept a |
| 253 |
// space-separated list of arguments to pass to an underlying tool |
| 254 |
// during the build. To embed spaces in an element in the list, surround |
| 255 |
// it with either single or double quotes. The argument list may be |
| 256 |
// preceded by a package pattern and an equal sign, which restricts |
| 257 |
// the use of that argument list to the building of packages matching |
| 258 |
// that pattern (see 'go help packages' for a description of package |
| 259 |
// patterns). Without a pattern, the argument list applies only to the |
| 260 |
// packages named on the command line. The flags may be repeated |
| 261 |
// with different patterns in order to specify different arguments for |
| 262 |
// different sets of packages. If a package matches patterns given in |
| 263 |
// multiple flags, the latest match on the command line wins. |
| 264 |
// For example, 'go build -gcflags=-S fmt' prints the disassembly |
| 265 |
// only for package fmt, while 'go build -gcflags=all=-S fmt' |
| 266 |
// prints the disassembly for fmt and all its dependencies. |
| 267 |
// |
| 268 |
// For more about specifying packages, see 'go help packages'. |
| 269 |
// For more about where packages and binaries are installed, |
| 270 |
// run 'go help gopath'. |
| 271 |
// For more about calling between Go and C/C++, run 'go help c'. |
| 272 |
// |
| 273 |
// Note: Build adheres to certain conventions such as those described |
| 274 |
// by 'go help gopath'. Not all projects can follow these conventions, |
| 275 |
// however. Installations that have their own conventions or that use |
| 276 |
// a separate software build system may choose to use lower-level |
| 277 |
// invocations such as 'go tool compile' and 'go tool link' to avoid |
| 278 |
// some of the overheads and design decisions of the build tool. |
| 279 |
// |
| 280 |
// See also: go install, go get, go clean. |
| 281 |
// |
| 282 |
// # Remove object files and cached files |
| 283 |
// |
| 284 |
// Usage: |
| 285 |
// |
| 286 |
// go clean [-i] [-r] [-cache] [-testcache] [-modcache] [-fuzzcache] [build flags] [packages] |
| 287 |
// |
| 288 |
// Clean removes object files from package source directories. |
| 289 |
// The go command builds most objects in a temporary directory, |
| 290 |
// so go clean is mainly concerned with object files left by other |
| 291 |
// tools or by manual invocations of go build. |
| 292 |
// |
| 293 |
// If a package argument is given or the -i or -r flag is set, |
| 294 |
// clean removes the following files from each of the |
| 295 |
// source directories corresponding to the import paths: |
| 296 |
// |
| 297 |
// _obj/ old object directory, left from Makefiles |
| 298 |
// _test/ old test directory, left from Makefiles |
| 299 |
// _testmain.go old gotest file, left from Makefiles |
| 300 |
// test.out old test log, left from Makefiles |
| 301 |
// build.out old test log, left from Makefiles |
| 302 |
// *.[568ao] object files, left from Makefiles |
| 303 |
// |
| 304 |
// DIR(.exe) from go build |
| 305 |
// DIR.test(.exe) from go test -c |
| 306 |
// MAINFILE(.exe) from go build MAINFILE.go |
| 307 |
// *.so from SWIG |
| 308 |
// |
| 309 |
// In the list, DIR represents the final path element of the |
| 310 |
// directory, and MAINFILE is the base name of any Go source |
| 311 |
// file in the directory that is not included when building |
| 312 |
// the package. |
| 313 |
// |
| 314 |
// The -i flag causes clean to remove the corresponding installed |
| 315 |
// archive or binary (what 'go install' would create). |
| 316 |
// |
| 317 |
// The -n flag causes clean to print the remove commands it would execute, |
| 318 |
// but not run them. |
| 319 |
// |
| 320 |
// The -r flag causes clean to be applied recursively to all the |
| 321 |
// dependencies of the packages named by the import paths. |
| 322 |
// |
| 323 |
// The -x flag causes clean to print remove commands as it executes them. |
| 324 |
// |
| 325 |
// The -cache flag causes clean to remove the entire go build cache. |
| 326 |
// |
| 327 |
// The -testcache flag causes clean to expire all test results in the |
| 328 |
// go build cache. |
| 329 |
// |
| 330 |
// The -modcache flag causes clean to remove the entire module |
| 331 |
// download cache, including unpacked source code of versioned |
| 332 |
// dependencies. |
| 333 |
// |
| 334 |
// The -fuzzcache flag causes clean to remove files stored in the Go build |
| 335 |
// cache for fuzz testing. The fuzzing engine caches files that expand |
| 336 |
// code coverage, so removing them may make fuzzing less effective until |
| 337 |
// new inputs are found that provide the same coverage. These files are |
| 338 |
// distinct from those stored in testdata directory; clean does not remove |
| 339 |
// those files. |
| 340 |
// |
| 341 |
// For more about build flags, see 'go help build'. |
| 342 |
// |
| 343 |
// For more about specifying packages, see 'go help packages'. |
| 344 |
// |
| 345 |
// # Show documentation for package or symbol |
| 346 |
// |
| 347 |
// Usage: |
| 348 |
// |
| 349 |
// go doc [doc flags] [package|[package.]symbol[.methodOrField]] |
| 350 |
// |
| 351 |
// Doc prints the documentation comments associated with the item identified by its |
| 352 |
// arguments (a package, const, func, type, var, method, or struct field) |
| 353 |
// followed by a one-line summary of each of the first-level items "under" |
| 354 |
// that item (package-level declarations for a package, methods for a type, |
| 355 |
// etc.). |
| 356 |
// |
| 357 |
// Doc accepts zero, one, or two arguments. |
| 358 |
// |
| 359 |
// Given no arguments, that is, when run as |
| 360 |
// |
| 361 |
// go doc |
| 362 |
// |
| 363 |
// it prints the package documentation for the package in the current directory. |
| 364 |
// If the package is a command (package main), the exported symbols of the package |
| 365 |
// are elided from the presentation unless the -cmd flag is provided. |
| 366 |
// |
| 367 |
// When run with one argument, the argument is treated as a Go-syntax-like |
| 368 |
// representation of the item to be documented. What the argument selects depends |
| 369 |
// on what is installed in GOROOT and GOPATH, as well as the form of the argument, |
| 370 |
// which is schematically one of these: |
| 371 |
// |
| 372 |
// go doc <pkg> |
| 373 |
// go doc <sym>[.<methodOrField>] |
| 374 |
// go doc [<pkg>.]<sym>[.<methodOrField>] |
| 375 |
// go doc [<pkg>.][<sym>.]<methodOrField> |
| 376 |
// |
| 377 |
// The first item in this list matched by the argument is the one whose documentation |
| 378 |
// is printed. (See the examples below.) However, if the argument starts with a capital |
| 379 |
// letter it is assumed to identify a symbol or method in the current directory. |
| 380 |
// |
| 381 |
// For packages, the order of scanning is determined lexically in breadth-first order. |
| 382 |
// That is, the package presented is the one that matches the search and is nearest |
| 383 |
// the root and lexically first at its level of the hierarchy. The GOROOT tree is |
| 384 |
// always scanned in its entirety before GOPATH. |
| 385 |
// |
| 386 |
// If there is no package specified or matched, the package in the current |
| 387 |
// directory is selected, so "go doc Foo" shows the documentation for symbol Foo in |
| 388 |
// the current package. |
| 389 |
// |
| 390 |
// The package path must be either a qualified path or a proper suffix of a |
| 391 |
// path. The go tool's usual package mechanism does not apply: package path |
| 392 |
// elements like . and ... are not implemented by go doc. |
| 393 |
// |
| 394 |
// When run with two arguments, the first is a package path (full path or suffix), |
| 395 |
// and the second is a symbol, or symbol with method or struct field: |
| 396 |
// |
| 397 |
// go doc <pkg> <sym>[.<methodOrField>] |
| 398 |
// |
| 399 |
// In all forms, when matching symbols, lower-case letters in the argument match |
| 400 |
// either case but upper-case letters match exactly. This means that there may be |
| 401 |
// multiple matches of a lower-case argument in a package if different symbols have |
| 402 |
// different cases. If this occurs, documentation for all matches is printed. |
| 403 |
// |
| 404 |
// Examples: |
| 405 |
// |
| 406 |
// go doc |
| 407 |
// Show documentation for current package. |
| 408 |
// go doc -http |
| 409 |
// Serve HTML documentation over HTTP for the current package. |
| 410 |
// go doc Foo |
| 411 |
// Show documentation for Foo in the current package. |
| 412 |
// (Foo starts with a capital letter so it cannot match |
| 413 |
// a package path.) |
| 414 |
// go doc encoding/json |
| 415 |
// Show documentation for the encoding/json package. |
| 416 |
// go doc json |
| 417 |
// Shorthand for encoding/json. |
| 418 |
// go doc json.Number (or go doc json.number) |
| 419 |
// Show documentation and method summary for json.Number. |
| 420 |
// go doc json.Number.Int64 (or go doc json.number.int64) |
| 421 |
// Show documentation for json.Number's Int64 method. |
| 422 |
// go doc cmd/doc |
| 423 |
// Show package docs for the doc command. |
| 424 |
// go doc -cmd cmd/doc |
| 425 |
// Show package docs and exported symbols within the doc command. |
| 426 |
// go doc template.new |
| 427 |
// Show documentation for html/template's New function. |
| 428 |
// (html/template is lexically before text/template) |
| 429 |
// go doc text/template.new # One argument |
| 430 |
// Show documentation for text/template's New function. |
| 431 |
// go doc text/template new # Two arguments |
| 432 |
// Show documentation for text/template's New function. |
| 433 |
// |
| 434 |
// At least in the current tree, these invocations all print the |
| 435 |
// documentation for json.Decoder's Decode method: |
| 436 |
// |
| 437 |
// go doc json.Decoder.Decode |
| 438 |
// go doc json.decoder.decode |
| 439 |
// go doc json.decode |
| 440 |
// cd go/src/encoding/json; go doc decode |
| 441 |
// |
| 442 |
// Flags: |
| 443 |
// |
| 444 |
// -all |
| 445 |
// Show all the documentation for the package. |
| 446 |
// -c |
| 447 |
// Respect case when matching symbols. |
| 448 |
// -cmd |
| 449 |
// Treat a command (package main) like a regular package. |
| 450 |
// Otherwise package main's exported symbols are hidden |
| 451 |
// when showing the package's top-level documentation. |
| 452 |
// -http |
| 453 |
// Serve HTML docs over HTTP. |
| 454 |
// -short |
| 455 |
// One-line representation for each symbol. |
| 456 |
// -src |
| 457 |
// Show the full source code for the symbol. This will |
| 458 |
// display the full Go source of its declaration and |
| 459 |
// definition, such as a function definition (including |
| 460 |
// the body), type declaration or enclosing const |
| 461 |
// block. The output may therefore include unexported |
| 462 |
// details. |
| 463 |
// -u |
| 464 |
// Show documentation for unexported as well as exported |
| 465 |
// symbols, methods, and fields. |
| 466 |
// |
| 467 |
// # Print Go environment information |
| 468 |
// |
| 469 |
// Usage: |
| 470 |
// |
| 471 |
// go env [-json] [-changed] [-u] [-w] [var ...] |
| 472 |
// |
| 473 |
// Env prints Go environment information. |
| 474 |
// |
| 475 |
// By default env prints information as a shell script |
| 476 |
// (on Windows, a batch file). If one or more variable |
| 477 |
// names is given as arguments, env prints the value of |
| 478 |
// each named variable on its own line. |
| 479 |
// |
| 480 |
// The -json flag prints the environment in JSON format |
| 481 |
// instead of as a shell script. |
| 482 |
// |
| 483 |
// The -u flag requires one or more arguments and unsets |
| 484 |
// the default setting for the named environment variables, |
| 485 |
// if one has been set with 'go env -w'. |
| 486 |
// |
| 487 |
// The -w flag requires one or more arguments of the |
| 488 |
// form NAME=VALUE and changes the default settings |
| 489 |
// of the named environment variables to the given values. |
| 490 |
// |
| 491 |
// The -changed flag prints only those settings whose effective |
| 492 |
// value differs from the default value that would be obtained in |
| 493 |
// an empty environment with no prior uses of the -w flag. |
| 494 |
// |
| 495 |
// For more about environment variables, see 'go help environment'. |
| 496 |
// |
| 497 |
// # Update packages to use new APIs |
| 498 |
// |
| 499 |
// Usage: |
| 500 |
// |
| 501 |
// go fix [-fix list] [packages] |
| 502 |
// |
| 503 |
// Fix runs the Go fix command on the packages named by the import paths. |
| 504 |
// |
| 505 |
// The -fix flag sets a comma-separated list of fixes to run. |
| 506 |
// The default is all known fixes. |
| 507 |
// (Its value is passed to 'go tool fix -r'.) |
| 508 |
// |
| 509 |
// For more about fix, see 'go doc cmd/fix'. |
| 510 |
// For more about specifying packages, see 'go help packages'. |
| 511 |
// |
| 512 |
// To run fix with other options, run 'go tool fix'. |
| 513 |
// |
| 514 |
// See also: go fmt, go vet. |
| 515 |
// |
| 516 |
// # Gofmt (reformat) package sources |
| 517 |
// |
| 518 |
// Usage: |
| 519 |
// |
| 520 |
// go fmt [-n] [-x] [packages] |
| 521 |
// |
| 522 |
// Fmt runs the command 'gofmt -l -w' on the packages named |
| 523 |
// by the import paths. It prints the names of the files that are modified. |
| 524 |
// |
| 525 |
// For more about gofmt, see 'go doc cmd/gofmt'. |
| 526 |
// For more about specifying packages, see 'go help packages'. |
| 527 |
// |
| 528 |
// The -n flag prints commands that would be executed. |
| 529 |
// The -x flag prints commands as they are executed. |
| 530 |
// |
| 531 |
// The -mod flag's value sets which module download mode |
| 532 |
// to use: readonly or vendor. See 'go help modules' for more. |
| 533 |
// |
| 534 |
// To run gofmt with specific options, run gofmt itself. |
| 535 |
// |
| 536 |
// See also: go fix, go vet. |
| 537 |
// |
| 538 |
// # Generate Go files by processing source |
| 539 |
// |
| 540 |
// Usage: |
| 541 |
// |
| 542 |
// go generate [-run regexp] [-n] [-v] [-x] [build flags] [file.go... | packages] |
| 543 |
// |
| 544 |
// Generate runs commands described by directives within existing |
| 545 |
// files. Those commands can run any process but the intent is to |
| 546 |
// create or update Go source files. |
| 547 |
// |
| 548 |
// Go generate is never run automatically by go build, go test, |
| 549 |
// and so on. It must be run explicitly. |
| 550 |
// |
| 551 |
// Go generate scans the file for directives, which are lines of |
| 552 |
// the form, |
| 553 |
// |
| 554 |
// //go:generate command argument... |
| 555 |
// |
| 556 |
// (note: no leading spaces and no space in "//go") where command |
| 557 |
// is the generator to be run, corresponding to an executable file |
| 558 |
// that can be run locally. It must either be in the shell path |
| 559 |
// (gofmt), a fully qualified path (/usr/you/bin/mytool), or a |
| 560 |
// command alias, described below. |
| 561 |
// |
| 562 |
// Note that go generate does not parse the file, so lines that look |
| 563 |
// like directives in comments or multiline strings will be treated |
| 564 |
// as directives. |
| 565 |
// |
| 566 |
// The arguments to the directive are space-separated tokens or |
| 567 |
// double-quoted strings passed to the generator as individual |
| 568 |
// arguments when it is run. |
| 569 |
// |
| 570 |
// Quoted strings use Go syntax and are evaluated before execution; a |
| 571 |
// quoted string appears as a single argument to the generator. |
| 572 |
// |
| 573 |
// To convey to humans and machine tools that code is generated, |
| 574 |
// generated source should have a line that matches the following |
| 575 |
// regular expression (in Go syntax): |
| 576 |
// |
| 577 |
// ^// Code generated .* DO NOT EDIT\.$ |
| 578 |
// |
| 579 |
// This line must appear before the first non-comment, non-blank |
| 580 |
// text in the file. |
| 581 |
// |
| 582 |
// Go generate sets several variables when it runs the generator: |
| 583 |
// |
| 584 |
// $GOARCH |
| 585 |
// The execution architecture (arm, amd64, etc.) |
| 586 |
// $GOOS |
| 587 |
// The execution operating system (linux, windows, etc.) |
| 588 |
// $GOFILE |
| 589 |
// The base name of the file. |
| 590 |
// $GOLINE |
| 591 |
// The line number of the directive in the source file. |
| 592 |
// $GOPACKAGE |
| 593 |
// The name of the package of the file containing the directive. |
| 594 |
// $GOROOT |
| 595 |
// The GOROOT directory for the 'go' command that invoked the |
| 596 |
// generator, containing the Go toolchain and standard library. |
| 597 |
// $DOLLAR |
| 598 |
// A dollar sign. |
| 599 |
// $PATH |
| 600 |
// The $PATH of the parent process, with $GOROOT/bin |
| 601 |
// placed at the beginning. This causes generators |
| 602 |
// that execute 'go' commands to use the same 'go' |
| 603 |
// as the parent 'go generate' command. |
| 604 |
// |
| 605 |
// Other than variable substitution and quoted-string evaluation, no |
| 606 |
// special processing such as "globbing" is performed on the command |
| 607 |
// line. |
| 608 |
// |
| 609 |
// As a last step before running the command, any invocations of any |
| 610 |
// environment variables with alphanumeric names, such as $GOFILE or |
| 611 |
// $HOME, are expanded throughout the command line. The syntax for |
| 612 |
// variable expansion is $NAME on all operating systems. Due to the |
| 613 |
// order of evaluation, variables are expanded even inside quoted |
| 614 |
// strings. If the variable NAME is not set, $NAME expands to the |
| 615 |
// empty string. |
| 616 |
// |
| 617 |
// A directive of the form, |
| 618 |
// |
| 619 |
// //go:generate -command xxx args... |
| 620 |
// |
| 621 |
// specifies, for the remainder of this source file only, that the |
| 622 |
// string xxx represents the command identified by the arguments. This |
| 623 |
// can be used to create aliases or to handle multiword generators. |
| 624 |
// For example, |
| 625 |
// |
| 626 |
// //go:generate -command foo go tool foo |
| 627 |
// |
| 628 |
// specifies that the command "foo" represents the generator |
| 629 |
// "go tool foo". |
| 630 |
// |
| 631 |
// Generate processes packages in the order given on the command line, |
| 632 |
// one at a time. If the command line lists .go files from a single directory, |
| 633 |
// they are treated as a single package. Within a package, generate processes the |
| 634 |
// source files in a package in file name order, one at a time. Within |
| 635 |
// a source file, generate runs generators in the order they appear |
| 636 |
// in the file, one at a time. The go generate tool also sets the build |
| 637 |
// tag "generate" so that files may be examined by go generate but ignored |
| 638 |
// during build. |
| 639 |
// |
| 640 |
// For packages with invalid code, generate processes only source files with a |
| 641 |
// valid package clause. |
| 642 |
// |
| 643 |
// If any generator returns an error exit status, "go generate" skips |
| 644 |
// all further processing for that package. |
| 645 |
// |
| 646 |
// The generator is run in the package's source directory. |
| 647 |
// |
| 648 |
// Go generate accepts two specific flags: |
| 649 |
// |
| 650 |
// -run="" |
| 651 |
// if non-empty, specifies a regular expression to select |
| 652 |
// directives whose full original source text (excluding |
| 653 |
// any trailing spaces and final newline) matches the |
| 654 |
// expression. |
| 655 |
// |
| 656 |
// -skip="" |
| 657 |
// if non-empty, specifies a regular expression to suppress |
| 658 |
// directives whose full original source text (excluding |
| 659 |
// any trailing spaces and final newline) matches the |
| 660 |
// expression. If a directive matches both the -run and |
| 661 |
// the -skip arguments, it is skipped. |
| 662 |
// |
| 663 |
// It also accepts the standard build flags including -v, -n, and -x. |
| 664 |
// The -v flag prints the names of packages and files as they are |
| 665 |
// processed. |
| 666 |
// The -n flag prints commands that would be executed. |
| 667 |
// The -x flag prints commands as they are executed. |
| 668 |
// |
| 669 |
// For more about build flags, see 'go help build'. |
| 670 |
// |
| 671 |
// For more about specifying packages, see 'go help packages'. |
| 672 |
// |
| 673 |
// # Add dependencies to current module and install them |
| 674 |
// |
| 675 |
// Usage: |
| 676 |
// |
| 677 |
// go get [-t] [-u] [-tool] [build flags] [packages] |
| 678 |
// |
| 679 |
// Get resolves its command-line arguments to packages at specific module versions, |
| 680 |
// updates go.mod to require those versions, and downloads source code into the |
| 681 |
// module cache. |
| 682 |
// |
| 683 |
// To add a dependency for a package or upgrade it to its latest version: |
| 684 |
// |
| 685 |
// go get example.com/pkg |
| 686 |
// |
| 687 |
// To upgrade or downgrade a package to a specific version: |
| 688 |
// |
| 689 |
// go get example.com/[email protected] |
| 690 |
// |
| 691 |
// To remove a dependency on a module and downgrade modules that require it: |
| 692 |
// |
| 693 |
// go get example.com/mod@none |
| 694 |
// |
| 695 |
// To upgrade the minimum required Go version to the latest released Go version: |
| 696 |
// |
| 697 |
// go get go@latest |
| 698 |
// |
| 699 |
// To upgrade the Go toolchain to the latest patch release of the current Go toolchain: |
| 700 |
// |
| 701 |
// go get toolchain@patch |
| 702 |
// |
| 703 |
// See https://golang.org/ref/mod#go-get for details. |
| 704 |
// |
| 705 |
// In earlier versions of Go, 'go get' was used to build and install packages. |
| 706 |
// Now, 'go get' is dedicated to adjusting dependencies in go.mod. 'go install' |
| 707 |
// may be used to build and install commands instead. When a version is specified, |
| 708 |
// 'go install' runs in module-aware mode and ignores the go.mod file in the |
| 709 |
// current directory. For example: |
| 710 |
// |
| 711 |
// go install example.com/[email protected] |
| 712 |
// go install example.com/pkg@latest |
| 713 |
// |
| 714 |
// See 'go help install' or https://golang.org/ref/mod#go-install for details. |
| 715 |
// |
| 716 |
// 'go get' accepts the following flags. |
| 717 |
// |
| 718 |
// The -t flag instructs get to consider modules needed to build tests of |
| 719 |
// packages specified on the command line. |
| 720 |
// |
| 721 |
// The -u flag instructs get to update modules providing dependencies |
| 722 |
// of packages named on the command line to use newer minor or patch |
| 723 |
// releases when available. |
| 724 |
// |
| 725 |
// The -u=patch flag (not -u patch) also instructs get to update dependencies, |
| 726 |
// but changes the default to select patch releases. |
| 727 |
// |
| 728 |
// When the -t and -u flags are used together, get will update |
| 729 |
// test dependencies as well. |
| 730 |
// |
| 731 |
// The -tool flag instructs go to add a matching tool line to go.mod for each |
| 732 |
// listed package. If -tool is used with @none, the line will be removed. |
| 733 |
// |
| 734 |
// The -x flag prints commands as they are executed. This is useful for |
| 735 |
// debugging version control commands when a module is downloaded directly |
| 736 |
// from a repository. |
| 737 |
// |
| 738 |
// For more about build flags, see 'go help build'. |
| 739 |
// |
| 740 |
// For more about modules, see https://golang.org/ref/mod. |
| 741 |
// |
| 742 |
// For more about using 'go get' to update the minimum Go version and |
| 743 |
// suggested Go toolchain, see https://go.dev/doc/toolchain. |
| 744 |
// |
| 745 |
// For more about specifying packages, see 'go help packages'. |
| 746 |
// |
| 747 |
// See also: go build, go install, go clean, go mod. |
| 748 |
// |
| 749 |
// # Compile and install packages and dependencies |
| 750 |
// |
| 751 |
// Usage: |
| 752 |
// |
| 753 |
// go install [build flags] [packages] |
| 754 |
// |
| 755 |
// Install compiles and installs the packages named by the import paths. |
| 756 |
// |
| 757 |
// Executables are installed in the directory named by the GOBIN environment |
| 758 |
// variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH |
| 759 |
// environment variable is not set. Executables in $GOROOT |
| 760 |
// are installed in $GOROOT/bin or $GOTOOLDIR instead of $GOBIN. |
| 761 |
// |
| 762 |
// If the arguments have version suffixes (like @latest or @v1.0.0), "go install" |
| 763 |
// builds packages in module-aware mode, ignoring the go.mod file in the current |
| 764 |
// directory or any parent directory, if there is one. This is useful for |
| 765 |
// installing executables without affecting the dependencies of the main module. |
| 766 |
// To eliminate ambiguity about which module versions are used in the build, the |
| 767 |
// arguments must satisfy the following constraints: |
| 768 |
// |
| 769 |
// - Arguments must be package paths or package patterns (with "..." wildcards). |
| 770 |
// They must not be standard packages (like fmt), meta-patterns (std, cmd, |
| 771 |
// all), or relative or absolute file paths. |
| 772 |
// |
| 773 |
// - All arguments must have the same version suffix. Different queries are not |
| 774 |
// allowed, even if they refer to the same version. |
| 775 |
// |
| 776 |
// - All arguments must refer to packages in the same module at the same version. |
| 777 |
// |
| 778 |
// - Package path arguments must refer to main packages. Pattern arguments |
| 779 |
// will only match main packages. |
| 780 |
// |
| 781 |
// - No module is considered the "main" module. If the module containing |
| 782 |
// packages named on the command line has a go.mod file, it must not contain |
| 783 |
// directives (replace and exclude) that would cause it to be interpreted |
| 784 |
// differently than if it were the main module. The module must not require |
| 785 |
// a higher version of itself. |
| 786 |
// |
| 787 |
// - Vendor directories are not used in any module. (Vendor directories are not |
| 788 |
// included in the module zip files downloaded by 'go install'.) |
| 789 |
// |
| 790 |
// If the arguments don't have version suffixes, "go install" may run in |
| 791 |
// module-aware mode or GOPATH mode, depending on the GO111MODULE environment |
| 792 |
// variable and the presence of a go.mod file. See 'go help modules' for details. |
| 793 |
// If module-aware mode is enabled, "go install" runs in the context of the main |
| 794 |
// module. |
| 795 |
// |
| 796 |
// When module-aware mode is disabled, non-main packages are installed in the |
| 797 |
// directory $GOPATH/pkg/$GOOS_$GOARCH. When module-aware mode is enabled, |
| 798 |
// non-main packages are built and cached but not installed. |
| 799 |
// |
| 800 |
// Before Go 1.20, the standard library was installed to |
| 801 |
// $GOROOT/pkg/$GOOS_$GOARCH. |
| 802 |
// Starting in Go 1.20, the standard library is built and cached but not installed. |
| 803 |
// Setting GODEBUG=installgoroot=all restores the use of |
| 804 |
// $GOROOT/pkg/$GOOS_$GOARCH. |
| 805 |
// |
| 806 |
// For more about build flags, see 'go help build'. |
| 807 |
// |
| 808 |
// For more about specifying packages, see 'go help packages'. |
| 809 |
// |
| 810 |
// See also: go build, go get, go clean. |
| 811 |
// |
| 812 |
// # List packages or modules |
| 813 |
// |
| 814 |
// Usage: |
| 815 |
// |
| 816 |
// go list [-f format] [-json] [-m] [list flags] [build flags] [packages] |
| 817 |
// |
| 818 |
// List lists the named packages, one per line. |
| 819 |
// The most commonly-used flags are -f and -json, which control the form |
| 820 |
// of the output printed for each package. Other list flags, documented below, |
| 821 |
// control more specific details. |
| 822 |
// |
| 823 |
// The default output shows the package import path: |
| 824 |
// |
| 825 |
// bytes |
| 826 |
// encoding/json |
| 827 |
// github.com/gorilla/mux |
| 828 |
// golang.org/x/net/html |
| 829 |
// |
| 830 |
// The -f flag specifies an alternate format for the list, using the |
| 831 |
// syntax of package template. The default output is equivalent |
| 832 |
// to -f '{{.ImportPath}}'. The struct being passed to the template is: |
| 833 |
// |
| 834 |
// type Package struct { |
| 835 |
// Dir string // directory containing package sources |
| 836 |
// ImportPath string // import path of package in dir |
| 837 |
// ImportComment string // path in import comment on package statement |
| 838 |
// Name string // package name |
| 839 |
// Doc string // package documentation string |
| 840 |
// Target string // install path |
| 841 |
// Shlib string // the shared library that contains this package (only set when -linkshared) |
| 842 |
// Goroot bool // is this package in the Go root? |
| 843 |
// Standard bool // is this package part of the standard Go library? |
| 844 |
// Stale bool // would 'go install' do anything for this package? |
| 845 |
// StaleReason string // explanation for Stale==true |
| 846 |
// Root string // Go root or Go path dir containing this package |
| 847 |
// ConflictDir string // this directory shadows Dir in $GOPATH |
| 848 |
// BinaryOnly bool // binary-only package (no longer supported) |
| 849 |
// ForTest string // package is only for use in named test |
| 850 |
// Export string // file containing export data (when using -export) |
| 851 |
// BuildID string // build ID of the compiled package (when using -export) |
| 852 |
// Module *Module // info about package's containing module, if any (can be nil) |
| 853 |
// Match []string // command-line patterns matching this package |
| 854 |
// DepOnly bool // package is only a dependency, not explicitly listed |
| 855 |
// DefaultGODEBUG string // default GODEBUG setting, for main packages |
| 856 |
// |
| 857 |
// // Source files |
| 858 |
// GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles) |
| 859 |
// CgoFiles []string // .go source files that import "C" |
| 860 |
// CompiledGoFiles []string // .go files presented to compiler (when using -compiled) |
| 861 |
// IgnoredGoFiles []string // .go source files ignored due to build constraints |
| 862 |
// IgnoredOtherFiles []string // non-.go source files ignored due to build constraints |
| 863 |
// CFiles []string // .c source files |
| 864 |
// CXXFiles []string // .cc, .cxx and .cpp source files |
| 865 |
// MFiles []string // .m source files |
| 866 |
// HFiles []string // .h, .hh, .hpp and .hxx source files |
| 867 |
// FFiles []string // .f, .F, .for and .f90 Fortran source files |
| 868 |
// SFiles []string // .s source files |
| 869 |
// SwigFiles []string // .swig files |
| 870 |
// SwigCXXFiles []string // .swigcxx files |
| 871 |
// SysoFiles []string // .syso object files to add to archive |
| 872 |
// TestGoFiles []string // _test.go files in package |
| 873 |
// XTestGoFiles []string // _test.go files outside package |
| 874 |
// |
| 875 |
// // Embedded files |
| 876 |
// EmbedPatterns []string // //go:embed patterns |
| 877 |
// EmbedFiles []string // files matched by EmbedPatterns |
| 878 |
// TestEmbedPatterns []string // //go:embed patterns in TestGoFiles |
| 879 |
// TestEmbedFiles []string // files matched by TestEmbedPatterns |
| 880 |
// XTestEmbedPatterns []string // //go:embed patterns in XTestGoFiles |
| 881 |
// XTestEmbedFiles []string // files matched by XTestEmbedPatterns |
| 882 |
// |
| 883 |
// // Cgo directives |
| 884 |
// CgoCFLAGS []string // cgo: flags for C compiler |
| 885 |
// CgoCPPFLAGS []string // cgo: flags for C preprocessor |
| 886 |
// CgoCXXFLAGS []string // cgo: flags for C++ compiler |
| 887 |
// CgoFFLAGS []string // cgo: flags for Fortran compiler |
| 888 |
// CgoLDFLAGS []string // cgo: flags for linker |
| 889 |
// CgoPkgConfig []string // cgo: pkg-config names |
| 890 |
// |
| 891 |
// // Dependency information |
| 892 |
// Imports []string // import paths used by this package |
| 893 |
// ImportMap map[string]string // map from source import to ImportPath (identity entries omitted) |
| 894 |
// Deps []string // all (recursively) imported dependencies |
| 895 |
// TestImports []string // imports from TestGoFiles |
| 896 |
// XTestImports []string // imports from XTestGoFiles |
| 897 |
// |
| 898 |
// // Error information |
| 899 |
// Incomplete bool // this package or a dependency has an error |
| 900 |
// Error *PackageError // error loading package |
| 901 |
// DepsErrors []*PackageError // errors loading dependencies |
| 902 |
// } |
| 903 |
// |
| 904 |
// Packages stored in vendor directories report an ImportPath that includes the |
| 905 |
// path to the vendor directory (for example, "d/vendor/p" instead of "p"), |
| 906 |
// so that the ImportPath uniquely identifies a given copy of a package. |
| 907 |
// The Imports, Deps, TestImports, and XTestImports lists also contain these |
| 908 |
// expanded import paths. See golang.org/s/go15vendor for more about vendoring. |
| 909 |
// |
| 910 |
// The error information, if any, is |
| 911 |
// |
| 912 |
// type PackageError struct { |
| 913 |
// ImportStack []string // shortest path from package named on command line to this one |
| 914 |
// Pos string // position of error (if present, file:line:col) |
| 915 |
// Err string // the error itself |
| 916 |
// } |
| 917 |
// |
| 918 |
// The module information is a Module struct, defined in the discussion |
| 919 |
// of list -m below. |
| 920 |
// |
| 921 |
// The template function "join" calls strings.Join. |
| 922 |
// |
| 923 |
// The template function "context" returns the build context, defined as: |
| 924 |
// |
| 925 |
// type Context struct { |
| 926 |
// GOARCH string // target architecture |
| 927 |
// GOOS string // target operating system |
| 928 |
// GOROOT string // Go root |
| 929 |
// GOPATH string // Go path |
| 930 |
// CgoEnabled bool // whether cgo can be used |
| 931 |
// UseAllFiles bool // use files regardless of //go:build lines, file names |
| 932 |
// Compiler string // compiler to assume when computing target paths |
| 933 |
// BuildTags []string // build constraints to match in //go:build lines |
| 934 |
// ToolTags []string // toolchain-specific build constraints |
| 935 |
// ReleaseTags []string // releases the current release is compatible with |
| 936 |
// InstallSuffix string // suffix to use in the name of the install dir |
| 937 |
// } |
| 938 |
// |
| 939 |
// For more information about the meaning of these fields see the documentation |
| 940 |
// for the go/build package's Context type. |
| 941 |
// |
| 942 |
// The -json flag causes the package data to be printed in JSON format |
| 943 |
// instead of using the template format. The JSON flag can optionally be |
| 944 |
// provided with a set of comma-separated required field names to be output. |
| 945 |
// If so, those required fields will always appear in JSON output, but |
| 946 |
// others may be omitted to save work in computing the JSON struct. |
| 947 |
// |
| 948 |
// The -compiled flag causes list to set CompiledGoFiles to the Go source |
| 949 |
// files presented to the compiler. Typically this means that it repeats |
| 950 |
// the files listed in GoFiles and then also adds the Go code generated |
| 951 |
// by processing CgoFiles and SwigFiles. The Imports list contains the |
| 952 |
// union of all imports from both GoFiles and CompiledGoFiles. |
| 953 |
// |
| 954 |
// The -deps flag causes list to iterate over not just the named packages |
| 955 |
// but also all their dependencies. It visits them in a depth-first post-order |
| 956 |
// traversal, so that a package is listed only after all its dependencies. |
| 957 |
// Packages not explicitly listed on the command line will have the DepOnly |
| 958 |
// field set to true. |
| 959 |
// |
| 960 |
// The -e flag changes the handling of erroneous packages, those that |
| 961 |
// cannot be found or are malformed. By default, the list command |
| 962 |
// prints an error to standard error for each erroneous package and |
| 963 |
// omits the packages from consideration during the usual printing. |
| 964 |
// With the -e flag, the list command never prints errors to standard |
| 965 |
// error and instead processes the erroneous packages with the usual |
| 966 |
// printing. Erroneous packages will have a non-empty ImportPath and |
| 967 |
// a non-nil Error field; other information may or may not be missing |
| 968 |
// (zeroed). |
| 969 |
// |
| 970 |
// The -export flag causes list to set the Export field to the name of a |
| 971 |
// file containing up-to-date export information for the given package, |
| 972 |
// and the BuildID field to the build ID of the compiled package. |
| 973 |
// |
| 974 |
// The -find flag causes list to identify the named packages but not |
| 975 |
// resolve their dependencies: the Imports and Deps lists will be empty. |
| 976 |
// With the -find flag, the -deps, -test and -export commands cannot be |
| 977 |
// used. |
| 978 |
// |
| 979 |
// The -test flag causes list to report not only the named packages |
| 980 |
// but also their test binaries (for packages with tests), to convey to |
| 981 |
// source code analysis tools exactly how test binaries are constructed. |
| 982 |
// The reported import path for a test binary is the import path of |
| 983 |
// the package followed by a ".test" suffix, as in "math/rand.test". |
| 984 |
// When building a test, it is sometimes necessary to rebuild certain |
| 985 |
// dependencies specially for that test (most commonly the tested |
| 986 |
// package itself). The reported import path of a package recompiled |
| 987 |
// for a particular test binary is followed by a space and the name of |
| 988 |
// the test binary in brackets, as in "math/rand [math/rand.test]" |
| 989 |
// or "regexp [sort.test]". The ForTest field is also set to the name |
| 990 |
// of the package being tested ("math/rand" or "sort" in the previous |
| 991 |
// examples). |
| 992 |
// |
| 993 |
// The Dir, Target, Shlib, Root, ConflictDir, and Export file paths |
| 994 |
// are all absolute paths. |
| 995 |
// |
| 996 |
// By default, the lists GoFiles, CgoFiles, and so on hold names of files in Dir |
| 997 |
// (that is, paths relative to Dir, not absolute paths). |
| 998 |
// The generated files added when using the -compiled and -test flags |
| 999 |
// are absolute paths referring to cached copies of generated Go source files. |
| 1000 |
// Although they are Go source files, the paths may not end in ".go". |
| 1001 |
// |
| 1002 |
// The -m flag causes list to list modules instead of packages. |
| 1003 |
// |
| 1004 |
// When listing modules, the -f flag still specifies a format template |
| 1005 |
// applied to a Go struct, but now a Module struct: |
| 1006 |
// |
| 1007 |
// type Module struct { |
| 1008 |
// Path string // module path |
| 1009 |
// Query string // version query corresponding to this version |
| 1010 |
// Version string // module version |
| 1011 |
// Versions []string // available module versions |
| 1012 |
// Replace *Module // replaced by this module |
| 1013 |
// Time *time.Time // time version was created |
| 1014 |
// Update *Module // available update (with -u) |
| 1015 |
// Main bool // is this the main module? |
| 1016 |
// Indirect bool // module is only indirectly needed by main module |
| 1017 |
// Dir string // directory holding local copy of files, if any |
| 1018 |
// GoMod string // path to go.mod file describing module, if any |
| 1019 |
// GoVersion string // go version used in module |
| 1020 |
// Retracted []string // retraction information, if any (with -retracted or -u) |
| 1021 |
// Deprecated string // deprecation message, if any (with -u) |
| 1022 |
// Error *ModuleError // error loading module |
| 1023 |
// Sum string // checksum for path, version (as in go.sum) |
| 1024 |
// GoModSum string // checksum for go.mod (as in go.sum) |
| 1025 |
// Origin any // provenance of module |
| 1026 |
// Reuse bool // reuse of old module info is safe |
| 1027 |
// } |
| 1028 |
// |
| 1029 |
// type ModuleError struct { |
| 1030 |
// Err string // the error itself |
| 1031 |
// } |
| 1032 |
// |
| 1033 |
// The file GoMod refers to may be outside the module directory if the |
| 1034 |
// module is in the module cache or if the -modfile flag is used. |
| 1035 |
// |
| 1036 |
// The default output is to print the module path and then |
| 1037 |
// information about the version and replacement if any. |
| 1038 |
// For example, 'go list -m all' might print: |
| 1039 |
// |
| 1040 |
// my/main/module |
| 1041 |
// golang.org/x/text v0.3.0 => /tmp/text |
| 1042 |
// rsc.io/pdf v0.1.1 |
| 1043 |
// |
| 1044 |
// The Module struct has a String method that formats this |
| 1045 |
// line of output, so that the default format is equivalent |
| 1046 |
// to -f '{{.String}}'. |
| 1047 |
// |
| 1048 |
// Note that when a module has been replaced, its Replace field |
| 1049 |
// describes the replacement module, and its Dir field is set to |
| 1050 |
// the replacement's source code, if present. (That is, if Replace |
| 1051 |
// is non-nil, then Dir is set to Replace.Dir, with no access to |
| 1052 |
// the replaced source code.) |
| 1053 |
// |
| 1054 |
// The -u flag adds information about available upgrades. |
| 1055 |
// When the latest version of a given module is newer than |
| 1056 |
// the current one, list -u sets the Module's Update field |
| 1057 |
// to information about the newer module. list -u will also set |
| 1058 |
// the module's Retracted field if the current version is retracted. |
| 1059 |
// The Module's String method indicates an available upgrade by |
| 1060 |
// formatting the newer version in brackets after the current version. |
| 1061 |
// If a version is retracted, the string "(retracted)" will follow it. |
| 1062 |
// For example, 'go list -m -u all' might print: |
| 1063 |
// |
| 1064 |
// my/main/module |
| 1065 |
// golang.org/x/text v0.3.0 [v0.4.0] => /tmp/text |
| 1066 |
// rsc.io/pdf v0.1.1 (retracted) [v0.1.2] |
| 1067 |
// |
| 1068 |
// (For tools, 'go list -m -u -json all' may be more convenient to parse.) |
| 1069 |
// |
| 1070 |
// The -versions flag causes list to set the Module's Versions field |
| 1071 |
// to a list of all known versions of that module, ordered according |
| 1072 |
// to semantic versioning, earliest to latest. The flag also changes |
| 1073 |
// the default output format to display the module path followed by the |
| 1074 |
// space-separated version list. |
| 1075 |
// |
| 1076 |
// The -retracted flag causes list to report information about retracted |
| 1077 |
// module versions. When -retracted is used with -f or -json, the Retracted |
| 1078 |
// field explains why the version was retracted. |
| 1079 |
// The strings are taken from comments on the retract directive in the |
| 1080 |
// module's go.mod file. When -retracted is used with -versions, retracted |
| 1081 |
// versions are listed together with unretracted versions. The -retracted |
| 1082 |
// flag may be used with or without -m. |
| 1083 |
// |
| 1084 |
// The arguments to list -m are interpreted as a list of modules, not packages. |
| 1085 |
// The main module is the module containing the current directory. |
| 1086 |
// The active modules are the main module and its dependencies. |
| 1087 |
// With no arguments, list -m shows the main module. |
| 1088 |
// With arguments, list -m shows the modules specified by the arguments. |
| 1089 |
// Any of the active modules can be specified by its module path. |
| 1090 |
// The special pattern "all" specifies all the active modules, first the main |
| 1091 |
// module and then dependencies sorted by module path. |
| 1092 |
// A pattern containing "..." specifies the active modules whose |
| 1093 |
// module paths match the pattern. |
| 1094 |
// A query of the form path@version specifies the result of that query, |
| 1095 |
// which is not limited to active modules. |
| 1096 |
// See 'go help modules' for more about module queries. |
| 1097 |
// |
| 1098 |
// The template function "module" takes a single string argument |
| 1099 |
// that must be a module path or query and returns the specified |
| 1100 |
// module as a Module struct. If an error occurs, the result will |
| 1101 |
// be a Module struct with a non-nil Error field. |
| 1102 |
// |
| 1103 |
// When using -m, the -reuse=old.json flag accepts the name of file containing |
| 1104 |
// the JSON output of a previous 'go list -m -json' invocation with the |
| 1105 |
// same set of modifier flags (such as -u, -retracted, and -versions). |
| 1106 |
// The go command may use this file to determine that a module is unchanged |
| 1107 |
// since the previous invocation and avoid redownloading information about it. |
| 1108 |
// Modules that are not redownloaded will be marked in the new output by |
| 1109 |
// setting the Reuse field to true. Normally the module cache provides this |
| 1110 |
// kind of reuse automatically; the -reuse flag can be useful on systems that |
| 1111 |
// do not preserve the module cache. |
| 1112 |
// |
| 1113 |
// For more about build flags, see 'go help build'. |
| 1114 |
// |
| 1115 |
// For more about specifying packages, see 'go help packages'. |
| 1116 |
// |
| 1117 |
// For more about modules, see https://golang.org/ref/mod. |
| 1118 |
// |
| 1119 |
// # Module maintenance |
| 1120 |
// |
| 1121 |
// Go mod provides access to operations on modules. |
| 1122 |
// |
| 1123 |
// Note that support for modules is built into all the go commands, |
| 1124 |
// not just 'go mod'. For example, day-to-day adding, removing, upgrading, |
| 1125 |
// and downgrading of dependencies should be done using 'go get'. |
| 1126 |
// See 'go help modules' for an overview of module functionality. |
| 1127 |
// |
| 1128 |
// Usage: |
| 1129 |
// |
| 1130 |
// go mod <command> [arguments] |
| 1131 |
// |
| 1132 |
// The commands are: |
| 1133 |
// |
| 1134 |
// download download modules to local cache |
| 1135 |
// edit edit go.mod from tools or scripts |
| 1136 |
// graph print module requirement graph |
| 1137 |
// init initialize new module in current directory |
| 1138 |
// tidy add missing and remove unused modules |
| 1139 |
// vendor make vendored copy of dependencies |
| 1140 |
// verify verify dependencies have expected content |
| 1141 |
// why explain why packages or modules are needed |
| 1142 |
// |
| 1143 |
// Use "go help mod <command>" for more information about a command. |
| 1144 |
// |
| 1145 |
// # Download modules to local cache |
| 1146 |
// |
| 1147 |
// Usage: |
| 1148 |
// |
| 1149 |
// go mod download [-x] [-json] [-reuse=old.json] [modules] |
| 1150 |
// |
| 1151 |
// Download downloads the named modules, which can be module patterns selecting |
| 1152 |
// dependencies of the main module or module queries of the form path@version. |
| 1153 |
// |
| 1154 |
// With no arguments, download applies to the modules needed to build and test |
| 1155 |
// the packages in the main module: the modules explicitly required by the main |
| 1156 |
// module if it is at 'go 1.17' or higher, or all transitively-required modules |
| 1157 |
// if at 'go 1.16' or lower. |
| 1158 |
// |
| 1159 |
// The go command will automatically download modules as needed during ordinary |
| 1160 |
// execution. The "go mod download" command is useful mainly for pre-filling |
| 1161 |
// the local cache or to compute the answers for a Go module proxy. |
| 1162 |
// |
| 1163 |
// By default, download writes nothing to standard output. It may print progress |
| 1164 |
// messages and errors to standard error. |
| 1165 |
// |
| 1166 |
// The -json flag causes download to print a sequence of JSON objects |
| 1167 |
// to standard output, describing each downloaded module (or failure), |
| 1168 |
// corresponding to this Go struct: |
| 1169 |
// |
| 1170 |
// type Module struct { |
| 1171 |
// Path string // module path |
| 1172 |
// Query string // version query corresponding to this version |
| 1173 |
// Version string // module version |
| 1174 |
// Error string // error loading module |
| 1175 |
// Info string // absolute path to cached .info file |
| 1176 |
// GoMod string // absolute path to cached .mod file |
| 1177 |
// Zip string // absolute path to cached .zip file |
| 1178 |
// Dir string // absolute path to cached source root directory |
| 1179 |
// Sum string // checksum for path, version (as in go.sum) |
| 1180 |
// GoModSum string // checksum for go.mod (as in go.sum) |
| 1181 |
// Origin any // provenance of module |
| 1182 |
// Reuse bool // reuse of old module info is safe |
| 1183 |
// } |
| 1184 |
// |
| 1185 |
// The -reuse flag accepts the name of file containing the JSON output of a |
| 1186 |
// previous 'go mod download -json' invocation. The go command may use this |
| 1187 |
// file to determine that a module is unchanged since the previous invocation |
| 1188 |
// and avoid redownloading it. Modules that are not redownloaded will be marked |
| 1189 |
// in the new output by setting the Reuse field to true. Normally the module |
| 1190 |
// cache provides this kind of reuse automatically; the -reuse flag can be |
| 1191 |
// useful on systems that do not preserve the module cache. |
| 1192 |
// |
| 1193 |
// The -x flag causes download to print the commands download executes. |
| 1194 |
// |
| 1195 |
// See https://golang.org/ref/mod#go-mod-download for more about 'go mod download'. |
| 1196 |
// |
| 1197 |
// See https://golang.org/ref/mod#version-queries for more about version queries. |
| 1198 |
// |
| 1199 |
// # Edit go.mod from tools or scripts |
| 1200 |
// |
| 1201 |
// Usage: |
| 1202 |
// |
| 1203 |
// go mod edit [editing flags] [-fmt|-print|-json] [go.mod] |
| 1204 |
// |
| 1205 |
// Edit provides a command-line interface for editing go.mod, |
| 1206 |
// for use primarily by tools or scripts. It reads only go.mod; |
| 1207 |
// it does not look up information about the modules involved. |
| 1208 |
// By default, edit reads and writes the go.mod file of the main module, |
| 1209 |
// but a different target file can be specified after the editing flags. |
| 1210 |
// |
| 1211 |
// The editing flags specify a sequence of editing operations. |
| 1212 |
// |
| 1213 |
// The -fmt flag reformats the go.mod file without making other changes. |
| 1214 |
// This reformatting is also implied by any other modifications that use or |
| 1215 |
// rewrite the go.mod file. The only time this flag is needed is if no other |
| 1216 |
// flags are specified, as in 'go mod edit -fmt'. |
| 1217 |
// |
| 1218 |
// The -module flag changes the module's path (the go.mod file's module line). |
| 1219 |
// |
| 1220 |
// The -godebug=key=value flag adds a godebug key=value line, |
| 1221 |
// replacing any existing godebug lines with the given key. |
| 1222 |
// |
| 1223 |
// The -dropgodebug=key flag drops any existing godebug lines |
| 1224 |
// with the given key. |
| 1225 |
// |
| 1226 |
// The -require=path@version and -droprequire=path flags |
| 1227 |
// add and drop a requirement on the given module path and version. |
| 1228 |
// Note that -require overrides any existing requirements on path. |
| 1229 |
// These flags are mainly for tools that understand the module graph. |
| 1230 |
// Users should prefer 'go get path@version' or 'go get path@none', |
| 1231 |
// which make other go.mod adjustments as needed to satisfy |
| 1232 |
// constraints imposed by other modules. |
| 1233 |
// |
| 1234 |
// The -go=version flag sets the expected Go language version. |
| 1235 |
// This flag is mainly for tools that understand Go version dependencies. |
| 1236 |
// Users should prefer 'go get go@version'. |
| 1237 |
// |
| 1238 |
// The -toolchain=version flag sets the Go toolchain to use. |
| 1239 |
// This flag is mainly for tools that understand Go version dependencies. |
| 1240 |
// Users should prefer 'go get toolchain@version'. |
| 1241 |
// |
| 1242 |
// The -exclude=path@version and -dropexclude=path@version flags |
| 1243 |
// add and drop an exclusion for the given module path and version. |
| 1244 |
// Note that -exclude=path@version is a no-op if that exclusion already exists. |
| 1245 |
// |
| 1246 |
// The -replace=old[@v]=new[@v] flag adds a replacement of the given |
| 1247 |
// module path and version pair. If the @v in old@v is omitted, a |
| 1248 |
// replacement without a version on the left side is added, which applies |
| 1249 |
// to all versions of the old module path. If the @v in new@v is omitted, |
| 1250 |
// the new path should be a local module root directory, not a module |
| 1251 |
// path. Note that -replace overrides any redundant replacements for old[@v], |
| 1252 |
// so omitting @v will drop existing replacements for specific versions. |
| 1253 |
// |
| 1254 |
// The -dropreplace=old[@v] flag drops a replacement of the given |
| 1255 |
// module path and version pair. If the @v is omitted, a replacement without |
| 1256 |
// a version on the left side is dropped. |
| 1257 |
// |
| 1258 |
// The -retract=version and -dropretract=version flags add and drop a |
| 1259 |
// retraction on the given version. The version may be a single version |
| 1260 |
// like "v1.2.3" or a closed interval like "[v1.1.0,v1.1.9]". Note that |
| 1261 |
// -retract=version is a no-op if that retraction already exists. |
| 1262 |
// |
| 1263 |
// The -tool=path and -droptool=path flags add and drop a tool declaration |
| 1264 |
// for the given path. |
| 1265 |
// |
| 1266 |
// The -ignore=path and -dropignore=path flags add and drop a ignore declaration |
| 1267 |
// for the given path. |
| 1268 |
// |
| 1269 |
// The -godebug, -dropgodebug, -require, -droprequire, -exclude, -dropexclude, |
| 1270 |
// -replace, -dropreplace, -retract, -dropretract, -tool, -droptool, -ignore, |
| 1271 |
// and -dropignore editing flags may be repeated, and the changes are applied |
| 1272 |
// in the order given. |
| 1273 |
// |
| 1274 |
// The -print flag prints the final go.mod in its text format instead of |
| 1275 |
// writing it back to go.mod. |
| 1276 |
// |
| 1277 |
// The -json flag prints the final go.mod file in JSON format instead of |
| 1278 |
// writing it back to go.mod. The JSON output corresponds to these Go types: |
| 1279 |
// |
| 1280 |
// type Module struct { |
| 1281 |
// Path string |
| 1282 |
// Version string |
| 1283 |
// } |
| 1284 |
// |
| 1285 |
// type GoMod struct { |
| 1286 |
// Module ModPath |
| 1287 |
// Go string |
| 1288 |
// Toolchain string |
| 1289 |
// Godebug []Godebug |
| 1290 |
// Require []Require |
| 1291 |
// Exclude []Module |
| 1292 |
// Replace []Replace |
| 1293 |
// Retract []Retract |
| 1294 |
// } |
| 1295 |
// |
| 1296 |
// type ModPath struct { |
| 1297 |
// Path string |
| 1298 |
// Deprecated string |
| 1299 |
// } |
| 1300 |
// |
| 1301 |
// type Godebug struct { |
| 1302 |
// Key string |
| 1303 |
// Value string |
| 1304 |
// } |
| 1305 |
// |
| 1306 |
// type Require struct { |
| 1307 |
// Path string |
| 1308 |
// Version string |
| 1309 |
// Indirect bool |
| 1310 |
// } |
| 1311 |
// |
| 1312 |
// type Replace struct { |
| 1313 |
// Old Module |
| 1314 |
// New Module |
| 1315 |
// } |
| 1316 |
// |
| 1317 |
// type Retract struct { |
| 1318 |
// Low string |
| 1319 |
// High string |
| 1320 |
// Rationale string |
| 1321 |
// } |
| 1322 |
// |
| 1323 |
// type Tool struct { |
| 1324 |
// Path string |
| 1325 |
// } |
| 1326 |
// |
| 1327 |
// type Ignore struct { |
| 1328 |
// Path string |
| 1329 |
// } |
| 1330 |
// |
| 1331 |
// Retract entries representing a single version (not an interval) will have |
| 1332 |
// the "Low" and "High" fields set to the same value. |
| 1333 |
// |
| 1334 |
// Note that this only describes the go.mod file itself, not other modules |
| 1335 |
// referred to indirectly. For the full set of modules available to a build, |
| 1336 |
// use 'go list -m -json all'. |
| 1337 |
// |
| 1338 |
// Edit also provides the -C, -n, and -x build flags. |
| 1339 |
// |
| 1340 |
// See https://golang.org/ref/mod#go-mod-edit for more about 'go mod edit'. |
| 1341 |
// |
| 1342 |
// # Print module requirement graph |
| 1343 |
// |
| 1344 |
// Usage: |
| 1345 |
// |
| 1346 |
// go mod graph [-go=version] [-x] |
| 1347 |
// |
| 1348 |
// Graph prints the module requirement graph (with replacements applied) |
| 1349 |
// in text form. Each line in the output has two space-separated fields: a module |
| 1350 |
// and one of its requirements. Each module is identified as a string of the form |
| 1351 |
// path@version, except for the main module, which has no @version suffix. |
| 1352 |
// |
| 1353 |
// The -go flag causes graph to report the module graph as loaded by the |
| 1354 |
// given Go version, instead of the version indicated by the 'go' directive |
| 1355 |
// in the go.mod file. |
| 1356 |
// |
| 1357 |
// The -x flag causes graph to print the commands graph executes. |
| 1358 |
// |
| 1359 |
// See https://golang.org/ref/mod#go-mod-graph for more about 'go mod graph'. |
| 1360 |
// |
| 1361 |
// # Initialize new module in current directory |
| 1362 |
// |
| 1363 |
// Usage: |
| 1364 |
// |
| 1365 |
// go mod init [module-path] |
| 1366 |
// |
| 1367 |
// Init initializes and writes a new go.mod file in the current directory, in |
| 1368 |
// effect creating a new module rooted at the current directory. The go.mod file |
| 1369 |
// must not already exist. |
| 1370 |
// |
| 1371 |
// Init accepts one optional argument, the module path for the new module. If the |
| 1372 |
// module path argument is omitted, init will attempt to infer the module path |
| 1373 |
// using import comments in .go files and the current directory (if in GOPATH). |
| 1374 |
// |
| 1375 |
// See https://golang.org/ref/mod#go-mod-init for more about 'go mod init'. |
| 1376 |
// |
| 1377 |
// # Add missing and remove unused modules |
| 1378 |
// |
| 1379 |
// Usage: |
| 1380 |
// |
| 1381 |
// go mod tidy [-e] [-v] [-x] [-diff] [-go=version] [-compat=version] |
| 1382 |
// |
| 1383 |
// Tidy makes sure go.mod matches the source code in the module. |
| 1384 |
// It adds any missing modules necessary to build the current module's |
| 1385 |
// packages and dependencies, and it removes unused modules that |
| 1386 |
// don't provide any relevant packages. It also adds any missing entries |
| 1387 |
// to go.sum and removes any unnecessary ones. |
| 1388 |
// |
| 1389 |
// The -v flag causes tidy to print information about removed modules |
| 1390 |
// to standard error. |
| 1391 |
// |
| 1392 |
// The -e flag causes tidy to attempt to proceed despite errors |
| 1393 |
// encountered while loading packages. |
| 1394 |
// |
| 1395 |
// The -diff flag causes tidy not to modify go.mod or go.sum but |
| 1396 |
// instead print the necessary changes as a unified diff. It exits |
| 1397 |
// with a non-zero code if the diff is not empty. |
| 1398 |
// |
| 1399 |
// The -go flag causes tidy to update the 'go' directive in the go.mod |
| 1400 |
// file to the given version, which may change which module dependencies |
| 1401 |
// are retained as explicit requirements in the go.mod file. |
| 1402 |
// (Go versions 1.17 and higher retain more requirements in order to |
| 1403 |
// support lazy module loading.) |
| 1404 |
// |
| 1405 |
// The -compat flag preserves any additional checksums needed for the |
| 1406 |
// 'go' command from the indicated major Go release to successfully load |
| 1407 |
// the module graph, and causes tidy to error out if that version of the |
| 1408 |
// 'go' command would load any imported package from a different module |
| 1409 |
// version. By default, tidy acts as if the -compat flag were set to the |
| 1410 |
// version prior to the one indicated by the 'go' directive in the go.mod |
| 1411 |
// file. |
| 1412 |
// |
| 1413 |
// The -x flag causes tidy to print the commands download executes. |
| 1414 |
// |
| 1415 |
// See https://golang.org/ref/mod#go-mod-tidy for more about 'go mod tidy'. |
| 1416 |
// |
| 1417 |
// # Make vendored copy of dependencies |
| 1418 |
// |
| 1419 |
// Usage: |
| 1420 |
// |
| 1421 |
// go mod vendor [-e] [-v] [-o outdir] |
| 1422 |
// |
| 1423 |
// Vendor resets the main module's vendor directory to include all packages |
| 1424 |
// needed to build and test all the main module's packages. |
| 1425 |
// It does not include test code for vendored packages. |
| 1426 |
// |
| 1427 |
// The -v flag causes vendor to print the names of vendored |
| 1428 |
// modules and packages to standard error. |
| 1429 |
// |
| 1430 |
// The -e flag causes vendor to attempt to proceed despite errors |
| 1431 |
// encountered while loading packages. |
| 1432 |
// |
| 1433 |
// The -o flag causes vendor to create the vendor directory at the given |
| 1434 |
// path instead of "vendor". The go command can only use a vendor directory |
| 1435 |
// named "vendor" within the module root directory, so this flag is |
| 1436 |
// primarily useful for other tools. |
| 1437 |
// |
| 1438 |
// See https://golang.org/ref/mod#go-mod-vendor for more about 'go mod vendor'. |
| 1439 |
// |
| 1440 |
// # Verify dependencies have expected content |
| 1441 |
// |
| 1442 |
// Usage: |
| 1443 |
// |
| 1444 |
// go mod verify |
| 1445 |
// |
| 1446 |
// Verify checks that the dependencies of the current module, |
| 1447 |
// which are stored in a local downloaded source cache, have not been |
| 1448 |
// modified since being downloaded. If all the modules are unmodified, |
| 1449 |
// verify prints "all modules verified." Otherwise it reports which |
| 1450 |
// modules have been changed and causes 'go mod' to exit with a |
| 1451 |
// non-zero status. |
| 1452 |
// |
| 1453 |
// See https://golang.org/ref/mod#go-mod-verify for more about 'go mod verify'. |
| 1454 |
// |
| 1455 |
// # Explain why packages or modules are needed |
| 1456 |
// |
| 1457 |
// Usage: |
| 1458 |
// |
| 1459 |
// go mod why [-m] [-vendor] packages... |
| 1460 |
// |
| 1461 |
// Why shows a shortest path in the import graph from the main module to |
| 1462 |
// each of the listed packages. If the -m flag is given, why treats the |
| 1463 |
// arguments as a list of modules and finds a path to any package in each |
| 1464 |
// of the modules. |
| 1465 |
// |
| 1466 |
// By default, why queries the graph of packages matched by "go list all", |
| 1467 |
// which includes tests for reachable packages. The -vendor flag causes why |
| 1468 |
// to exclude tests of dependencies. |
| 1469 |
// |
| 1470 |
// The output is a sequence of stanzas, one for each package or module |
| 1471 |
// name on the command line, separated by blank lines. Each stanza begins |
| 1472 |
// with a comment line "# package" or "# module" giving the target |
| 1473 |
// package or module. Subsequent lines give a path through the import |
| 1474 |
// graph, one package per line. If the package or module is not |
| 1475 |
// referenced from the main module, the stanza will display a single |
| 1476 |
// parenthesized note indicating that fact. |
| 1477 |
// |
| 1478 |
// For example: |
| 1479 |
// |
| 1480 |
// $ go mod why golang.org/x/text/language golang.org/x/text/encoding |
| 1481 |
// # golang.org/x/text/language |
| 1482 |
// rsc.io/quote |
| 1483 |
// rsc.io/sampler |
| 1484 |
// golang.org/x/text/language |
| 1485 |
// |
| 1486 |
// # golang.org/x/text/encoding |
| 1487 |
// (main module does not need package golang.org/x/text/encoding) |
| 1488 |
// $ |
| 1489 |
// |
| 1490 |
// See https://golang.org/ref/mod#go-mod-why for more about 'go mod why'. |
| 1491 |
// |
| 1492 |
// # Workspace maintenance |
| 1493 |
// |
| 1494 |
// Work provides access to operations on workspaces. |
| 1495 |
// |
| 1496 |
// Note that support for workspaces is built into many other commands, not |
| 1497 |
// just 'go work'. |
| 1498 |
// |
| 1499 |
// See 'go help modules' for information about Go's module system of which |
| 1500 |
// workspaces are a part. |
| 1501 |
// |
| 1502 |
// See https://go.dev/ref/mod#workspaces for an in-depth reference on |
| 1503 |
// workspaces. |
| 1504 |
// |
| 1505 |
// See https://go.dev/doc/tutorial/workspaces for an introductory |
| 1506 |
// tutorial on workspaces. |
| 1507 |
// |
| 1508 |
// A workspace is specified by a go.work file that specifies a set of |
| 1509 |
// module directories with the "use" directive. These modules are used as |
| 1510 |
// root modules by the go command for builds and related operations. A |
| 1511 |
// workspace that does not specify modules to be used cannot be used to do |
| 1512 |
// builds from local modules. |
| 1513 |
// |
| 1514 |
// go.work files are line-oriented. Each line holds a single directive, |
| 1515 |
// made up of a keyword followed by arguments. For example: |
| 1516 |
// |
| 1517 |
// go 1.18 |
| 1518 |
// |
| 1519 |
// use ../foo/bar |
| 1520 |
// use ./baz |
| 1521 |
// |
| 1522 |
// replace example.com/foo v1.2.3 => example.com/bar v1.4.5 |
| 1523 |
// |
| 1524 |
// The leading keyword can be factored out of adjacent lines to create a block, |
| 1525 |
// like in Go imports. |
| 1526 |
// |
| 1527 |
// use ( |
| 1528 |
// ../foo/bar |
| 1529 |
// ./baz |
| 1530 |
// ) |
| 1531 |
// |
| 1532 |
// The use directive specifies a module to be included in the workspace's |
| 1533 |
// set of main modules. The argument to the use directive is the directory |
| 1534 |
// containing the module's go.mod file. |
| 1535 |
// |
| 1536 |
// The go directive specifies the version of Go the file was written at. It |
| 1537 |
// is possible there may be future changes in the semantics of workspaces |
| 1538 |
// that could be controlled by this version, but for now the version |
| 1539 |
// specified has no effect. |
| 1540 |
// |
| 1541 |
// The replace directive has the same syntax as the replace directive in a |
| 1542 |
// go.mod file and takes precedence over replaces in go.mod files. It is |
| 1543 |
// primarily intended to override conflicting replaces in different workspace |
| 1544 |
// modules. |
| 1545 |
// |
| 1546 |
// To determine whether the go command is operating in workspace mode, use |
| 1547 |
// the "go env GOWORK" command. This will specify the workspace file being |
| 1548 |
// used. |
| 1549 |
// |
| 1550 |
// Usage: |
| 1551 |
// |
| 1552 |
// go work <command> [arguments] |
| 1553 |
// |
| 1554 |
// The commands are: |
| 1555 |
// |
| 1556 |
// edit edit go.work from tools or scripts |
| 1557 |
// init initialize workspace file |
| 1558 |
// sync sync workspace build list to modules |
| 1559 |
// use add modules to workspace file |
| 1560 |
// vendor make vendored copy of dependencies |
| 1561 |
// |
| 1562 |
// Use "go help work <command>" for more information about a command. |
| 1563 |
// |
| 1564 |
// # Edit go.work from tools or scripts |
| 1565 |
// |
| 1566 |
// Usage: |
| 1567 |
// |
| 1568 |
// go work edit [editing flags] [go.work] |
| 1569 |
// |
| 1570 |
// Edit provides a command-line interface for editing go.work, |
| 1571 |
// for use primarily by tools or scripts. It only reads go.work; |
| 1572 |
// it does not look up information about the modules involved. |
| 1573 |
// If no file is specified, Edit looks for a go.work file in the current |
| 1574 |
// directory and its parent directories |
| 1575 |
// |
| 1576 |
// The editing flags specify a sequence of editing operations. |
| 1577 |
// |
| 1578 |
// The -fmt flag reformats the go.work file without making other changes. |
| 1579 |
// This reformatting is also implied by any other modifications that use or |
| 1580 |
// rewrite the go.mod file. The only time this flag is needed is if no other |
| 1581 |
// flags are specified, as in 'go work edit -fmt'. |
| 1582 |
// |
| 1583 |
// The -godebug=key=value flag adds a godebug key=value line, |
| 1584 |
// replacing any existing godebug lines with the given key. |
| 1585 |
// |
| 1586 |
// The -dropgodebug=key flag drops any existing godebug lines |
| 1587 |
// with the given key. |
| 1588 |
// |
| 1589 |
// The -use=path and -dropuse=path flags |
| 1590 |
// add and drop a use directive from the go.work file's set of module directories. |
| 1591 |
// |
| 1592 |
// The -replace=old[@v]=new[@v] flag adds a replacement of the given |
| 1593 |
// module path and version pair. If the @v in old@v is omitted, a |
| 1594 |
// replacement without a version on the left side is added, which applies |
| 1595 |
// to all versions of the old module path. If the @v in new@v is omitted, |
| 1596 |
// the new path should be a local module root directory, not a module |
| 1597 |
// path. Note that -replace overrides any redundant replacements for old[@v], |
| 1598 |
// so omitting @v will drop existing replacements for specific versions. |
| 1599 |
// |
| 1600 |
// The -dropreplace=old[@v] flag drops a replacement of the given |
| 1601 |
// module path and version pair. If the @v is omitted, a replacement without |
| 1602 |
// a version on the left side is dropped. |
| 1603 |
// |
| 1604 |
// The -use, -dropuse, -replace, and -dropreplace, |
| 1605 |
// editing flags may be repeated, and the changes are applied in the order given. |
| 1606 |
// |
| 1607 |
// The -go=version flag sets the expected Go language version. |
| 1608 |
// |
| 1609 |
// The -toolchain=name flag sets the Go toolchain to use. |
| 1610 |
// |
| 1611 |
// The -print flag prints the final go.work in its text format instead of |
| 1612 |
// writing it back to go.mod. |
| 1613 |
// |
| 1614 |
// The -json flag prints the final go.work file in JSON format instead of |
| 1615 |
// writing it back to go.mod. The JSON output corresponds to these Go types: |
| 1616 |
// |
| 1617 |
// type GoWork struct { |
| 1618 |
// Go string |
| 1619 |
// Toolchain string |
| 1620 |
// Godebug []Godebug |
| 1621 |
// Use []Use |
| 1622 |
// Replace []Replace |
| 1623 |
// } |
| 1624 |
// |
| 1625 |
// type Godebug struct { |
| 1626 |
// Key string |
| 1627 |
// Value string |
| 1628 |
// } |
| 1629 |
// |
| 1630 |
// type Use struct { |
| 1631 |
// DiskPath string |
| 1632 |
// ModulePath string |
| 1633 |
// } |
| 1634 |
// |
| 1635 |
// type Replace struct { |
| 1636 |
// Old Module |
| 1637 |
// New Module |
| 1638 |
// } |
| 1639 |
// |
| 1640 |
// type Module struct { |
| 1641 |
// Path string |
| 1642 |
// Version string |
| 1643 |
// } |
| 1644 |
// |
| 1645 |
// See the workspaces reference at https://go.dev/ref/mod#workspaces |
| 1646 |
// for more information. |
| 1647 |
// |
| 1648 |
// # Initialize workspace file |
| 1649 |
// |
| 1650 |
// Usage: |
| 1651 |
// |
| 1652 |
// go work init [moddirs] |
| 1653 |
// |
| 1654 |
// Init initializes and writes a new go.work file in the |
| 1655 |
// current directory, in effect creating a new workspace at the current |
| 1656 |
// directory. |
| 1657 |
// |
| 1658 |
// go work init optionally accepts paths to the workspace modules as |
| 1659 |
// arguments. If the argument is omitted, an empty workspace with no |
| 1660 |
// modules will be created. |
| 1661 |
// |
| 1662 |
// Each argument path is added to a use directive in the go.work file. The |
| 1663 |
// current go version will also be listed in the go.work file. |
| 1664 |
// |
| 1665 |
// See the workspaces reference at https://go.dev/ref/mod#workspaces |
| 1666 |
// for more information. |
| 1667 |
// |
| 1668 |
// # Sync workspace build list to modules |
| 1669 |
// |
| 1670 |
// Usage: |
| 1671 |
// |
| 1672 |
// go work sync |
| 1673 |
// |
| 1674 |
// Sync syncs the workspace's build list back to the |
| 1675 |
// workspace's modules |
| 1676 |
// |
| 1677 |
// The workspace's build list is the set of versions of all the |
| 1678 |
// (transitive) dependency modules used to do builds in the workspace. go |
| 1679 |
// work sync generates that build list using the Minimal Version Selection |
| 1680 |
// algorithm, and then syncs those versions back to each of modules |
| 1681 |
// specified in the workspace (with use directives). |
| 1682 |
// |
| 1683 |
// The syncing is done by sequentially upgrading each of the dependency |
| 1684 |
// modules specified in a workspace module to the version in the build list |
| 1685 |
// if the dependency module's version is not already the same as the build |
| 1686 |
// list's version. Note that Minimal Version Selection guarantees that the |
| 1687 |
// build list's version of each module is always the same or higher than |
| 1688 |
// that in each workspace module. |
| 1689 |
// |
| 1690 |
// See the workspaces reference at https://go.dev/ref/mod#workspaces |
| 1691 |
// for more information. |
| 1692 |
// |
| 1693 |
// # Add modules to workspace file |
| 1694 |
// |
| 1695 |
// Usage: |
| 1696 |
// |
| 1697 |
// go work use [-r] [moddirs] |
| 1698 |
// |
| 1699 |
// Use provides a command-line interface for adding |
| 1700 |
// directories, optionally recursively, to a go.work file. |
| 1701 |
// |
| 1702 |
// A use directive will be added to the go.work file for each argument |
| 1703 |
// directory listed on the command line go.work file, if it exists, |
| 1704 |
// or removed from the go.work file if it does not exist. |
| 1705 |
// Use fails if any remaining use directives refer to modules that |
| 1706 |
// do not exist. |
| 1707 |
// |
| 1708 |
// Use updates the go line in go.work to specify a version at least as |
| 1709 |
// new as all the go lines in the used modules, both preexisting ones |
| 1710 |
// and newly added ones. With no arguments, this update is the only |
| 1711 |
// thing that go work use does. |
| 1712 |
// |
| 1713 |
// The -r flag searches recursively for modules in the argument |
| 1714 |
// directories, and the use command operates as if each of the directories |
| 1715 |
// were specified as arguments. |
| 1716 |
// |
| 1717 |
// See the workspaces reference at https://go.dev/ref/mod#workspaces |
| 1718 |
// for more information. |
| 1719 |
// |
| 1720 |
// # Make vendored copy of dependencies |
| 1721 |
// |
| 1722 |
// Usage: |
| 1723 |
// |
| 1724 |
// go work vendor [-e] [-v] [-o outdir] |
| 1725 |
// |
| 1726 |
// Vendor resets the workspace's vendor directory to include all packages |
| 1727 |
// needed to build and test all the workspace's packages. |
| 1728 |
// It does not include test code for vendored packages. |
| 1729 |
// |
| 1730 |
// The -v flag causes vendor to print the names of vendored |
| 1731 |
// modules and packages to standard error. |
| 1732 |
// |
| 1733 |
// The -e flag causes vendor to attempt to proceed despite errors |
| 1734 |
// encountered while loading packages. |
| 1735 |
// |
| 1736 |
// The -o flag causes vendor to create the vendor directory at the given |
| 1737 |
// path instead of "vendor". The go command can only use a vendor directory |
| 1738 |
// named "vendor" within the module root directory, so this flag is |
| 1739 |
// primarily useful for other tools. |
| 1740 |
// |
| 1741 |
// # Compile and run Go program |
| 1742 |
// |
| 1743 |
// Usage: |
| 1744 |
// |
| 1745 |
// go run [build flags] [-exec xprog] package [arguments...] |
| 1746 |
// |
| 1747 |
// Run compiles and runs the named main Go package. |
| 1748 |
// Typically the package is specified as a list of .go source files from a single |
| 1749 |
// directory, but it may also be an import path, file system path, or pattern |
| 1750 |
// matching a single known package, as in 'go run .' or 'go run my/cmd'. |
| 1751 |
// |
| 1752 |
// If the package argument has a version suffix (like @latest or @v1.0.0), |
| 1753 |
// "go run" builds the program in module-aware mode, ignoring the go.mod file in |
| 1754 |
// the current directory or any parent directory, if there is one. This is useful |
| 1755 |
// for running programs without affecting the dependencies of the main module. |
| 1756 |
// |
| 1757 |
// If the package argument doesn't have a version suffix, "go run" may run in |
| 1758 |
// module-aware mode or GOPATH mode, depending on the GO111MODULE environment |
| 1759 |
// variable and the presence of a go.mod file. See 'go help modules' for details. |
| 1760 |
// If module-aware mode is enabled, "go run" runs in the context of the main |
| 1761 |
// module. |
| 1762 |
// |
| 1763 |
// By default, 'go run' runs the compiled binary directly: 'a.out arguments...'. |
| 1764 |
// If the -exec flag is given, 'go run' invokes the binary using xprog: |
| 1765 |
// |
| 1766 |
// 'xprog a.out arguments...'. |
| 1767 |
// |
| 1768 |
// If the -exec flag is not given, GOOS or GOARCH is different from the system |
| 1769 |
// default, and a program named go_$GOOS_$GOARCH_exec can be found |
| 1770 |
// on the current search path, 'go run' invokes the binary using that program, |
| 1771 |
// for example 'go_js_wasm_exec a.out arguments...'. This allows execution of |
| 1772 |
// cross-compiled programs when a simulator or other execution method is |
| 1773 |
// available. |
| 1774 |
// |
| 1775 |
// By default, 'go run' compiles the binary without generating the information |
| 1776 |
// used by debuggers, to reduce build time. To include debugger information in |
| 1777 |
// the binary, use 'go build'. |
| 1778 |
// |
| 1779 |
// The exit status of Run is not the exit status of the compiled binary. |
| 1780 |
// |
| 1781 |
// For more about build flags, see 'go help build'. |
| 1782 |
// For more about specifying packages, see 'go help packages'. |
| 1783 |
// |
| 1784 |
// See also: go build. |
| 1785 |
// |
| 1786 |
// # Manage telemetry data and settings |
| 1787 |
// |
| 1788 |
// Usage: |
| 1789 |
// |
| 1790 |
// go telemetry [off|local|on] |
| 1791 |
// |
| 1792 |
// Telemetry is used to manage Go telemetry data and settings. |
| 1793 |
// |
| 1794 |
// Telemetry can be in one of three modes: off, local, or on. |
| 1795 |
// |
| 1796 |
// When telemetry is in local mode, counter data is written to the local file |
| 1797 |
// system, but will not be uploaded to remote servers. |
| 1798 |
// |
| 1799 |
// When telemetry is off, local counter data is neither collected nor uploaded. |
| 1800 |
// |
| 1801 |
// When telemetry is on, telemetry data is written to the local file system |
| 1802 |
// and periodically sent to https://telemetry.go.dev/. Uploaded data is used to |
| 1803 |
// help improve the Go toolchain and related tools, and it will be published as |
| 1804 |
// part of a public dataset. |
| 1805 |
// |
| 1806 |
// For more details, see https://telemetry.go.dev/privacy. |
| 1807 |
// This data is collected in accordance with the Google Privacy Policy |
| 1808 |
// (https://policies.google.com/privacy). |
| 1809 |
// |
| 1810 |
// To view the current telemetry mode, run "go telemetry". |
| 1811 |
// To disable telemetry uploading, but keep local data collection, run |
| 1812 |
// "go telemetry local". |
| 1813 |
// To enable both collection and uploading, run “go telemetry on”. |
| 1814 |
// To disable both collection and uploading, run "go telemetry off". |
| 1815 |
// |
| 1816 |
// The current telemetry mode is also available as the value of the |
| 1817 |
// non-settable "GOTELEMETRY" go env variable. The directory in the |
| 1818 |
// local file system that telemetry data is written to is available |
| 1819 |
// as the value of the non-settable "GOTELEMETRYDIR" go env variable. |
| 1820 |
// |
| 1821 |
// See https://go.dev/doc/telemetry for more information on telemetry. |
| 1822 |
// |
| 1823 |
// # Test packages |
| 1824 |
// |
| 1825 |
// Usage: |
| 1826 |
// |
| 1827 |
// go test [build/test flags] [packages] [build/test flags & test binary flags] |
| 1828 |
// |
| 1829 |
// 'Go test' automates testing the packages named by the import paths. |
| 1830 |
// It prints a summary of the test results in the format: |
| 1831 |
// |
| 1832 |
// ok archive/tar 0.011s |
| 1833 |
// FAIL archive/zip 0.022s |
| 1834 |
// ok compress/gzip 0.033s |
| 1835 |
// ... |
| 1836 |
// |
| 1837 |
// followed by detailed output for each failed package. |
| 1838 |
// |
| 1839 |
// 'Go test' recompiles each package along with any files with names matching |
| 1840 |
// the file pattern "*_test.go". |
| 1841 |
// These additional files can contain test functions, benchmark functions, fuzz |
| 1842 |
// tests and example functions. See 'go help testfunc' for more. |
| 1843 |
// Each listed package causes the execution of a separate test binary. |
| 1844 |
// Files whose names begin with "_" (including "_test.go") or "." are ignored. |
| 1845 |
// |
| 1846 |
// Test files that declare a package with the suffix "_test" will be compiled as a |
| 1847 |
// separate package, and then linked and run with the main test binary. |
| 1848 |
// |
| 1849 |
// The go tool will ignore a directory named "testdata", making it available |
| 1850 |
// to hold ancillary data needed by the tests. |
| 1851 |
// |
| 1852 |
// As part of building a test binary, go test runs go vet on the package |
| 1853 |
// and its test source files to identify significant problems. If go vet |
| 1854 |
// finds any problems, go test reports those and does not run the test |
| 1855 |
// binary. Only a high-confidence subset of the default go vet checks are |
| 1856 |
// used. That subset is: atomic, bool, buildtags, directive, errorsas, |
| 1857 |
// ifaceassert, nilfunc, printf, stringintconv, and tests. You can see |
| 1858 |
// the documentation for these and other vet tests via "go doc cmd/vet". |
| 1859 |
// To disable the running of go vet, use the -vet=off flag. To run all |
| 1860 |
// checks, use the -vet=all flag. |
| 1861 |
// |
| 1862 |
// All test output and summary lines are printed to the go command's |
| 1863 |
// standard output, even if the test printed them to its own standard |
| 1864 |
// error. (The go command's standard error is reserved for printing |
| 1865 |
// errors building the tests.) |
| 1866 |
// |
| 1867 |
// The go command places $GOROOT/bin at the beginning of $PATH |
| 1868 |
// in the test's environment, so that tests that execute |
| 1869 |
// 'go' commands use the same 'go' as the parent 'go test' command. |
| 1870 |
// |
| 1871 |
// Go test runs in two different modes: |
| 1872 |
// |
| 1873 |
// The first, called local directory mode, occurs when go test is |
| 1874 |
// invoked with no package arguments (for example, 'go test' or 'go |
| 1875 |
// test -v'). In this mode, go test compiles the package sources and |
| 1876 |
// tests found in the current directory and then runs the resulting |
| 1877 |
// test binary. In this mode, caching (discussed below) is disabled. |
| 1878 |
// After the package test finishes, go test prints a summary line |
| 1879 |
// showing the test status ('ok' or 'FAIL'), package name, and elapsed |
| 1880 |
// time. |
| 1881 |
// |
| 1882 |
// The second, called package list mode, occurs when go test is invoked |
| 1883 |
// with explicit package arguments (for example 'go test math', 'go |
| 1884 |
// test ./...', and even 'go test .'). In this mode, go test compiles |
| 1885 |
// and tests each of the packages listed on the command line. If a |
| 1886 |
// package test passes, go test prints only the final 'ok' summary |
| 1887 |
// line. If a package test fails, go test prints the full test output. |
| 1888 |
// If invoked with the -bench or -v flag, go test prints the full |
| 1889 |
// output even for passing package tests, in order to display the |
| 1890 |
// requested benchmark results or verbose logging. After the package |
| 1891 |
// tests for all of the listed packages finish, and their output is |
| 1892 |
// printed, go test prints a final 'FAIL' status if any package test |
| 1893 |
// has failed. |
| 1894 |
// |
| 1895 |
// In package list mode only, go test caches successful package test |
| 1896 |
// results to avoid unnecessary repeated running of tests. When the |
| 1897 |
// result of a test can be recovered from the cache, go test will |
| 1898 |
// redisplay the previous output instead of running the test binary |
| 1899 |
// again. When this happens, go test prints '(cached)' in place of the |
| 1900 |
// elapsed time in the summary line. |
| 1901 |
// |
| 1902 |
// The rule for a match in the cache is that the run involves the same |
| 1903 |
// test binary and the flags on the command line come entirely from a |
| 1904 |
// restricted set of 'cacheable' test flags, defined as -benchtime, |
| 1905 |
// -coverprofile, -cpu, -failfast, -fullpath, -list, -outputdir, -parallel, |
| 1906 |
// -run, -short, -skip, -timeout and -v. |
| 1907 |
// If a run of go test has any test or non-test flags outside this set, |
| 1908 |
// the result is not cached. To disable test caching, use any test flag |
| 1909 |
// or argument other than the cacheable flags. The idiomatic way to disable |
| 1910 |
// test caching explicitly is to use -count=1. Tests that open files within |
| 1911 |
// the package's module or that consult environment variables only |
| 1912 |
// match future runs in which the files and environment variables are |
| 1913 |
// unchanged. A cached test result is treated as executing in no time |
| 1914 |
// at all, so a successful package test result will be cached and |
| 1915 |
// reused regardless of -timeout setting. |
| 1916 |
// |
| 1917 |
// In addition to the build flags, the flags handled by 'go test' itself are: |
| 1918 |
// |
| 1919 |
// -args |
| 1920 |
// Pass the remainder of the command line (everything after -args) |
| 1921 |
// to the test binary, uninterpreted and unchanged. |
| 1922 |
// Because this flag consumes the remainder of the command line, |
| 1923 |
// the package list (if present) must appear before this flag. |
| 1924 |
// |
| 1925 |
// -c |
| 1926 |
// Compile the test binary to pkg.test in the current directory but do not run it |
| 1927 |
// (where pkg is the last element of the package's import path). |
| 1928 |
// The file name or target directory can be changed with the -o flag. |
| 1929 |
// |
| 1930 |
// -exec xprog |
| 1931 |
// Run the test binary using xprog. The behavior is the same as |
| 1932 |
// in 'go run'. See 'go help run' for details. |
| 1933 |
// |
| 1934 |
// -json |
| 1935 |
// Convert test output to JSON suitable for automated processing. |
| 1936 |
// See 'go doc test2json' for the encoding details. |
| 1937 |
// Also emits build output in JSON. See 'go help buildjson'. |
| 1938 |
// |
| 1939 |
// -o file |
| 1940 |
// Compile the test binary to the named file. |
| 1941 |
// The test still runs (unless -c or -i is specified). |
| 1942 |
// If file ends in a slash or names an existing directory, |
| 1943 |
// the test is written to pkg.test in that directory. |
| 1944 |
// |
| 1945 |
// The test binary also accepts flags that control execution of the test; these |
| 1946 |
// flags are also accessible by 'go test'. See 'go help testflag' for details. |
| 1947 |
// |
| 1948 |
// For more about build flags, see 'go help build'. |
| 1949 |
// For more about specifying packages, see 'go help packages'. |
| 1950 |
// |
| 1951 |
// See also: go build, go vet. |
| 1952 |
// |
| 1953 |
// # Run specified go tool |
| 1954 |
// |
| 1955 |
// Usage: |
| 1956 |
// |
| 1957 |
// go tool [-n] command [args...] |
| 1958 |
// |
| 1959 |
// Tool runs the go tool command identified by the arguments. |
| 1960 |
// |
| 1961 |
// Go ships with a number of builtin tools, and additional tools |
| 1962 |
// may be defined in the go.mod of the current module. |
| 1963 |
// |
| 1964 |
// With no arguments it prints the list of known tools. |
| 1965 |
// |
| 1966 |
// The -n flag causes tool to print the command that would be |
| 1967 |
// executed but not execute it. |
| 1968 |
// |
| 1969 |
// The -modfile=file.mod build flag causes tool to use an alternate file |
| 1970 |
// instead of the go.mod in the module root directory. |
| 1971 |
// |
| 1972 |
// Tool also provides the -C, -overlay, and -modcacherw build flags. |
| 1973 |
// |
| 1974 |
// For more about build flags, see 'go help build'. |
| 1975 |
// |
| 1976 |
// For more about each builtin tool command, see 'go doc cmd/<command>'. |
| 1977 |
// |
| 1978 |
// # Print Go version |
| 1979 |
// |
| 1980 |
// Usage: |
| 1981 |
// |
| 1982 |
// go version [-m] [-v] [-json] [file ...] |
| 1983 |
// |
| 1984 |
// Version prints the build information for Go binary files. |
| 1985 |
// |
| 1986 |
// Go version reports the Go version used to build each of the named files. |
| 1987 |
// |
| 1988 |
// If no files are named on the command line, go version prints its own |
| 1989 |
// version information. |
| 1990 |
// |
| 1991 |
// If a directory is named, go version walks that directory, recursively, |
| 1992 |
// looking for recognized Go binaries and reporting their versions. |
| 1993 |
// By default, go version does not report unrecognized files found |
| 1994 |
// during a directory scan. The -v flag causes it to report unrecognized files. |
| 1995 |
// |
| 1996 |
// The -m flag causes go version to print each file's embedded |
| 1997 |
// module version information, when available. In the output, the module |
| 1998 |
// information consists of multiple lines following the version line, each |
| 1999 |
// indented by a leading tab character. |
| 2000 |
// |
| 2001 |
// The -json flag is similar to -m but outputs the runtime/debug.BuildInfo in JSON format. |
| 2002 |
// If flag -json is specified without -m, go version reports an error. |
| 2003 |
// |
| 2004 |
// See also: go doc runtime/debug.BuildInfo. |
| 2005 |
// |
| 2006 |
// # Report likely mistakes in packages |
| 2007 |
// |
| 2008 |
// Usage: |
| 2009 |
// |
| 2010 |
// go vet [build flags] [-vettool prog] [vet flags] [packages] |
| 2011 |
// |
| 2012 |
// Vet runs the Go vet command on the packages named by the import paths. |
| 2013 |
// |
| 2014 |
// For more about vet and its flags, see 'go doc cmd/vet'. |
| 2015 |
// For more about specifying packages, see 'go help packages'. |
| 2016 |
// For a list of checkers and their flags, see 'go tool vet help'. |
| 2017 |
// For details of a specific checker such as 'printf', see 'go tool vet help printf'. |
| 2018 |
// |
| 2019 |
// The -vettool=prog flag selects a different analysis tool with alternative |
| 2020 |
// or additional checks. |
| 2021 |
// For example, the 'shadow' analyzer can be built and run using these commands: |
| 2022 |
// |
| 2023 |
// go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest |
| 2024 |
// go vet -vettool=$(which shadow) |
| 2025 |
// |
| 2026 |
// The build flags supported by go vet are those that control package resolution |
| 2027 |
// and execution, such as -C, -n, -x, -v, -tags, and -toolexec. |
| 2028 |
// For more about these flags, see 'go help build'. |
| 2029 |
// |
| 2030 |
// See also: go fmt, go fix. |
| 2031 |
// |
| 2032 |
// # Build constraints |
| 2033 |
// |
| 2034 |
// A build constraint, also known as a build tag, is a condition under which a |
| 2035 |
// file should be included in the package. Build constraints are given by a |
| 2036 |
// line comment that begins |
| 2037 |
// |
| 2038 |
// //go:build |
| 2039 |
// |
| 2040 |
// Build constraints can also be used to downgrade the language version |
| 2041 |
// used to compile a file. |
| 2042 |
// |
| 2043 |
// Constraints may appear in any kind of source file (not just Go), but |
| 2044 |
// they must appear near the top of the file, preceded |
| 2045 |
// only by blank lines and other comments. These rules mean that in Go |
| 2046 |
// files a build constraint must appear before the package clause. |
| 2047 |
// |
| 2048 |
// To distinguish build constraints from package documentation, |
| 2049 |
// a build constraint should be followed by a blank line. |
| 2050 |
// |
| 2051 |
// A build constraint comment is evaluated as an expression containing |
| 2052 |
// build tags combined by ||, &&, and ! operators and parentheses. |
| 2053 |
// Operators have the same meaning as in Go. |
| 2054 |
// |
| 2055 |
// For example, the following build constraint constrains a file to |
| 2056 |
// build when the "linux" and "386" constraints are satisfied, or when |
| 2057 |
// "darwin" is satisfied and "cgo" is not: |
| 2058 |
// |
| 2059 |
// //go:build (linux && 386) || (darwin && !cgo) |
| 2060 |
// |
| 2061 |
// It is an error for a file to have more than one //go:build line. |
| 2062 |
// |
| 2063 |
// During a particular build, the following build tags are satisfied: |
| 2064 |
// |
| 2065 |
// - the target operating system, as spelled by runtime.GOOS, set with the |
| 2066 |
// GOOS environment variable. |
| 2067 |
// - the target architecture, as spelled by runtime.GOARCH, set with the |
| 2068 |
// GOARCH environment variable. |
| 2069 |
// - any architecture features, in the form GOARCH.feature |
| 2070 |
// (for example, "amd64.v2"), as detailed below. |
| 2071 |
// - "unix", if GOOS is a Unix or Unix-like system. |
| 2072 |
// - the compiler being used, either "gc" or "gccgo" |
| 2073 |
// - "cgo", if the cgo command is supported (see CGO_ENABLED in |
| 2074 |
// 'go help environment'). |
| 2075 |
// - a term for each Go major release, through the current version: |
| 2076 |
// "go1.1" from Go version 1.1 onward, "go1.12" from Go 1.12, and so on. |
| 2077 |
// - any additional tags given by the -tags flag (see 'go help build'). |
| 2078 |
// |
| 2079 |
// There are no separate build tags for beta or minor releases. |
| 2080 |
// |
| 2081 |
// If a file's name, after stripping the extension and a possible _test suffix, |
| 2082 |
// matches any of the following patterns: |
| 2083 |
// |
| 2084 |
// *_GOOS |
| 2085 |
// *_GOARCH |
| 2086 |
// *_GOOS_GOARCH |
| 2087 |
// |
| 2088 |
// (example: source_windows_amd64.go) where GOOS and GOARCH represent |
| 2089 |
// any known operating system and architecture values respectively, then |
| 2090 |
// the file is considered to have an implicit build constraint requiring |
| 2091 |
// those terms (in addition to any explicit constraints in the file). |
| 2092 |
// |
| 2093 |
// Using GOOS=android matches build tags and files as for GOOS=linux |
| 2094 |
// in addition to android tags and files. |
| 2095 |
// |
| 2096 |
// Using GOOS=illumos matches build tags and files as for GOOS=solaris |
| 2097 |
// in addition to illumos tags and files. |
| 2098 |
// |
| 2099 |
// Using GOOS=ios matches build tags and files as for GOOS=darwin |
| 2100 |
// in addition to ios tags and files. |
| 2101 |
// |
| 2102 |
// The defined architecture feature build tags are: |
| 2103 |
// |
| 2104 |
// - For GOARCH=386, GO386=387 and GO386=sse2 |
| 2105 |
// set the 386.387 and 386.sse2 build tags, respectively. |
| 2106 |
// - For GOARCH=amd64, GOAMD64=v1, v2, and v3 |
| 2107 |
// correspond to the amd64.v1, amd64.v2, and amd64.v3 feature build tags. |
| 2108 |
// - For GOARCH=arm, GOARM=5, 6, and 7 |
| 2109 |
// correspond to the arm.5, arm.6, and arm.7 feature build tags. |
| 2110 |
// - For GOARCH=arm64, GOARM64=v8.{0-9} and v9.{0-5} |
| 2111 |
// correspond to the arm64.v8.{0-9} and arm64.v9.{0-5} feature build tags. |
| 2112 |
// - For GOARCH=mips or mipsle, |
| 2113 |
// GOMIPS=hardfloat and softfloat |
| 2114 |
// correspond to the mips.hardfloat and mips.softfloat |
| 2115 |
// (or mipsle.hardfloat and mipsle.softfloat) feature build tags. |
| 2116 |
// - For GOARCH=mips64 or mips64le, |
| 2117 |
// GOMIPS64=hardfloat and softfloat |
| 2118 |
// correspond to the mips64.hardfloat and mips64.softfloat |
| 2119 |
// (or mips64le.hardfloat and mips64le.softfloat) feature build tags. |
| 2120 |
// - For GOARCH=ppc64 or ppc64le, |
| 2121 |
// GOPPC64=power8, power9, and power10 correspond to the |
| 2122 |
// ppc64.power8, ppc64.power9, and ppc64.power10 |
| 2123 |
// (or ppc64le.power8, ppc64le.power9, and ppc64le.power10) |
| 2124 |
// feature build tags. |
| 2125 |
// - For GOARCH=riscv64, |
| 2126 |
// GORISCV64=rva20u64, rva22u64 and rva23u64 correspond to the riscv64.rva20u64, |
| 2127 |
// riscv64.rva22u64 and riscv64.rva23u64 build tags. |
| 2128 |
// - For GOARCH=wasm, GOWASM=satconv and signext |
| 2129 |
// correspond to the wasm.satconv and wasm.signext feature build tags. |
| 2130 |
// |
| 2131 |
// For GOARCH=amd64, arm, ppc64, ppc64le, and riscv64, a particular feature level |
| 2132 |
// sets the feature build tags for all previous levels as well. |
| 2133 |
// For example, GOAMD64=v2 sets the amd64.v1 and amd64.v2 feature flags. |
| 2134 |
// This ensures that code making use of v2 features continues to compile |
| 2135 |
// when, say, GOAMD64=v4 is introduced. |
| 2136 |
// Code handling the absence of a particular feature level |
| 2137 |
// should use a negation: |
| 2138 |
// |
| 2139 |
// //go:build !amd64.v2 |
| 2140 |
// |
| 2141 |
// To keep a file from being considered for any build: |
| 2142 |
// |
| 2143 |
// //go:build ignore |
| 2144 |
// |
| 2145 |
// (Any other unsatisfied word will work as well, but "ignore" is conventional.) |
| 2146 |
// |
| 2147 |
// To build a file only when using cgo, and only on Linux and OS X: |
| 2148 |
// |
| 2149 |
// //go:build cgo && (linux || darwin) |
| 2150 |
// |
| 2151 |
// Such a file is usually paired with another file implementing the |
| 2152 |
// default functionality for other systems, which in this case would |
| 2153 |
// carry the constraint: |
| 2154 |
// |
| 2155 |
// //go:build !(cgo && (linux || darwin)) |
| 2156 |
// |
| 2157 |
// Naming a file dns_windows.go will cause it to be included only when |
| 2158 |
// building the package for Windows; similarly, math_386.s will be included |
| 2159 |
// only when building the package for 32-bit x86. |
| 2160 |
// |
| 2161 |
// Go versions 1.16 and earlier used a different syntax for build constraints, |
| 2162 |
// with a "// +build" prefix. The gofmt command will add an equivalent //go:build |
| 2163 |
// constraint when encountering the older syntax. |
| 2164 |
// |
| 2165 |
// In modules with a Go version of 1.21 or later, if a file's build constraint |
| 2166 |
// has a term for a Go major release, the language version used when compiling |
| 2167 |
// the file will be the minimum version implied by the build constraint. |
| 2168 |
// |
| 2169 |
// # Build -json encoding |
| 2170 |
// |
| 2171 |
// The 'go build', 'go install', and 'go test' commands take a -json flag that |
| 2172 |
// reports build output and failures as structured JSON output on standard |
| 2173 |
// output. |
| 2174 |
// |
| 2175 |
// The JSON stream is a newline-separated sequence of BuildEvent objects |
| 2176 |
// corresponding to the Go struct: |
| 2177 |
// |
| 2178 |
// type BuildEvent struct { |
| 2179 |
// ImportPath string |
| 2180 |
// Action string |
| 2181 |
// Output string |
| 2182 |
// } |
| 2183 |
// |
| 2184 |
// The ImportPath field gives the package ID of the package being built. |
| 2185 |
// This matches the Package.ImportPath field of go list -json and the |
| 2186 |
// TestEvent.FailedBuild field of go test -json. Note that it does not |
| 2187 |
// match TestEvent.Package. |
| 2188 |
// |
| 2189 |
// The Action field is one of the following: |
| 2190 |
// |
| 2191 |
// build-output - The toolchain printed output |
| 2192 |
// build-fail - The build failed |
| 2193 |
// |
| 2194 |
// The Output field is set for Action == "build-output" and is a portion of |
| 2195 |
// the build's output. The concatenation of the Output fields of all output |
| 2196 |
// events is the exact output of the build. A single event may contain one |
| 2197 |
// or more lines of output and there may be more than one output event for |
| 2198 |
// a given ImportPath. This matches the definition of the TestEvent.Output |
| 2199 |
// field produced by go test -json. |
| 2200 |
// |
| 2201 |
// For go test -json, this struct is designed so that parsers can distinguish |
| 2202 |
// interleaved TestEvents and BuildEvents by inspecting the Action field. |
| 2203 |
// Furthermore, as with TestEvent, parsers can simply concatenate the Output |
| 2204 |
// fields of all events to reconstruct the text format output, as it would |
| 2205 |
// have appeared from go build without the -json flag. |
| 2206 |
// |
| 2207 |
// Note that there may also be non-JSON error text on standard error, even |
| 2208 |
// with the -json flag. Typically, this indicates an early, serious error. |
| 2209 |
// Consumers should be robust to this. |
| 2210 |
// |
| 2211 |
// # Build modes |
| 2212 |
// |
| 2213 |
// The 'go build' and 'go install' commands take a -buildmode argument which |
| 2214 |
// indicates which kind of object file is to be built. Currently supported values |
| 2215 |
// are: |
| 2216 |
// |
| 2217 |
// -buildmode=archive |
| 2218 |
// Build the listed non-main packages into .a files. Packages named |
| 2219 |
// main are ignored. |
| 2220 |
// |
| 2221 |
// -buildmode=c-archive |
| 2222 |
// Build the listed main package, plus all packages it imports, |
| 2223 |
// into a C archive file. The only callable symbols will be those |
| 2224 |
// functions exported using a cgo //export comment. Requires |
| 2225 |
// exactly one main package to be listed. |
| 2226 |
// |
| 2227 |
// -buildmode=c-shared |
| 2228 |
// Build the listed main package, plus all packages it imports, |
| 2229 |
// into a C shared library. The only callable symbols will |
| 2230 |
// be those functions exported using a cgo //export comment. |
| 2231 |
// On wasip1, this mode builds it to a WASI reactor/library, |
| 2232 |
// of which the callable symbols are those functions exported |
| 2233 |
// using a //go:wasmexport directive. Requires exactly one |
| 2234 |
// main package to be listed. |
| 2235 |
// |
| 2236 |
// -buildmode=default |
| 2237 |
// Listed main packages are built into executables and listed |
| 2238 |
// non-main packages are built into .a files (the default |
| 2239 |
// behavior). |
| 2240 |
// |
| 2241 |
// -buildmode=shared |
| 2242 |
// Combine all the listed non-main packages into a single shared |
| 2243 |
// library that will be used when building with the -linkshared |
| 2244 |
// option. Packages named main are ignored. |
| 2245 |
// |
| 2246 |
// -buildmode=exe |
| 2247 |
// Build the listed main packages and everything they import into |
| 2248 |
// executables. Packages not named main are ignored. |
| 2249 |
// |
| 2250 |
// -buildmode=pie |
| 2251 |
// Build the listed main packages and everything they import into |
| 2252 |
// position independent executables (PIE). Packages not named |
| 2253 |
// main are ignored. |
| 2254 |
// |
| 2255 |
// -buildmode=plugin |
| 2256 |
// Build the listed main packages, plus all packages that they |
| 2257 |
// import, into a Go plugin. Packages not named main are ignored. |
| 2258 |
// |
| 2259 |
// On AIX, when linking a C program that uses a Go archive built with |
| 2260 |
// -buildmode=c-archive, you must pass -Wl,-bnoobjreorder to the C compiler. |
| 2261 |
// |
| 2262 |
// # Calling between Go and C |
| 2263 |
// |
| 2264 |
// There are two different ways to call between Go and C/C++ code. |
| 2265 |
// |
| 2266 |
// The first is the cgo tool, which is part of the Go distribution. For |
| 2267 |
// information on how to use it see the cgo documentation (go doc cmd/cgo). |
| 2268 |
// |
| 2269 |
// The second is the SWIG program, which is a general tool for |
| 2270 |
// interfacing between languages. For information on SWIG see |
| 2271 |
// https://swig.org/. When running go build, any file with a .swig |
| 2272 |
// extension will be passed to SWIG. Any file with a .swigcxx extension |
| 2273 |
// will be passed to SWIG with the -c++ option. A package can't be just |
| 2274 |
// a .swig or .swigcxx file; there must be at least one .go file, even if |
| 2275 |
// it has just a package clause. |
| 2276 |
// |
| 2277 |
// When either cgo or SWIG is used, go build will pass any .c, .m, .s, .S |
| 2278 |
// or .sx files to the C compiler, and any .cc, .cpp, .cxx files to the C++ |
| 2279 |
// compiler. The CC or CXX environment variables may be set to determine |
| 2280 |
// the C or C++ compiler, respectively, to use. |
| 2281 |
// |
| 2282 |
// # Build and test caching |
| 2283 |
// |
| 2284 |
// The go command caches build outputs for reuse in future builds. |
| 2285 |
// The default location for cache data is a subdirectory named go-build |
| 2286 |
// in the standard user cache directory for the current operating system. |
| 2287 |
// The cache is safe for concurrent invocations of the go command. |
| 2288 |
// Setting the GOCACHE environment variable overrides this default, |
| 2289 |
// and running 'go env GOCACHE' prints the current cache directory. |
| 2290 |
// |
| 2291 |
// The go command periodically deletes cached data that has not been |
| 2292 |
// used recently. Running 'go clean -cache' deletes all cached data. |
| 2293 |
// |
| 2294 |
// The build cache correctly accounts for changes to Go source files, |
| 2295 |
// compilers, compiler options, and so on: cleaning the cache explicitly |
| 2296 |
// should not be necessary in typical use. However, the build cache |
| 2297 |
// does not detect changes to C libraries imported with cgo. |
| 2298 |
// If you have made changes to the C libraries on your system, you |
| 2299 |
// will need to clean the cache explicitly or else use the -a build flag |
| 2300 |
// (see 'go help build') to force rebuilding of packages that |
| 2301 |
// depend on the updated C libraries. |
| 2302 |
// |
| 2303 |
// The go command also caches successful package test results. |
| 2304 |
// See 'go help test' for details. Running 'go clean -testcache' removes |
| 2305 |
// all cached test results (but not cached build results). |
| 2306 |
// |
| 2307 |
// The go command also caches values used in fuzzing with 'go test -fuzz', |
| 2308 |
// specifically, values that expanded code coverage when passed to a |
| 2309 |
// fuzz function. These values are not used for regular building and |
| 2310 |
// testing, but they're stored in a subdirectory of the build cache. |
| 2311 |
// Running 'go clean -fuzzcache' removes all cached fuzzing values. |
| 2312 |
// This may make fuzzing less effective, temporarily. |
| 2313 |
// |
| 2314 |
// The GODEBUG environment variable can enable printing of debugging |
| 2315 |
// information about the state of the cache: |
| 2316 |
// |
| 2317 |
// GODEBUG=gocacheverify=1 causes the go command to bypass the |
| 2318 |
// use of any cache entries and instead rebuild everything and check |
| 2319 |
// that the results match existing cache entries. |
| 2320 |
// |
| 2321 |
// GODEBUG=gocachehash=1 causes the go command to print the inputs |
| 2322 |
// for all of the content hashes it uses to construct cache lookup keys. |
| 2323 |
// The output is voluminous but can be useful for debugging the cache. |
| 2324 |
// |
| 2325 |
// GODEBUG=gocachetest=1 causes the go command to print details of its |
| 2326 |
// decisions about whether to reuse a cached test result. |
| 2327 |
// |
| 2328 |
// # Environment variables |
| 2329 |
// |
| 2330 |
// The go command and the tools it invokes consult environment variables |
| 2331 |
// for configuration. If an environment variable is unset or empty, the go |
| 2332 |
// command uses a sensible default setting. To see the effective setting of |
| 2333 |
// the variable <NAME>, run 'go env <NAME>'. To change the default setting, |
| 2334 |
// run 'go env -w <NAME>=<VALUE>'. Defaults changed using 'go env -w' |
| 2335 |
// are recorded in a Go environment configuration file stored in the |
| 2336 |
// per-user configuration directory, as reported by os.UserConfigDir. |
| 2337 |
// The location of the configuration file can be changed by setting |
| 2338 |
// the environment variable GOENV, and 'go env GOENV' prints the |
| 2339 |
// effective location, but 'go env -w' cannot change the default location. |
| 2340 |
// See 'go help env' for details. |
| 2341 |
// |
| 2342 |
// General-purpose environment variables: |
| 2343 |
// |
| 2344 |
// GCCGO |
| 2345 |
// The gccgo command to run for 'go build -compiler=gccgo'. |
| 2346 |
// GO111MODULE |
| 2347 |
// Controls whether the go command runs in module-aware mode or GOPATH mode. |
| 2348 |
// May be "off", "on", or "auto". |
| 2349 |
// See https://golang.org/ref/mod#mod-commands. |
| 2350 |
// GOARCH |
| 2351 |
// The architecture, or processor, for which to compile code. |
| 2352 |
// Examples are amd64, 386, arm, ppc64. |
| 2353 |
// GOAUTH |
| 2354 |
// Controls authentication for go-import and HTTPS module mirror interactions. |
| 2355 |
// See 'go help goauth'. |
| 2356 |
// GOBIN |
| 2357 |
// The directory where 'go install' will install a command. |
| 2358 |
// GOCACHE |
| 2359 |
// The directory where the go command will store cached |
| 2360 |
// information for reuse in future builds. Must be an absolute path. |
| 2361 |
// GOCACHEPROG |
| 2362 |
// A command (with optional space-separated flags) that implements an |
| 2363 |
// external go command build cache. |
| 2364 |
// See 'go doc cmd/go/internal/cacheprog'. |
| 2365 |
// GODEBUG |
| 2366 |
// Enable various debugging facilities for programs built with Go, |
| 2367 |
// including the go command. Cannot be set using 'go env -w'. |
| 2368 |
// See https://go.dev/doc/godebug for details. |
| 2369 |
// GOENV |
| 2370 |
// The location of the Go environment configuration file. |
| 2371 |
// Cannot be set using 'go env -w'. |
| 2372 |
// Setting GOENV=off in the environment disables the use of the |
| 2373 |
// default configuration file. |
| 2374 |
// GOFLAGS |
| 2375 |
// A space-separated list of -flag=value settings to apply |
| 2376 |
// to go commands by default, when the given flag is known by |
| 2377 |
// the current command. Each entry must be a standalone flag. |
| 2378 |
// Because the entries are space-separated, flag values must |
| 2379 |
// not contain spaces. Flags listed on the command line |
| 2380 |
// are applied after this list and therefore override it. |
| 2381 |
// GOINSECURE |
| 2382 |
// Comma-separated list of glob patterns (in the syntax of Go's path.Match) |
| 2383 |
// of module path prefixes that should always be fetched in an insecure |
| 2384 |
// manner. Only applies to dependencies that are being fetched directly. |
| 2385 |
// GOINSECURE does not disable checksum database validation. GOPRIVATE or |
| 2386 |
// GONOSUMDB may be used to achieve that. |
| 2387 |
// GOMODCACHE |
| 2388 |
// The directory where the go command will store downloaded modules. |
| 2389 |
// GOOS |
| 2390 |
// The operating system for which to compile code. |
| 2391 |
// Examples are linux, darwin, windows, netbsd. |
| 2392 |
// GOPATH |
| 2393 |
// Controls where various files are stored. See: 'go help gopath'. |
| 2394 |
// GOPRIVATE, GONOPROXY, GONOSUMDB |
| 2395 |
// Comma-separated list of glob patterns (in the syntax of Go's path.Match) |
| 2396 |
// of module path prefixes that should always be fetched directly |
| 2397 |
// or that should not be compared against the checksum database. |
| 2398 |
// See https://golang.org/ref/mod#private-modules. |
| 2399 |
// GOPROXY |
| 2400 |
// URL of Go module proxy. See https://golang.org/ref/mod#environment-variables |
| 2401 |
// and https://golang.org/ref/mod#module-proxy for details. |
| 2402 |
// GOROOT |
| 2403 |
// The root of the go tree. |
| 2404 |
// GOSUMDB |
| 2405 |
// The name of checksum database to use and optionally its public key and |
| 2406 |
// URL. See https://golang.org/ref/mod#authenticating. |
| 2407 |
// GOTMPDIR |
| 2408 |
// The directory where the go command will write |
| 2409 |
// temporary source files, packages, and binaries. |
| 2410 |
// GOTOOLCHAIN |
| 2411 |
// Controls which Go toolchain is used. See https://go.dev/doc/toolchain. |
| 2412 |
// GOVCS |
| 2413 |
// Lists version control commands that may be used with matching servers. |
| 2414 |
// See 'go help vcs'. |
| 2415 |
// GOWORK |
| 2416 |
// In module aware mode, use the given go.work file as a workspace file. |
| 2417 |
// By default or when GOWORK is "auto", the go command searches for a |
| 2418 |
// file named go.work in the current directory and then containing directories |
| 2419 |
// until one is found. If a valid go.work file is found, the modules |
| 2420 |
// specified will collectively be used as the main modules. If GOWORK |
| 2421 |
// is "off", or a go.work file is not found in "auto" mode, workspace |
| 2422 |
// mode is disabled. |
| 2423 |
// |
| 2424 |
// Environment variables for use with cgo: |
| 2425 |
// |
| 2426 |
// AR |
| 2427 |
// The command to use to manipulate library archives when |
| 2428 |
// building with the gccgo compiler. |
| 2429 |
// The default is 'ar'. |
| 2430 |
// CC |
| 2431 |
// The command to use to compile C code. |
| 2432 |
// CGO_CFLAGS |
| 2433 |
// Flags that cgo will pass to the compiler when compiling |
| 2434 |
// C code. |
| 2435 |
// CGO_CFLAGS_ALLOW |
| 2436 |
// A regular expression specifying additional flags to allow |
| 2437 |
// to appear in #cgo CFLAGS source code directives. |
| 2438 |
// Does not apply to the CGO_CFLAGS environment variable. |
| 2439 |
// CGO_CFLAGS_DISALLOW |
| 2440 |
// A regular expression specifying flags that must be disallowed |
| 2441 |
// from appearing in #cgo CFLAGS source code directives. |
| 2442 |
// Does not apply to the CGO_CFLAGS environment variable. |
| 2443 |
// CGO_CPPFLAGS, CGO_CPPFLAGS_ALLOW, CGO_CPPFLAGS_DISALLOW |
| 2444 |
// Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW, |
| 2445 |
// but for the C preprocessor. |
| 2446 |
// CGO_CXXFLAGS, CGO_CXXFLAGS_ALLOW, CGO_CXXFLAGS_DISALLOW |
| 2447 |
// Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW, |
| 2448 |
// but for the C++ compiler. |
| 2449 |
// CGO_ENABLED |
| 2450 |
// Whether the cgo command is supported. Either 0 or 1. |
| 2451 |
// CGO_FFLAGS, CGO_FFLAGS_ALLOW, CGO_FFLAGS_DISALLOW |
| 2452 |
// Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW, |
| 2453 |
// but for the Fortran compiler. |
| 2454 |
// CGO_LDFLAGS, CGO_LDFLAGS_ALLOW, CGO_LDFLAGS_DISALLOW |
| 2455 |
// Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW, |
| 2456 |
// but for the linker. |
| 2457 |
// CXX |
| 2458 |
// The command to use to compile C++ code. |
| 2459 |
// FC |
| 2460 |
// The command to use to compile Fortran code. |
| 2461 |
// PKG_CONFIG |
| 2462 |
// Path to pkg-config tool. |
| 2463 |
// |
| 2464 |
// Architecture-specific environment variables: |
| 2465 |
// |
| 2466 |
// GO386 |
| 2467 |
// For GOARCH=386, how to implement floating point instructions. |
| 2468 |
// Valid values are sse2 (default), softfloat. |
| 2469 |
// GOAMD64 |
| 2470 |
// For GOARCH=amd64, the microarchitecture level for which to compile. |
| 2471 |
// Valid values are v1 (default), v2, v3, v4. |
| 2472 |
// See https://golang.org/wiki/MinimumRequirements#amd64 |
| 2473 |
// GOARM |
| 2474 |
// For GOARCH=arm, the ARM architecture for which to compile. |
| 2475 |
// Valid values are 5, 6, 7. |
| 2476 |
// When the Go tools are built on an arm system, |
| 2477 |
// the default value is set based on what the build system supports. |
| 2478 |
// When the Go tools are not built on an arm system |
| 2479 |
// (that is, when building a cross-compiler), |
| 2480 |
// the default value is 7. |
| 2481 |
// The value can be followed by an option specifying how to implement floating point instructions. |
| 2482 |
// Valid options are ,softfloat (default for 5) and ,hardfloat (default for 6 and 7). |
| 2483 |
// GOARM64 |
| 2484 |
// For GOARCH=arm64, the ARM64 architecture for which to compile. |
| 2485 |
// Valid values are v8.0 (default), v8.{1-9}, v9.{0-5}. |
| 2486 |
// The value can be followed by an option specifying extensions implemented by target hardware. |
| 2487 |
// Valid options are ,lse and ,crypto. |
| 2488 |
// Note that some extensions are enabled by default starting from a certain GOARM64 version; |
| 2489 |
// for example, lse is enabled by default starting from v8.1. |
| 2490 |
// GOMIPS |
| 2491 |
// For GOARCH=mips{,le}, whether to use floating point instructions. |
| 2492 |
// Valid values are hardfloat (default), softfloat. |
| 2493 |
// GOMIPS64 |
| 2494 |
// For GOARCH=mips64{,le}, whether to use floating point instructions. |
| 2495 |
// Valid values are hardfloat (default), softfloat. |
| 2496 |
// GOPPC64 |
| 2497 |
// For GOARCH=ppc64{,le}, the target ISA (Instruction Set Architecture). |
| 2498 |
// Valid values are power8 (default), power9, power10. |
| 2499 |
// GORISCV64 |
| 2500 |
// For GOARCH=riscv64, the RISC-V user-mode application profile for which |
| 2501 |
// to compile. Valid values are rva20u64 (default), rva22u64, rva23u64. |
| 2502 |
// See https://github.com/riscv/riscv-profiles/blob/main/src/profiles.adoc |
| 2503 |
// and https://github.com/riscv/riscv-profiles/blob/main/src/rva23-profile.adoc |
| 2504 |
// GOWASM |
| 2505 |
// For GOARCH=wasm, comma-separated list of experimental WebAssembly features to use. |
| 2506 |
// Valid values are satconv, signext. |
| 2507 |
// |
| 2508 |
// Environment variables for use with code coverage: |
| 2509 |
// |
| 2510 |
// GOCOVERDIR |
| 2511 |
// Directory into which to write code coverage data files |
| 2512 |
// generated by running a "go build -cover" binary. |
| 2513 |
// |
| 2514 |
// Special-purpose environment variables: |
| 2515 |
// |
| 2516 |
// GCCGOTOOLDIR |
| 2517 |
// If set, where to find gccgo tools, such as cgo. |
| 2518 |
// The default is based on how gccgo was configured. |
| 2519 |
// GOEXPERIMENT |
| 2520 |
// Comma-separated list of toolchain experiments to enable or disable. |
| 2521 |
// The list of available experiments may change arbitrarily over time. |
| 2522 |
// See GOROOT/src/internal/goexperiment/flags.go for currently valid values. |
| 2523 |
// Warning: This variable is provided for the development and testing |
| 2524 |
// of the Go toolchain itself. Use beyond that purpose is unsupported. |
| 2525 |
// GOFIPS140 |
| 2526 |
// The FIPS-140 cryptography mode to use when building binaries. |
| 2527 |
// The default is GOFIPS140=off, which makes no FIPS-140 changes at all. |
| 2528 |
// Other values enable FIPS-140 compliance measures and select alternate |
| 2529 |
// versions of the cryptography source code. |
| 2530 |
// See https://go.dev/security/fips140 for details. |
| 2531 |
// GO_EXTLINK_ENABLED |
| 2532 |
// Whether the linker should use external linking mode |
| 2533 |
// when using -linkmode=auto with code that uses cgo. |
| 2534 |
// Set to 0 to disable external linking mode, 1 to enable it. |
| 2535 |
// GIT_ALLOW_PROTOCOL |
| 2536 |
// Defined by Git. A colon-separated list of schemes that are allowed |
| 2537 |
// to be used with git fetch/clone. If set, any scheme not explicitly |
| 2538 |
// mentioned will be considered insecure by 'go get'. |
| 2539 |
// Because the variable is defined by Git, the default value cannot |
| 2540 |
// be set using 'go env -w'. |
| 2541 |
// |
| 2542 |
// Additional information available from 'go env' but not read from the environment: |
| 2543 |
// |
| 2544 |
// GOEXE |
| 2545 |
// The executable file name suffix (".exe" on Windows, "" on other systems). |
| 2546 |
// GOGCCFLAGS |
| 2547 |
// A space-separated list of arguments supplied to the CC command. |
| 2548 |
// GOHOSTARCH |
| 2549 |
// The architecture (GOARCH) of the Go toolchain binaries. |
| 2550 |
// GOHOSTOS |
| 2551 |
// The operating system (GOOS) of the Go toolchain binaries. |
| 2552 |
// GOMOD |
| 2553 |
// The absolute path to the go.mod of the main module. |
| 2554 |
// If module-aware mode is enabled, but there is no go.mod, GOMOD will be |
| 2555 |
// os.DevNull ("/dev/null" on Unix-like systems, "NUL" on Windows). |
| 2556 |
// If module-aware mode is disabled, GOMOD will be the empty string. |
| 2557 |
// GOTELEMETRY |
| 2558 |
// The current Go telemetry mode ("off", "local", or "on"). |
| 2559 |
// See "go help telemetry" for more information. |
| 2560 |
// GOTELEMETRYDIR |
| 2561 |
// The directory Go telemetry data is written is written to. |
| 2562 |
// GOTOOLDIR |
| 2563 |
// The directory where the go tools (compile, cover, doc, etc...) are installed. |
| 2564 |
// GOVERSION |
| 2565 |
// The version of the installed Go tree, as reported by runtime.Version. |
| 2566 |
// |
| 2567 |
// # File types |
| 2568 |
// |
| 2569 |
// The go command examines the contents of a restricted set of files |
| 2570 |
// in each directory. It identifies which files to examine based on |
| 2571 |
// the extension of the file name. These extensions are: |
| 2572 |
// |
| 2573 |
// .go |
| 2574 |
// Go source files. |
| 2575 |
// .c, .h |
| 2576 |
// C source files. |
| 2577 |
// If the package uses cgo or SWIG, these will be compiled with the |
| 2578 |
// OS-native compiler (typically gcc); otherwise they will |
| 2579 |
// trigger an error. |
| 2580 |
// .cc, .cpp, .cxx, .hh, .hpp, .hxx |
| 2581 |
// C++ source files. Only useful with cgo or SWIG, and always |
| 2582 |
// compiled with the OS-native compiler. |
| 2583 |
// .m |
| 2584 |
// Objective-C source files. Only useful with cgo, and always |
| 2585 |
// compiled with the OS-native compiler. |
| 2586 |
// .s, .S, .sx |
| 2587 |
// Assembler source files. |
| 2588 |
// If the package uses cgo or SWIG, these will be assembled with the |
| 2589 |
// OS-native assembler (typically gcc (sic)); otherwise they |
| 2590 |
// will be assembled with the Go assembler. |
| 2591 |
// .swig, .swigcxx |
| 2592 |
// SWIG definition files. |
| 2593 |
// .syso |
| 2594 |
// System object files. |
| 2595 |
// |
| 2596 |
// Files of each of these types except .syso may contain build |
| 2597 |
// constraints, but the go command stops scanning for build constraints |
| 2598 |
// at the first item in the file that is not a blank line or //-style |
| 2599 |
// line comment. See the go/build package documentation for |
| 2600 |
// more details. |
| 2601 |
// |
| 2602 |
// # GOAUTH environment variable |
| 2603 |
// |
| 2604 |
// GOAUTH is a semicolon-separated list of authentication commands for go-import and |
| 2605 |
// HTTPS module mirror interactions. The default is netrc. |
| 2606 |
// |
| 2607 |
// The supported authentication commands are: |
| 2608 |
// |
| 2609 |
// off |
| 2610 |
// |
| 2611 |
// Disables authentication. |
| 2612 |
// |
| 2613 |
// netrc |
| 2614 |
// |
| 2615 |
// Uses credentials from NETRC or the .netrc file in your home directory. |
| 2616 |
// |
| 2617 |
// git dir |
| 2618 |
// |
| 2619 |
// Runs 'git credential fill' in dir and uses its credentials. The |
| 2620 |
// go command will run 'git credential approve/reject' to update |
| 2621 |
// the credential helper's cache. |
| 2622 |
// |
| 2623 |
// command |
| 2624 |
// |
| 2625 |
// Executes the given command (a space-separated argument list) and attaches |
| 2626 |
// the provided headers to HTTPS requests. |
| 2627 |
// The command must produce output in the following format: |
| 2628 |
// Response = { CredentialSet } . |
| 2629 |
// CredentialSet = URLLine { URLLine } BlankLine { HeaderLine } BlankLine . |
| 2630 |
// URLLine = /* URL that starts with "https://" */ '\n' . |
| 2631 |
// HeaderLine = /* HTTP Request header */ '\n' . |
| 2632 |
// BlankLine = '\n' . |
| 2633 |
// |
| 2634 |
// Example: |
| 2635 |
// https://example.com |
| 2636 |
// https://example.net/api/ |
| 2637 |
// |
| 2638 |
// Authorization: Basic <token> |
| 2639 |
// |
| 2640 |
// https://another-example.org/ |
| 2641 |
// |
| 2642 |
// Example: Data |
| 2643 |
// |
| 2644 |
// If the server responds with any 4xx code, the go command will write the |
| 2645 |
// following to the program's stdin: |
| 2646 |
// Response = StatusLine { HeaderLine } BlankLine . |
| 2647 |
// StatusLine = Protocol Space Status '\n' . |
| 2648 |
// Protocol = /* HTTP protocol */ . |
| 2649 |
// Space = ' ' . |
| 2650 |
// Status = /* HTTP status code */ . |
| 2651 |
// BlankLine = '\n' . |
| 2652 |
// HeaderLine = /* HTTP Response's header */ '\n' . |
| 2653 |
// |
| 2654 |
// Example: |
| 2655 |
// HTTP/1.1 401 Unauthorized |
| 2656 |
// Content-Length: 19 |
| 2657 |
// Content-Type: text/plain; charset=utf-8 |
| 2658 |
// Date: Thu, 07 Nov 2024 18:43:09 GMT |
| 2659 |
// |
| 2660 |
// Note: it is safe to use net/http.ReadResponse to parse this input. |
| 2661 |
// |
| 2662 |
// Before the first HTTPS fetch, the go command will invoke each GOAUTH |
| 2663 |
// command in the list with no additional arguments and no input. |
| 2664 |
// If the server responds with any 4xx code, the go command will invoke the |
| 2665 |
// GOAUTH commands again with the URL as an additional command-line argument |
| 2666 |
// and the HTTP Response to the program's stdin. |
| 2667 |
// If the server responds with an error again, the fetch fails: a URL-specific |
| 2668 |
// GOAUTH will only be attempted once per fetch. |
| 2669 |
// |
| 2670 |
// # The go.mod file |
| 2671 |
// |
| 2672 |
// A module version is defined by a tree of source files, with a go.mod |
| 2673 |
// file in its root. When the go command is run, it looks in the current |
| 2674 |
// directory and then successive parent directories to find the go.mod |
| 2675 |
// marking the root of the main (current) module. |
| 2676 |
// |
| 2677 |
// The go.mod file format is described in detail at |
| 2678 |
// https://golang.org/ref/mod#go-mod-file. |
| 2679 |
// |
| 2680 |
// To create a new go.mod file, use 'go mod init'. For details see |
| 2681 |
// 'go help mod init' or https://golang.org/ref/mod#go-mod-init. |
| 2682 |
// |
| 2683 |
// To add missing module requirements or remove unneeded requirements, |
| 2684 |
// use 'go mod tidy'. For details, see 'go help mod tidy' or |
| 2685 |
// https://golang.org/ref/mod#go-mod-tidy. |
| 2686 |
// |
| 2687 |
// To add, upgrade, downgrade, or remove a specific module requirement, use |
| 2688 |
// 'go get'. For details, see 'go help module-get' or |
| 2689 |
// https://golang.org/ref/mod#go-get. |
| 2690 |
// |
| 2691 |
// To make other changes or to parse go.mod as JSON for use by other tools, |
| 2692 |
// use 'go mod edit'. See 'go help mod edit' or |
| 2693 |
// https://golang.org/ref/mod#go-mod-edit. |
| 2694 |
// |
| 2695 |
// # GOPATH environment variable |
| 2696 |
// |
| 2697 |
// The Go path is used to resolve import statements. |
| 2698 |
// It is implemented by and documented in the go/build package. |
| 2699 |
// |
| 2700 |
// The GOPATH environment variable lists places to look for Go code. |
| 2701 |
// On Unix, the value is a colon-separated string. |
| 2702 |
// On Windows, the value is a semicolon-separated string. |
| 2703 |
// On Plan 9, the value is a list. |
| 2704 |
// |
| 2705 |
// If the environment variable is unset, GOPATH defaults |
| 2706 |
// to a subdirectory named "go" in the user's home directory |
| 2707 |
// ($HOME/go on Unix, %USERPROFILE%\go on Windows), |
| 2708 |
// unless that directory holds a Go distribution. |
| 2709 |
// Run "go env GOPATH" to see the current GOPATH. |
| 2710 |
// |
| 2711 |
// See https://golang.org/wiki/SettingGOPATH to set a custom GOPATH. |
| 2712 |
// |
| 2713 |
// Each directory listed in GOPATH must have a prescribed structure: |
| 2714 |
// |
| 2715 |
// The src directory holds source code. The path below src |
| 2716 |
// determines the import path or executable name. |
| 2717 |
// |
| 2718 |
// The pkg directory holds installed package objects. |
| 2719 |
// As in the Go tree, each target operating system and |
| 2720 |
// architecture pair has its own subdirectory of pkg |
| 2721 |
// (pkg/GOOS_GOARCH). |
| 2722 |
// |
| 2723 |
// If DIR is a directory listed in the GOPATH, a package with |
| 2724 |
// source in DIR/src/foo/bar can be imported as "foo/bar" and |
| 2725 |
// has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a". |
| 2726 |
// |
| 2727 |
// The bin directory holds compiled commands. |
| 2728 |
// Each command is named for its source directory, but only |
| 2729 |
// the final element, not the entire path. That is, the |
| 2730 |
// command with source in DIR/src/foo/quux is installed into |
| 2731 |
// DIR/bin/quux, not DIR/bin/foo/quux. The "foo/" prefix is stripped |
| 2732 |
// so that you can add DIR/bin to your PATH to get at the |
| 2733 |
// installed commands. If the GOBIN environment variable is |
| 2734 |
// set, commands are installed to the directory it names instead |
| 2735 |
// of DIR/bin. GOBIN must be an absolute path. |
| 2736 |
// |
| 2737 |
// Here's an example directory layout: |
| 2738 |
// |
| 2739 |
// GOPATH=/home/user/go |
| 2740 |
// |
| 2741 |
// /home/user/go/ |
| 2742 |
// src/ |
| 2743 |
// foo/ |
| 2744 |
// bar/ (go code in package bar) |
| 2745 |
// x.go |
| 2746 |
// quux/ (go code in package main) |
| 2747 |
// y.go |
| 2748 |
// bin/ |
| 2749 |
// quux (installed command) |
| 2750 |
// pkg/ |
| 2751 |
// linux_amd64/ |
| 2752 |
// foo/ |
| 2753 |
// bar.a (installed package object) |
| 2754 |
// |
| 2755 |
// Go searches each directory listed in GOPATH to find source code, |
| 2756 |
// but new packages are always downloaded into the first directory |
| 2757 |
// in the list. |
| 2758 |
// |
| 2759 |
// See https://golang.org/doc/code.html for an example. |
| 2760 |
// |
| 2761 |
// # GOPATH and Modules |
| 2762 |
// |
| 2763 |
// When using modules, GOPATH is no longer used for resolving imports. |
| 2764 |
// However, it is still used to store downloaded source code (in GOPATH/pkg/mod) |
| 2765 |
// and compiled commands (in GOPATH/bin). |
| 2766 |
// |
| 2767 |
// # Internal Directories |
| 2768 |
// |
| 2769 |
// Code in or below a directory named "internal" is importable only |
| 2770 |
// by code in the directory tree rooted at the parent of "internal". |
| 2771 |
// Here's an extended version of the directory layout above: |
| 2772 |
// |
| 2773 |
// /home/user/go/ |
| 2774 |
// src/ |
| 2775 |
// crash/ |
| 2776 |
// bang/ (go code in package bang) |
| 2777 |
// b.go |
| 2778 |
// foo/ (go code in package foo) |
| 2779 |
// f.go |
| 2780 |
// bar/ (go code in package bar) |
| 2781 |
// x.go |
| 2782 |
// internal/ |
| 2783 |
// baz/ (go code in package baz) |
| 2784 |
// z.go |
| 2785 |
// quux/ (go code in package main) |
| 2786 |
// y.go |
| 2787 |
// |
| 2788 |
// The code in z.go is imported as "foo/internal/baz", but that |
| 2789 |
// import statement can only appear in source files in the subtree |
| 2790 |
// rooted at foo. The source files foo/f.go, foo/bar/x.go, and |
| 2791 |
// foo/quux/y.go can all import "foo/internal/baz", but the source file |
| 2792 |
// crash/bang/b.go cannot. |
| 2793 |
// |
| 2794 |
// See https://golang.org/s/go14internal for details. |
| 2795 |
// |
| 2796 |
// # Vendor Directories |
| 2797 |
// |
| 2798 |
// Go 1.6 includes support for using local copies of external dependencies |
| 2799 |
// to satisfy imports of those dependencies, often referred to as vendoring. |
| 2800 |
// |
| 2801 |
// Code below a directory named "vendor" is importable only |
| 2802 |
// by code in the directory tree rooted at the parent of "vendor", |
| 2803 |
// and only using an import path that omits the prefix up to and |
| 2804 |
// including the vendor element. |
| 2805 |
// |
| 2806 |
// Here's the example from the previous section, |
| 2807 |
// but with the "internal" directory renamed to "vendor" |
| 2808 |
// and a new foo/vendor/crash/bang directory added: |
| 2809 |
// |
| 2810 |
// /home/user/go/ |
| 2811 |
// src/ |
| 2812 |
// crash/ |
| 2813 |
// bang/ (go code in package bang) |
| 2814 |
// b.go |
| 2815 |
// foo/ (go code in package foo) |
| 2816 |
// f.go |
| 2817 |
// bar/ (go code in package bar) |
| 2818 |
// x.go |
| 2819 |
// vendor/ |
| 2820 |
// crash/ |
| 2821 |
// bang/ (go code in package bang) |
| 2822 |
// b.go |
| 2823 |
// baz/ (go code in package baz) |
| 2824 |
// z.go |
| 2825 |
// quux/ (go code in package main) |
| 2826 |
// y.go |
| 2827 |
// |
| 2828 |
// The same visibility rules apply as for internal, but the code |
| 2829 |
// in z.go is imported as "baz", not as "foo/vendor/baz". |
| 2830 |
// |
| 2831 |
// Code in vendor directories deeper in the source tree shadows |
| 2832 |
// code in higher directories. Within the subtree rooted at foo, an import |
| 2833 |
// of "crash/bang" resolves to "foo/vendor/crash/bang", not the |
| 2834 |
// top-level "crash/bang". |
| 2835 |
// |
| 2836 |
// Code in vendor directories is not subject to import path |
| 2837 |
// checking (see 'go help importpath'). |
| 2838 |
// |
| 2839 |
// When 'go get' checks out or updates a git repository, it now also |
| 2840 |
// updates submodules. |
| 2841 |
// |
| 2842 |
// Vendor directories do not affect the placement of new repositories |
| 2843 |
// being checked out for the first time by 'go get': those are always |
| 2844 |
// placed in the main GOPATH, never in a vendor subtree. |
| 2845 |
// |
| 2846 |
// See https://golang.org/s/go15vendor for details. |
| 2847 |
// |
| 2848 |
// # Module proxy protocol |
| 2849 |
// |
| 2850 |
// A Go module proxy is any web server that can respond to GET requests for |
| 2851 |
// URLs of a specified form. The requests have no query parameters, so even |
| 2852 |
// a site serving from a fixed file system (including a file:/// URL) |
| 2853 |
// can be a module proxy. |
| 2854 |
// |
| 2855 |
// For details on the GOPROXY protocol, see |
| 2856 |
// https://golang.org/ref/mod#goproxy-protocol. |
| 2857 |
// |
| 2858 |
// # Import path syntax |
| 2859 |
// |
| 2860 |
// An import path (see 'go help packages') denotes a package stored in the local |
| 2861 |
// file system. In general, an import path denotes either a standard package (such |
| 2862 |
// as "unicode/utf8") or a package found in one of the work spaces (For more |
| 2863 |
// details see: 'go help gopath'). |
| 2864 |
// |
| 2865 |
// # Relative import paths |
| 2866 |
// |
| 2867 |
// An import path beginning with ./ or ../ is called a relative path. |
| 2868 |
// The toolchain supports relative import paths as a shortcut in two ways. |
| 2869 |
// |
| 2870 |
// First, a relative path can be used as a shorthand on the command line. |
| 2871 |
// If you are working in the directory containing the code imported as |
| 2872 |
// "unicode" and want to run the tests for "unicode/utf8", you can type |
| 2873 |
// "go test ./utf8" instead of needing to specify the full path. |
| 2874 |
// Similarly, in the reverse situation, "go test .." will test "unicode" from |
| 2875 |
// the "unicode/utf8" directory. Relative patterns are also allowed, like |
| 2876 |
// "go test ./..." to test all subdirectories. See 'go help packages' for details |
| 2877 |
// on the pattern syntax. |
| 2878 |
// |
| 2879 |
// Second, if you are compiling a Go program not in a work space, |
| 2880 |
// you can use a relative path in an import statement in that program |
| 2881 |
// to refer to nearby code also not in a work space. |
| 2882 |
// This makes it easy to experiment with small multipackage programs |
| 2883 |
// outside of the usual work spaces, but such programs cannot be |
| 2884 |
// installed with "go install" (there is no work space in which to install them), |
| 2885 |
// so they are rebuilt from scratch each time they are built. |
| 2886 |
// To avoid ambiguity, Go programs cannot use relative import paths |
| 2887 |
// within a work space. |
| 2888 |
// |
| 2889 |
// # Remote import paths |
| 2890 |
// |
| 2891 |
// Certain import paths also |
| 2892 |
// describe how to obtain the source code for the package using |
| 2893 |
// a revision control system. |
| 2894 |
// |
| 2895 |
// A few common code hosting sites have special syntax: |
| 2896 |
// |
| 2897 |
// Bitbucket (Git, Mercurial) |
| 2898 |
// |
| 2899 |
// import "bitbucket.org/user/project" |
| 2900 |
// import "bitbucket.org/user/project/sub/directory" |
| 2901 |
// |
| 2902 |
// GitHub (Git) |
| 2903 |
// |
| 2904 |
// import "github.com/user/project" |
| 2905 |
// import "github.com/user/project/sub/directory" |
| 2906 |
// |
| 2907 |
// Launchpad (Bazaar) |
| 2908 |
// |
| 2909 |
// import "launchpad.net/project" |
| 2910 |
// import "launchpad.net/project/series" |
| 2911 |
// import "launchpad.net/project/series/sub/directory" |
| 2912 |
// |
| 2913 |
// import "launchpad.net/~user/project/branch" |
| 2914 |
// import "launchpad.net/~user/project/branch/sub/directory" |
| 2915 |
// |
| 2916 |
// IBM DevOps Services (Git) |
| 2917 |
// |
| 2918 |
// import "hub.jazz.net/git/user/project" |
| 2919 |
// import "hub.jazz.net/git/user/project/sub/directory" |
| 2920 |
// |
| 2921 |
// For code hosted on other servers, import paths may either be qualified |
| 2922 |
// with the version control type, or the go tool can dynamically fetch |
| 2923 |
// the import path over https/http and discover where the code resides |
| 2924 |
// from a <meta> tag in the HTML. |
| 2925 |
// |
| 2926 |
// To declare the code location, an import path of the form |
| 2927 |
// |
| 2928 |
// repository.vcs/path |
| 2929 |
// |
| 2930 |
// specifies the given repository, with or without the .vcs suffix, |
| 2931 |
// using the named version control system, and then the path inside |
| 2932 |
// that repository. The supported version control systems are: |
| 2933 |
// |
| 2934 |
// Bazaar .bzr |
| 2935 |
// Fossil .fossil |
| 2936 |
// Git .git |
| 2937 |
// Mercurial .hg |
| 2938 |
// Subversion .svn |
| 2939 |
// |
| 2940 |
// For example, |
| 2941 |
// |
| 2942 |
// import "example.org/user/foo.hg" |
| 2943 |
// |
| 2944 |
// denotes the root directory of the Mercurial repository at |
| 2945 |
// example.org/user/foo, and |
| 2946 |
// |
| 2947 |
// import "example.org/repo.git/foo/bar" |
| 2948 |
// |
| 2949 |
// denotes the foo/bar directory of the Git repository at |
| 2950 |
// example.org/repo. |
| 2951 |
// |
| 2952 |
// When a version control system supports multiple protocols, |
| 2953 |
// each is tried in turn when downloading. For example, a Git |
| 2954 |
// download tries https://, then git+ssh://. |
| 2955 |
// |
| 2956 |
// By default, downloads are restricted to known secure protocols |
| 2957 |
// (e.g. https, ssh). To override this setting for Git downloads, the |
| 2958 |
// GIT_ALLOW_PROTOCOL environment variable can be set (For more details see: |
| 2959 |
// 'go help environment'). |
| 2960 |
// |
| 2961 |
// If the import path is not a known code hosting site and also lacks a |
| 2962 |
// version control qualifier, the go tool attempts to fetch the import |
| 2963 |
// over https/http and looks for a <meta> tag in the document's HTML |
| 2964 |
// <head>. |
| 2965 |
// |
| 2966 |
// The meta tag has the form: |
| 2967 |
// |
| 2968 |
// <meta name="go-import" content="import-prefix vcs repo-root"> |
| 2969 |
// |
| 2970 |
// Starting in Go 1.25, an optional subdirectory will be recognized by the |
| 2971 |
// go command: |
| 2972 |
// |
| 2973 |
// <meta name="go-import" content="import-prefix vcs repo-root subdir"> |
| 2974 |
// |
| 2975 |
// The import-prefix is the import path corresponding to the repository |
| 2976 |
// root. It must be a prefix or an exact match of the package being |
| 2977 |
// fetched with "go get". If it's not an exact match, another http |
| 2978 |
// request is made at the prefix to verify the <meta> tags match. |
| 2979 |
// |
| 2980 |
// The meta tag should appear as early in the file as possible. |
| 2981 |
// In particular, it should appear before any raw JavaScript or CSS, |
| 2982 |
// to avoid confusing the go command's restricted parser. |
| 2983 |
// |
| 2984 |
// The vcs is one of "bzr", "fossil", "git", "hg", "svn". |
| 2985 |
// |
| 2986 |
// The repo-root is the root of the version control system |
| 2987 |
// containing a scheme and not containing a .vcs qualifier. |
| 2988 |
// |
| 2989 |
// The subdir specifies the directory within the repo-root where the |
| 2990 |
// Go module's root (including its go.mod file) is located. It allows |
| 2991 |
// you to organize your repository with the Go module code in a subdirectory |
| 2992 |
// rather than directly at the repository's root. |
| 2993 |
// If set, all vcs tags must be prefixed with "subdir". i.e. "subdir/v1.2.3" |
| 2994 |
// |
| 2995 |
// For example, |
| 2996 |
// |
| 2997 |
// import "example.org/pkg/foo" |
| 2998 |
// |
| 2999 |
// will result in the following requests: |
| 3000 |
// |
| 3001 |
// https://example.org/pkg/foo?go-get=1 (preferred) |
| 3002 |
// http://example.org/pkg/foo?go-get=1 (fallback, only with use of correctly set GOINSECURE) |
| 3003 |
// |
| 3004 |
// If that page contains the meta tag |
| 3005 |
// |
| 3006 |
// <meta name="go-import" content="example.org git https://code.org/r/p/exproj"> |
| 3007 |
// |
| 3008 |
// the go tool will verify that https://example.org/?go-get=1 contains the |
| 3009 |
// same meta tag and then download the code from the Git repository at https://code.org/r/p/exproj |
| 3010 |
// |
| 3011 |
// If that page contains the meta tag |
| 3012 |
// |
| 3013 |
// <meta name="go-import" content="example.org git https://code.org/r/p/exproj foo/subdir"> |
| 3014 |
// |
| 3015 |
// the go tool will verify that https://example.org/?go-get=1 contains the same meta |
| 3016 |
// tag and then download the code from the "foo/subdir" subdirectory within the Git repository |
| 3017 |
// at https://code.org/r/p/exproj |
| 3018 |
// |
| 3019 |
// Downloaded packages are stored in the module cache. |
| 3020 |
// See https://golang.org/ref/mod#module-cache. |
| 3021 |
// |
| 3022 |
// When using modules, an additional variant of the go-import meta tag is |
| 3023 |
// recognized and is preferred over those listing version control systems. |
| 3024 |
// That variant uses "mod" as the vcs in the content value, as in: |
| 3025 |
// |
| 3026 |
// <meta name="go-import" content="example.org mod https://code.org/moduleproxy"> |
| 3027 |
// |
| 3028 |
// This tag means to fetch modules with paths beginning with example.org |
| 3029 |
// from the module proxy available at the URL https://code.org/moduleproxy. |
| 3030 |
// See https://golang.org/ref/mod#goproxy-protocol for details about the |
| 3031 |
// proxy protocol. |
| 3032 |
// |
| 3033 |
// # Import path checking |
| 3034 |
// |
| 3035 |
// When the custom import path feature described above redirects to a |
| 3036 |
// known code hosting site, each of the resulting packages has two possible |
| 3037 |
// import paths, using the custom domain or the known hosting site. |
| 3038 |
// |
| 3039 |
// A package statement is said to have an "import comment" if it is immediately |
| 3040 |
// followed (before the next newline) by a comment of one of these two forms: |
| 3041 |
// |
| 3042 |
// package math // import "path" |
| 3043 |
// package math /* import "path" */ |
| 3044 |
// |
| 3045 |
// The go command will refuse to install a package with an import comment |
| 3046 |
// unless it is being referred to by that import path. In this way, import comments |
| 3047 |
// let package authors make sure the custom import path is used and not a |
| 3048 |
// direct path to the underlying code hosting site. |
| 3049 |
// |
| 3050 |
// Import path checking is disabled for code found within vendor trees. |
| 3051 |
// This makes it possible to copy code into alternate locations in vendor trees |
| 3052 |
// without needing to update import comments. |
| 3053 |
// |
| 3054 |
// Import path checking is also disabled when using modules. |
| 3055 |
// Import path comments are obsoleted by the go.mod file's module statement. |
| 3056 |
// |
| 3057 |
// See https://golang.org/s/go14customimport for details. |
| 3058 |
// |
| 3059 |
// # Modules, module versions, and more |
| 3060 |
// |
| 3061 |
// Modules are how Go manages dependencies. |
| 3062 |
// |
| 3063 |
// A module is a collection of packages that are released, versioned, and |
| 3064 |
// distributed together. Modules may be downloaded directly from version control |
| 3065 |
// repositories or from module proxy servers. |
| 3066 |
// |
| 3067 |
// For a series of tutorials on modules, see |
| 3068 |
// https://golang.org/doc/tutorial/create-module. |
| 3069 |
// |
| 3070 |
// For a detailed reference on modules, see https://golang.org/ref/mod. |
| 3071 |
// |
| 3072 |
// By default, the go command may download modules from https://proxy.golang.org. |
| 3073 |
// It may authenticate modules using the checksum database at |
| 3074 |
// https://sum.golang.org. Both services are operated by the Go team at Google. |
| 3075 |
// The privacy policies for these services are available at |
| 3076 |
// https://proxy.golang.org/privacy and https://sum.golang.org/privacy, |
| 3077 |
// respectively. |
| 3078 |
// |
| 3079 |
// The go command's download behavior may be configured using GOPROXY, GOSUMDB, |
| 3080 |
// GOPRIVATE, and other environment variables. See 'go help environment' |
| 3081 |
// and https://golang.org/ref/mod#private-module-privacy for more information. |
| 3082 |
// |
| 3083 |
// # Module authentication using go.sum |
| 3084 |
// |
| 3085 |
// When the go command downloads a module zip file or go.mod file into the |
| 3086 |
// module cache, it computes a cryptographic hash and compares it with a known |
| 3087 |
// value to verify the file hasn't changed since it was first downloaded. Known |
| 3088 |
// hashes are stored in a file in the module root directory named go.sum. Hashes |
| 3089 |
// may also be downloaded from the checksum database depending on the values of |
| 3090 |
// GOSUMDB, GOPRIVATE, and GONOSUMDB. |
| 3091 |
// |
| 3092 |
// For details, see https://golang.org/ref/mod#authenticating. |
| 3093 |
// |
| 3094 |
// # Package lists and patterns |
| 3095 |
// |
| 3096 |
// Many commands apply to a set of packages: |
| 3097 |
// |
| 3098 |
// go <action> [packages] |
| 3099 |
// |
| 3100 |
// Usually, [packages] is a list of import paths. |
| 3101 |
// |
| 3102 |
// An import path that is a rooted path or that begins with |
| 3103 |
// a . or .. element is interpreted as a file system path and |
| 3104 |
// denotes the package in that directory. |
| 3105 |
// |
| 3106 |
// Otherwise, the import path P denotes the package found in |
| 3107 |
// the directory DIR/src/P for some DIR listed in the GOPATH |
| 3108 |
// environment variable (For more details see: 'go help gopath'). |
| 3109 |
// |
| 3110 |
// If no import paths are given, the action applies to the |
| 3111 |
// package in the current directory. |
| 3112 |
// |
| 3113 |
// There are five reserved names for paths that should not be used |
| 3114 |
// for packages to be built with the go tool: |
| 3115 |
// |
| 3116 |
// - "main" denotes the top-level package in a stand-alone executable. |
| 3117 |
// |
| 3118 |
// - "all" expands to all packages in the main module (or workspace modules) and |
| 3119 |
// their dependencies, including dependencies needed by tests of any of those. In |
| 3120 |
// GOPATH mode, "all" expands to all packages found in all the GOPATH trees. |
| 3121 |
// |
| 3122 |
// - "std" is like all but expands to just the packages in the standard |
| 3123 |
// Go library. |
| 3124 |
// |
| 3125 |
// - "cmd" expands to the Go repository's commands and their |
| 3126 |
// internal libraries. |
| 3127 |
// |
| 3128 |
// - "tool" expands to the tools defined in the current module's go.mod file. |
| 3129 |
// |
| 3130 |
// Package names match against fully-qualified import paths or patterns that |
| 3131 |
// match against any number of import paths. For instance, "fmt" refers to the |
| 3132 |
// standard library's package fmt, but "http" alone for package http would not |
| 3133 |
// match the import path "net/http" from the standard library. Instead, the |
| 3134 |
// complete import path "net/http" must be used. |
| 3135 |
// |
| 3136 |
// Import paths beginning with "cmd/" only match source code in |
| 3137 |
// the Go repository. |
| 3138 |
// |
| 3139 |
// An import path is a pattern if it includes one or more "..." wildcards, |
| 3140 |
// each of which can match any string, including the empty string and |
| 3141 |
// strings containing slashes. Such a pattern expands to all package |
| 3142 |
// directories found in the GOPATH trees with names matching the |
| 3143 |
// patterns. |
| 3144 |
// |
| 3145 |
// To make common patterns more convenient, there are two special cases. |
| 3146 |
// First, /... at the end of the pattern can match an empty string, |
| 3147 |
// so that net/... matches both net and packages in its subdirectories, like net/http. |
| 3148 |
// Second, any slash-separated pattern element containing a wildcard never |
| 3149 |
// participates in a match of the "vendor" element in the path of a vendored |
| 3150 |
// package, so that ./... does not match packages in subdirectories of |
| 3151 |
// ./vendor or ./mycode/vendor, but ./vendor/... and ./mycode/vendor/... do. |
| 3152 |
// Note, however, that a directory named vendor that itself contains code |
| 3153 |
// is not a vendored package: cmd/vendor would be a command named vendor, |
| 3154 |
// and the pattern cmd/... matches it. |
| 3155 |
// See golang.org/s/go15vendor for more about vendoring. |
| 3156 |
// |
| 3157 |
// An import path can also name a package to be downloaded from |
| 3158 |
// a remote repository. Run 'go help importpath' for details. |
| 3159 |
// |
| 3160 |
// Every package in a program must have a unique import path. |
| 3161 |
// By convention, this is arranged by starting each path with a |
| 3162 |
// unique prefix that belongs to you. For example, paths used |
| 3163 |
// internally at Google all begin with 'google', and paths |
| 3164 |
// denoting remote repositories begin with the path to the code, |
| 3165 |
// such as 'github.com/user/repo'. Package patterns should include this prefix. |
| 3166 |
// For instance, a package called 'http' residing under 'github.com/user/repo', |
| 3167 |
// would be addressed with the fully-qualified pattern: |
| 3168 |
// 'github.com/user/repo/http'. |
| 3169 |
// |
| 3170 |
// Packages in a program need not have unique package names, |
| 3171 |
// but there are two reserved package names with special meaning. |
| 3172 |
// The name main indicates a command, not a library. |
| 3173 |
// Commands are built into binaries and cannot be imported. |
| 3174 |
// The name documentation indicates documentation for |
| 3175 |
// a non-Go program in the directory. Files in package documentation |
| 3176 |
// are ignored by the go command. |
| 3177 |
// |
| 3178 |
// As a special case, if the package list is a list of .go files from a |
| 3179 |
// single directory, the command is applied to a single synthesized |
| 3180 |
// package made up of exactly those files, ignoring any build constraints |
| 3181 |
// in those files and ignoring any other files in the directory. |
| 3182 |
// |
| 3183 |
// Directory and file names that begin with "." or "_" are ignored |
| 3184 |
// by the go tool, as are directories named "testdata". |
| 3185 |
// |
| 3186 |
// # Configuration for downloading non-public code |
| 3187 |
// |
| 3188 |
// The go command defaults to downloading modules from the public Go module |
| 3189 |
// mirror at proxy.golang.org. It also defaults to validating downloaded modules, |
| 3190 |
// regardless of source, against the public Go checksum database at sum.golang.org. |
| 3191 |
// These defaults work well for publicly available source code. |
| 3192 |
// |
| 3193 |
// The GOPRIVATE environment variable controls which modules the go command |
| 3194 |
// considers to be private (not available publicly) and should therefore not use |
| 3195 |
// the proxy or checksum database. The variable is a comma-separated list of |
| 3196 |
// glob patterns (in the syntax of Go's path.Match) of module path prefixes. |
| 3197 |
// For example, |
| 3198 |
// |
| 3199 |
// GOPRIVATE=*.corp.example.com,rsc.io/private |
| 3200 |
// |
| 3201 |
// causes the go command to treat as private any module with a path prefix |
| 3202 |
// matching either pattern, including git.corp.example.com/xyzzy, rsc.io/private, |
| 3203 |
// and rsc.io/private/quux. |
| 3204 |
// |
| 3205 |
// For fine-grained control over module download and validation, the GONOPROXY |
| 3206 |
// and GONOSUMDB environment variables accept the same kind of glob list |
| 3207 |
// and override GOPRIVATE for the specific decision of whether to use the proxy |
| 3208 |
// and checksum database, respectively. |
| 3209 |
// |
| 3210 |
// For example, if a company ran a module proxy serving private modules, |
| 3211 |
// users would configure go using: |
| 3212 |
// |
| 3213 |
// GOPRIVATE=*.corp.example.com |
| 3214 |
// GOPROXY=proxy.example.com |
| 3215 |
// GONOPROXY=none |
| 3216 |
// |
| 3217 |
// The GOPRIVATE variable is also used to define the "public" and "private" |
| 3218 |
// patterns for the GOVCS variable; see 'go help vcs'. For that usage, |
| 3219 |
// GOPRIVATE applies even in GOPATH mode. In that case, it matches import paths |
| 3220 |
// instead of module paths. |
| 3221 |
// |
| 3222 |
// The 'go env -w' command (see 'go help env') can be used to set these variables |
| 3223 |
// for future go command invocations. |
| 3224 |
// |
| 3225 |
// For more details, see https://golang.org/ref/mod#private-modules. |
| 3226 |
// |
| 3227 |
// # Testing flags |
| 3228 |
// |
| 3229 |
// The 'go test' command takes both flags that apply to 'go test' itself |
| 3230 |
// and flags that apply to the resulting test binary. |
| 3231 |
// |
| 3232 |
// Several of the flags control profiling and write an execution profile |
| 3233 |
// suitable for "go tool pprof"; run "go tool pprof -h" for more |
| 3234 |
// information. The --alloc_space, --alloc_objects, and --show_bytes |
| 3235 |
// options of pprof control how the information is presented. |
| 3236 |
// |
| 3237 |
// The following flags are recognized by the 'go test' command and |
| 3238 |
// control the execution of any test: |
| 3239 |
// |
| 3240 |
// -bench regexp |
| 3241 |
// Run only those benchmarks matching a regular expression. |
| 3242 |
// By default, no benchmarks are run. |
| 3243 |
// To run all benchmarks, use '-bench .' or '-bench=.'. |
| 3244 |
// The regular expression is split by unbracketed slash (/) |
| 3245 |
// characters into a sequence of regular expressions, and each |
| 3246 |
// part of a benchmark's identifier must match the corresponding |
| 3247 |
// element in the sequence, if any. Possible parents of matches |
| 3248 |
// are run with b.N=1 to identify sub-benchmarks. For example, |
| 3249 |
// given -bench=X/Y, top-level benchmarks matching X are run |
| 3250 |
// with b.N=1 to find any sub-benchmarks matching Y, which are |
| 3251 |
// then run in full. |
| 3252 |
// |
| 3253 |
// -benchtime t |
| 3254 |
// Run enough iterations of each benchmark to take t, specified |
| 3255 |
// as a time.Duration (for example, -benchtime 1h30s). |
| 3256 |
// The default is 1 second (1s). |
| 3257 |
// The special syntax Nx means to run the benchmark N times |
| 3258 |
// (for example, -benchtime 100x). |
| 3259 |
// |
| 3260 |
// -count n |
| 3261 |
// Run each test, benchmark, and fuzz seed n times (default 1). |
| 3262 |
// If -cpu is set, run n times for each GOMAXPROCS value. |
| 3263 |
// Examples are always run once. -count does not apply to |
| 3264 |
// fuzz tests matched by -fuzz. |
| 3265 |
// |
| 3266 |
// -cover |
| 3267 |
// Enable coverage analysis. |
| 3268 |
// Note that because coverage works by annotating the source |
| 3269 |
// code before compilation, compilation and test failures with |
| 3270 |
// coverage enabled may report line numbers that don't correspond |
| 3271 |
// to the original sources. |
| 3272 |
// |
| 3273 |
// -covermode set,count,atomic |
| 3274 |
// Set the mode for coverage analysis for the package[s] |
| 3275 |
// being tested. The default is "set" unless -race is enabled, |
| 3276 |
// in which case it is "atomic". |
| 3277 |
// The values: |
| 3278 |
// set: bool: does this statement run? |
| 3279 |
// count: int: how many times does this statement run? |
| 3280 |
// atomic: int: count, but correct in multithreaded tests; |
| 3281 |
// significantly more expensive. |
| 3282 |
// Sets -cover. |
| 3283 |
// |
| 3284 |
// -coverpkg pattern1,pattern2,pattern3 |
| 3285 |
// Apply coverage analysis in each test to packages whose import paths |
| 3286 |
// match the patterns. The default is for each test to analyze only |
| 3287 |
// the package being tested. See 'go help packages' for a description |
| 3288 |
// of package patterns. Sets -cover. |
| 3289 |
// |
| 3290 |
// -cpu 1,2,4 |
| 3291 |
// Specify a list of GOMAXPROCS values for which the tests, benchmarks or |
| 3292 |
// fuzz tests should be executed. The default is the current value |
| 3293 |
// of GOMAXPROCS. -cpu does not apply to fuzz tests matched by -fuzz. |
| 3294 |
// |
| 3295 |
// -failfast |
| 3296 |
// Do not start new tests after the first test failure. |
| 3297 |
// |
| 3298 |
// -fullpath |
| 3299 |
// Show full file names in the error messages. |
| 3300 |
// |
| 3301 |
// -fuzz regexp |
| 3302 |
// Run the fuzz test matching the regular expression. When specified, |
| 3303 |
// the command line argument must match exactly one package within the |
| 3304 |
// main module, and regexp must match exactly one fuzz test within |
| 3305 |
// that package. Fuzzing will occur after tests, benchmarks, seed corpora |
| 3306 |
// of other fuzz tests, and examples have completed. See the Fuzzing |
| 3307 |
// section of the testing package documentation for details. |
| 3308 |
// |
| 3309 |
// -fuzztime t |
| 3310 |
// Run enough iterations of the fuzz target during fuzzing to take t, |
| 3311 |
// specified as a time.Duration (for example, -fuzztime 1h30s). |
| 3312 |
// The default is to run forever. |
| 3313 |
// The special syntax Nx means to run the fuzz target N times |
| 3314 |
// (for example, -fuzztime 1000x). |
| 3315 |
// |
| 3316 |
// -fuzzminimizetime t |
| 3317 |
// Run enough iterations of the fuzz target during each minimization |
| 3318 |
// attempt to take t, as specified as a time.Duration (for example, |
| 3319 |
// -fuzzminimizetime 30s). |
| 3320 |
// The default is 60s. |
| 3321 |
// The special syntax Nx means to run the fuzz target N times |
| 3322 |
// (for example, -fuzzminimizetime 100x). |
| 3323 |
// |
| 3324 |
// -json |
| 3325 |
// Log verbose output and test results in JSON. This presents the |
| 3326 |
// same information as the -v flag in a machine-readable format. |
| 3327 |
// |
| 3328 |
// -list regexp |
| 3329 |
// List tests, benchmarks, fuzz tests, or examples matching the regular |
| 3330 |
// expression. No tests, benchmarks, fuzz tests, or examples will be run. |
| 3331 |
// This will only list top-level tests. No subtest or subbenchmarks will be |
| 3332 |
// shown. |
| 3333 |
// |
| 3334 |
// -parallel n |
| 3335 |
// Allow parallel execution of test functions that call t.Parallel, and |
| 3336 |
// fuzz targets that call t.Parallel when running the seed corpus. |
| 3337 |
// The value of this flag is the maximum number of tests to run |
| 3338 |
// simultaneously. |
| 3339 |
// While fuzzing, the value of this flag is the maximum number of |
| 3340 |
// subprocesses that may call the fuzz function simultaneously, regardless of |
| 3341 |
// whether T.Parallel is called. |
| 3342 |
// By default, -parallel is set to the value of GOMAXPROCS. |
| 3343 |
// Setting -parallel to values higher than GOMAXPROCS may cause degraded |
| 3344 |
// performance due to CPU contention, especially when fuzzing. |
| 3345 |
// Note that -parallel only applies within a single test binary. |
| 3346 |
// The 'go test' command may run tests for different packages |
| 3347 |
// in parallel as well, according to the setting of the -p flag |
| 3348 |
// (see 'go help build'). |
| 3349 |
// |
| 3350 |
// -run regexp |
| 3351 |
// Run only those tests, examples, and fuzz tests matching the regular |
| 3352 |
// expression. For tests, the regular expression is split by unbracketed |
| 3353 |
// slash (/) characters into a sequence of regular expressions, and each |
| 3354 |
// part of a test's identifier must match the corresponding element in |
| 3355 |
// the sequence, if any. Note that possible parents of matches are |
| 3356 |
// run too, so that -run=X/Y matches and runs and reports the result |
| 3357 |
// of all tests matching X, even those without sub-tests matching Y, |
| 3358 |
// because it must run them to look for those sub-tests. |
| 3359 |
// See also -skip. |
| 3360 |
// |
| 3361 |
// -short |
| 3362 |
// Tell long-running tests to shorten their run time. |
| 3363 |
// It is off by default but set during all.bash so that installing |
| 3364 |
// the Go tree can run a sanity check but not spend time running |
| 3365 |
// exhaustive tests. |
| 3366 |
// |
| 3367 |
// -shuffle off,on,N |
| 3368 |
// Randomize the execution order of tests and benchmarks. |
| 3369 |
// It is off by default. If -shuffle is set to on, then it will seed |
| 3370 |
// the randomizer using the system clock. If -shuffle is set to an |
| 3371 |
// integer N, then N will be used as the seed value. In both cases, |
| 3372 |
// the seed will be reported for reproducibility. |
| 3373 |
// |
| 3374 |
// -skip regexp |
| 3375 |
// Run only those tests, examples, fuzz tests, and benchmarks that |
| 3376 |
// do not match the regular expression. Like for -run and -bench, |
| 3377 |
// for tests and benchmarks, the regular expression is split by unbracketed |
| 3378 |
// slash (/) characters into a sequence of regular expressions, and each |
| 3379 |
// part of a test's identifier must match the corresponding element in |
| 3380 |
// the sequence, if any. |
| 3381 |
// |
| 3382 |
// -timeout d |
| 3383 |
// If a test binary runs longer than duration d, panic. |
| 3384 |
// If d is 0, the timeout is disabled. |
| 3385 |
// The default is 10 minutes (10m). |
| 3386 |
// |
| 3387 |
// -v |
| 3388 |
// Verbose output: log all tests as they are run. Also print all |
| 3389 |
// text from Log and Logf calls even if the test succeeds. |
| 3390 |
// |
| 3391 |
// -vet list |
| 3392 |
// Configure the invocation of "go vet" during "go test" |
| 3393 |
// to use the comma-separated list of vet checks. |
| 3394 |
// If list is empty, "go test" runs "go vet" with a curated list of |
| 3395 |
// checks believed to be always worth addressing. |
| 3396 |
// If list is "off", "go test" does not run "go vet" at all. |
| 3397 |
// |
| 3398 |
// The following flags are also recognized by 'go test' and can be used to |
| 3399 |
// profile the tests during execution: |
| 3400 |
// |
| 3401 |
// -benchmem |
| 3402 |
// Print memory allocation statistics for benchmarks. |
| 3403 |
// Allocations made in C or using C.malloc are not counted. |
| 3404 |
// |
| 3405 |
// -blockprofile block.out |
| 3406 |
// Write a goroutine blocking profile to the specified file |
| 3407 |
// when all tests are complete. |
| 3408 |
// Writes test binary as -c would. |
| 3409 |
// |
| 3410 |
// -blockprofilerate n |
| 3411 |
// Control the detail provided in goroutine blocking profiles by |
| 3412 |
// calling runtime.SetBlockProfileRate with n. |
| 3413 |
// See 'go doc runtime.SetBlockProfileRate'. |
| 3414 |
// The profiler aims to sample, on average, one blocking event every |
| 3415 |
// n nanoseconds the program spends blocked. By default, |
| 3416 |
// if -test.blockprofile is set without this flag, all blocking events |
| 3417 |
// are recorded, equivalent to -test.blockprofilerate=1. |
| 3418 |
// |
| 3419 |
// -coverprofile cover.out |
| 3420 |
// Write a coverage profile to the file after all tests have passed. |
| 3421 |
// Sets -cover. |
| 3422 |
// |
| 3423 |
// -cpuprofile cpu.out |
| 3424 |
// Write a CPU profile to the specified file before exiting. |
| 3425 |
// Writes test binary as -c would. |
| 3426 |
// |
| 3427 |
// -memprofile mem.out |
| 3428 |
// Write an allocation profile to the file after all tests have passed. |
| 3429 |
// Writes test binary as -c would. |
| 3430 |
// |
| 3431 |
// -memprofilerate n |
| 3432 |
// Enable more precise (and expensive) memory allocation profiles by |
| 3433 |
// setting runtime.MemProfileRate. See 'go doc runtime.MemProfileRate'. |
| 3434 |
// To profile all memory allocations, use -test.memprofilerate=1. |
| 3435 |
// |
| 3436 |
// -mutexprofile mutex.out |
| 3437 |
// Write a mutex contention profile to the specified file |
| 3438 |
// when all tests are complete. |
| 3439 |
// Writes test binary as -c would. |
| 3440 |
// |
| 3441 |
// -mutexprofilefraction n |
| 3442 |
// Sample 1 in n stack traces of goroutines holding a |
| 3443 |
// contended mutex. |
| 3444 |
// |
| 3445 |
// -outputdir directory |
| 3446 |
// Place output files from profiling in the specified directory, |
| 3447 |
// by default the directory in which "go test" is running. |
| 3448 |
// |
| 3449 |
// -trace trace.out |
| 3450 |
// Write an execution trace to the specified file before exiting. |
| 3451 |
// |
| 3452 |
// Each of these flags is also recognized with an optional 'test.' prefix, |
| 3453 |
// as in -test.v. When invoking the generated test binary (the result of |
| 3454 |
// 'go test -c') directly, however, the prefix is mandatory. |
| 3455 |
// |
| 3456 |
// The 'go test' command rewrites or removes recognized flags, |
| 3457 |
// as appropriate, both before and after the optional package list, |
| 3458 |
// before invoking the test binary. |
| 3459 |
// |
| 3460 |
// For instance, the command |
| 3461 |
// |
| 3462 |
// go test -v -myflag testdata -cpuprofile=prof.out -x |
| 3463 |
// |
| 3464 |
// will compile the test binary and then run it as |
| 3465 |
// |
| 3466 |
// pkg.test -test.v -myflag testdata -test.cpuprofile=prof.out |
| 3467 |
// |
| 3468 |
// (The -x flag is removed because it applies only to the go command's |
| 3469 |
// execution, not to the test itself.) |
| 3470 |
// |
| 3471 |
// The test flags that generate profiles (other than for coverage) also |
| 3472 |
// leave the test binary in pkg.test for use when analyzing the profiles. |
| 3473 |
// |
| 3474 |
// When 'go test' runs a test binary, it does so from within the |
| 3475 |
// corresponding package's source code directory. Depending on the test, |
| 3476 |
// it may be necessary to do the same when invoking a generated test |
| 3477 |
// binary directly. Because that directory may be located within the |
| 3478 |
// module cache, which may be read-only and is verified by checksums, the |
| 3479 |
// test must not write to it or any other directory within the module |
| 3480 |
// unless explicitly requested by the user (such as with the -fuzz flag, |
| 3481 |
// which writes failures to testdata/fuzz). |
| 3482 |
// |
| 3483 |
// The command-line package list, if present, must appear before any |
| 3484 |
// flag not known to the go test command. Continuing the example above, |
| 3485 |
// the package list would have to appear before -myflag, but could appear |
| 3486 |
// on either side of -v. |
| 3487 |
// |
| 3488 |
// When 'go test' runs in package list mode, 'go test' caches successful |
| 3489 |
// package test results to avoid unnecessary repeated running of tests. To |
| 3490 |
// disable test caching, use any test flag or argument other than the |
| 3491 |
// cacheable flags. The idiomatic way to disable test caching explicitly |
| 3492 |
// is to use -count=1. |
| 3493 |
// |
| 3494 |
// To keep an argument for a test binary from being interpreted as a |
| 3495 |
// known flag or a package name, use -args (see 'go help test') which |
| 3496 |
// passes the remainder of the command line through to the test binary |
| 3497 |
// uninterpreted and unaltered. |
| 3498 |
// |
| 3499 |
// For instance, the command |
| 3500 |
// |
| 3501 |
// go test -v -args -x -v |
| 3502 |
// |
| 3503 |
// will compile the test binary and then run it as |
| 3504 |
// |
| 3505 |
// pkg.test -test.v -x -v |
| 3506 |
// |
| 3507 |
// Similarly, |
| 3508 |
// |
| 3509 |
// go test -args math |
| 3510 |
// |
| 3511 |
// will compile the test binary and then run it as |
| 3512 |
// |
| 3513 |
// pkg.test math |
| 3514 |
// |
| 3515 |
// In the first example, the -x and the second -v are passed through to the |
| 3516 |
// test binary unchanged and with no effect on the go command itself. |
| 3517 |
// In the second example, the argument math is passed through to the test |
| 3518 |
// binary, instead of being interpreted as the package list. |
| 3519 |
// |
| 3520 |
// # Testing functions |
| 3521 |
// |
| 3522 |
// The 'go test' command expects to find test, benchmark, and example functions |
| 3523 |
// in the "*_test.go" files corresponding to the package under test. |
| 3524 |
// |
| 3525 |
// A test function is one named TestXxx (where Xxx does not start with a |
| 3526 |
// lower case letter) and should have the signature, |
| 3527 |
// |
| 3528 |
// func TestXxx(t *testing.T) { ... } |
| 3529 |
// |
| 3530 |
// A benchmark function is one named BenchmarkXxx and should have the signature, |
| 3531 |
// |
| 3532 |
// func BenchmarkXxx(b *testing.B) { ... } |
| 3533 |
// |
| 3534 |
// A fuzz test is one named FuzzXxx and should have the signature, |
| 3535 |
// |
| 3536 |
// func FuzzXxx(f *testing.F) { ... } |
| 3537 |
// |
| 3538 |
// An example function is similar to a test function but, instead of using |
| 3539 |
// *testing.T to report success or failure, prints output to os.Stdout. |
| 3540 |
// If the last comment in the function starts with "Output:" then the output |
| 3541 |
// is compared exactly against the comment (see examples below). If the last |
| 3542 |
// comment begins with "Unordered output:" then the output is compared to the |
| 3543 |
// comment, however the order of the lines is ignored. An example with no such |
| 3544 |
// comment is compiled but not executed. An example with no text after |
| 3545 |
// "Output:" is compiled, executed, and expected to produce no output. |
| 3546 |
// |
| 3547 |
// Godoc displays the body of ExampleXxx to demonstrate the use |
| 3548 |
// of the function, constant, or variable Xxx. An example of a method M with |
| 3549 |
// receiver type T or *T is named ExampleT_M. There may be multiple examples |
| 3550 |
// for a given function, constant, or variable, distinguished by a trailing _xxx, |
| 3551 |
// where xxx is a suffix not beginning with an upper case letter. |
| 3552 |
// |
| 3553 |
// Here is an example of an example: |
| 3554 |
// |
| 3555 |
// func ExamplePrintln() { |
| 3556 |
// Println("The output of\nthis example.") |
| 3557 |
// // Output: The output of |
| 3558 |
// // this example. |
| 3559 |
// } |
| 3560 |
// |
| 3561 |
// Here is another example where the ordering of the output is ignored: |
| 3562 |
// |
| 3563 |
// func ExamplePerm() { |
| 3564 |
// for _, value := range Perm(4) { |
| 3565 |
// fmt.Println(value) |
| 3566 |
// } |
| 3567 |
// |
| 3568 |
// // Unordered output: 4 |
| 3569 |
// // 2 |
| 3570 |
// // 1 |
| 3571 |
// // 3 |
| 3572 |
// // 0 |
| 3573 |
// } |
| 3574 |
// |
| 3575 |
// The entire test file is presented as the example when it contains a single |
| 3576 |
// example function, at least one other function, type, variable, or constant |
| 3577 |
// declaration, and no tests, benchmarks, or fuzz tests. |
| 3578 |
// |
| 3579 |
// See the documentation of the testing package for more information. |
| 3580 |
// |
| 3581 |
// # Controlling version control with GOVCS |
| 3582 |
// |
| 3583 |
// The 'go get' command can run version control commands like git |
| 3584 |
// to download imported code. This functionality is critical to the decentralized |
| 3585 |
// Go package ecosystem, in which code can be imported from any server, |
| 3586 |
// but it is also a potential security problem, if a malicious server finds a |
| 3587 |
// way to cause the invoked version control command to run unintended code. |
| 3588 |
// |
| 3589 |
// To balance the functionality and security concerns, the 'go get' command |
| 3590 |
// by default will only use git and hg to download code from public servers. |
| 3591 |
// But it will use any known version control system (bzr, fossil, git, hg, svn) |
| 3592 |
// to download code from private servers, defined as those hosting packages |
| 3593 |
// matching the GOPRIVATE variable (see 'go help private'). The rationale behind |
| 3594 |
// allowing only Git and Mercurial is that these two systems have had the most |
| 3595 |
// attention to issues of being run as clients of untrusted servers. In contrast, |
| 3596 |
// Bazaar, Fossil, and Subversion have primarily been used in trusted, |
| 3597 |
// authenticated environments and are not as well scrutinized as attack surfaces. |
| 3598 |
// |
| 3599 |
// The version control command restrictions only apply when using direct version |
| 3600 |
// control access to download code. When downloading modules from a proxy, |
| 3601 |
// 'go get' uses the proxy protocol instead, which is always permitted. |
| 3602 |
// By default, the 'go get' command uses the Go module mirror (proxy.golang.org) |
| 3603 |
// for public packages and only falls back to version control for private |
| 3604 |
// packages or when the mirror refuses to serve a public package (typically for |
| 3605 |
// legal reasons). Therefore, clients can still access public code served from |
| 3606 |
// Bazaar, Fossil, or Subversion repositories by default, because those downloads |
| 3607 |
// use the Go module mirror, which takes on the security risk of running the |
| 3608 |
// version control commands using a custom sandbox. |
| 3609 |
// |
| 3610 |
// The GOVCS variable can be used to change the allowed version control systems |
| 3611 |
// for specific packages (identified by a module or import path). |
| 3612 |
// The GOVCS variable applies when building package in both module-aware mode |
| 3613 |
// and GOPATH mode. When using modules, the patterns match against the module path. |
| 3614 |
// When using GOPATH, the patterns match against the import path corresponding to |
| 3615 |
// the root of the version control repository. |
| 3616 |
// |
| 3617 |
// The general form of the GOVCS setting is a comma-separated list of |
| 3618 |
// pattern:vcslist rules. The pattern is a glob pattern that must match |
| 3619 |
// one or more leading elements of the module or import path. The vcslist |
| 3620 |
// is a pipe-separated list of allowed version control commands, or "all" |
| 3621 |
// to allow use of any known command, or "off" to disallow all commands. |
| 3622 |
// Note that if a module matches a pattern with vcslist "off", it may still be |
| 3623 |
// downloaded if the origin server uses the "mod" scheme, which instructs the |
| 3624 |
// go command to download the module using the GOPROXY protocol. |
| 3625 |
// The earliest matching pattern in the list applies, even if later patterns |
| 3626 |
// might also match. |
| 3627 |
// |
| 3628 |
// For example, consider: |
| 3629 |
// |
| 3630 |
// GOVCS=github.com:git,evil.com:off,*:git|hg |
| 3631 |
// |
| 3632 |
// With this setting, code with a module or import path beginning with |
| 3633 |
// github.com/ can only use git; paths on evil.com cannot use any version |
| 3634 |
// control command, and all other paths (* matches everything) can use |
| 3635 |
// only git or hg. |
| 3636 |
// |
| 3637 |
// The special patterns "public" and "private" match public and private |
| 3638 |
// module or import paths. A path is private if it matches the GOPRIVATE |
| 3639 |
// variable; otherwise it is public. |
| 3640 |
// |
| 3641 |
// If no rules in the GOVCS variable match a particular module or import path, |
| 3642 |
// the 'go get' command applies its default rule, which can now be summarized |
| 3643 |
// in GOVCS notation as 'public:git|hg,private:all'. |
| 3644 |
// |
| 3645 |
// To allow unfettered use of any version control system for any package, use: |
| 3646 |
// |
| 3647 |
// GOVCS=*:all |
| 3648 |
// |
| 3649 |
// To disable all use of version control, use: |
| 3650 |
// |
| 3651 |
// GOVCS=*:off |
| 3652 |
// |
| 3653 |
// The 'go env -w' command (see 'go help env') can be used to set the GOVCS |
| 3654 |
// variable for future go command invocations. |
| 3655 |
package main |