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