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