github.com/c9s/go@v0.0.0-20180120015821-984e81f64e0c/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 // DO NOT EDIT THIS FILE. GENERATED BY mkalldocs.sh. 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 // build compile packages and dependencies 17 // clean remove object files and cached files 18 // doc show documentation for package or symbol 19 // env print Go environment information 20 // bug start a bug report 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 27 // run compile and run Go program 28 // test test packages 29 // tool run specified go tool 30 // version print Go version 31 // vet report likely mistakes in packages 32 // 33 // Use "go help [command]" for more information about a command. 34 // 35 // Additional help topics: 36 // 37 // c calling between Go and C 38 // buildmode description of build modes 39 // filetype file types 40 // gopath GOPATH environment variable 41 // environment environment variables 42 // importpath import path syntax 43 // packages description of package lists 44 // testflag description of testing flags 45 // testfunc description of testing functions 46 // 47 // Use "go help [topic]" for more information about that topic. 48 // 49 // 50 // Compile packages and dependencies 51 // 52 // Usage: 53 // 54 // go build [-o output] [-i] [build flags] [packages] 55 // 56 // Build compiles the packages named by the import paths, 57 // along with their dependencies, but it does not install the results. 58 // 59 // If the arguments to build are a list of .go files, build treats 60 // them as a list of source files specifying a single package. 61 // 62 // When compiling a single main package, build writes 63 // the resulting executable to an output file named after 64 // the first source file ('go build ed.go rx.go' writes 'ed' or 'ed.exe') 65 // or the source code directory ('go build unix/sam' writes 'sam' or 'sam.exe'). 66 // The '.exe' suffix is added when writing a Windows executable. 67 // 68 // When compiling multiple packages or a single non-main package, 69 // build compiles the packages but discards the resulting object, 70 // serving only as a check that the packages can be built. 71 // 72 // When compiling packages, build ignores files that end in '_test.go'. 73 // 74 // The -o flag, only allowed when compiling a single package, 75 // forces build to write the resulting executable or object 76 // to the named output file, instead of the default behavior described 77 // in the last two paragraphs. 78 // 79 // The -i flag installs the packages that are dependencies of the target. 80 // 81 // The build flags are shared by the build, clean, get, install, list, run, 82 // and test commands: 83 // 84 // -a 85 // force rebuilding of packages that are already up-to-date. 86 // -n 87 // print the commands but do not run them. 88 // -p n 89 // the number of programs, such as build commands or 90 // test binaries, that can be run in parallel. 91 // The default is the number of CPUs available. 92 // -race 93 // enable data race detection. 94 // Supported only on linux/amd64, freebsd/amd64, darwin/amd64 and windows/amd64. 95 // -msan 96 // enable interoperation with memory sanitizer. 97 // Supported only on linux/amd64, 98 // and only with Clang/LLVM as the host C compiler. 99 // -v 100 // print the names of packages as they are compiled. 101 // -work 102 // print the name of the temporary work directory and 103 // do not delete it when exiting. 104 // -x 105 // print the commands. 106 // 107 // -asmflags '[pattern=]arg list' 108 // arguments to pass on each go tool asm invocation. 109 // -buildmode mode 110 // build mode to use. See 'go help buildmode' for more. 111 // -compiler name 112 // name of compiler to use, as in runtime.Compiler (gccgo or gc). 113 // -gccgoflags '[pattern=]arg list' 114 // arguments to pass on each gccgo compiler/linker invocation. 115 // -gcflags '[pattern=]arg list' 116 // arguments to pass on each go tool compile invocation. 117 // -installsuffix suffix 118 // a suffix to use in the name of the package installation directory, 119 // in order to keep output separate from default builds. 120 // If using the -race flag, the install suffix is automatically set to race 121 // or, if set explicitly, has _race appended to it. Likewise for the -msan 122 // flag. Using a -buildmode option that requires non-default compile flags 123 // has a similar effect. 124 // -ldflags '[pattern=]arg list' 125 // arguments to pass on each go tool link invocation. 126 // -linkshared 127 // link against shared libraries previously created with 128 // -buildmode=shared. 129 // -pkgdir dir 130 // install and load all packages from dir instead of the usual locations. 131 // For example, when building with a non-standard configuration, 132 // use -pkgdir to keep generated packages in a separate location. 133 // -tags 'tag list' 134 // a space-separated list of build tags to consider satisfied during the 135 // build. For more information about build tags, see the description of 136 // build constraints in the documentation for the go/build package. 137 // -toolexec 'cmd args' 138 // a program to use to invoke toolchain programs like vet and asm. 139 // For example, instead of running asm, the go command will run 140 // 'cmd args /path/to/asm <arguments for asm>'. 141 // 142 // The -asmflags, -gccgoflags, -gcflags, and -ldflags flags accept a 143 // space-separated list of arguments to pass to an underlying tool 144 // during the build. To embed spaces in an element in the list, surround 145 // it with either single or double quotes. The argument list may be 146 // preceded by a package pattern and an equal sign, which restricts 147 // the use of that argument list to the building of packages matching 148 // that pattern (see 'go help packages' for a description of package 149 // patterns). Without a pattern, the argument list applies only to the 150 // packages named on the command line. The flags may be repeated 151 // with different patterns in order to specify different arguments for 152 // different sets of packages. If a package matches patterns given in 153 // multiple flags, the latest match on the command line wins. 154 // For example, 'go build -gcflags=-S fmt' prints the disassembly 155 // only for package fmt, while 'go build -gcflags=all=-S fmt' 156 // prints the disassembly for fmt and all its dependencies. 157 // 158 // For more about specifying packages, see 'go help packages'. 159 // For more about where packages and binaries are installed, 160 // run 'go help gopath'. 161 // For more about calling between Go and C/C++, run 'go help c'. 162 // 163 // Note: Build adheres to certain conventions such as those described 164 // by 'go help gopath'. Not all projects can follow these conventions, 165 // however. Installations that have their own conventions or that use 166 // a separate software build system may choose to use lower-level 167 // invocations such as 'go tool compile' and 'go tool link' to avoid 168 // some of the overheads and design decisions of the build tool. 169 // 170 // See also: go install, go get, go clean. 171 // 172 // 173 // Remove object files and cached files 174 // 175 // Usage: 176 // 177 // go clean [-i] [-r] [-n] [-x] [-cache] [-testcache] [build flags] [packages] 178 // 179 // Clean removes object files from package source directories. 180 // The go command builds most objects in a temporary directory, 181 // so go clean is mainly concerned with object files left by other 182 // tools or by manual invocations of go build. 183 // 184 // Specifically, clean removes the following files from each of the 185 // source directories corresponding to the import paths: 186 // 187 // _obj/ old object directory, left from Makefiles 188 // _test/ old test directory, left from Makefiles 189 // _testmain.go old gotest file, left from Makefiles 190 // test.out old test log, left from Makefiles 191 // build.out old test log, left from Makefiles 192 // *.[568ao] object files, left from Makefiles 193 // 194 // DIR(.exe) from go build 195 // DIR.test(.exe) from go test -c 196 // MAINFILE(.exe) from go build MAINFILE.go 197 // *.so from SWIG 198 // 199 // In the list, DIR represents the final path element of the 200 // directory, and MAINFILE is the base name of any Go source 201 // file in the directory that is not included when building 202 // the package. 203 // 204 // The -i flag causes clean to remove the corresponding installed 205 // archive or binary (what 'go install' would create). 206 // 207 // The -n flag causes clean to print the remove commands it would execute, 208 // but not run them. 209 // 210 // The -r flag causes clean to be applied recursively to all the 211 // dependencies of the packages named by the import paths. 212 // 213 // The -x flag causes clean to print remove commands as it executes them. 214 // 215 // The -cache flag causes clean to remove the entire go build cache. 216 // 217 // The -testcache flag causes clean to expire all test results in the 218 // go build cache. 219 // 220 // For more about build flags, see 'go help build'. 221 // 222 // For more about specifying packages, see 'go help packages'. 223 // 224 // 225 // Show documentation for package or symbol 226 // 227 // Usage: 228 // 229 // go doc [-u] [-c] [package|[package.]symbol[.methodOrField]] 230 // 231 // Doc prints the documentation comments associated with the item identified by its 232 // arguments (a package, const, func, type, var, method, or struct field) 233 // followed by a one-line summary of each of the first-level items "under" 234 // that item (package-level declarations for a package, methods for a type, 235 // etc.). 236 // 237 // Doc accepts zero, one, or two arguments. 238 // 239 // Given no arguments, that is, when run as 240 // 241 // go doc 242 // 243 // it prints the package documentation for the package in the current directory. 244 // If the package is a command (package main), the exported symbols of the package 245 // are elided from the presentation unless the -cmd flag is provided. 246 // 247 // When run with one argument, the argument is treated as a Go-syntax-like 248 // representation of the item to be documented. What the argument selects depends 249 // on what is installed in GOROOT and GOPATH, as well as the form of the argument, 250 // which is schematically one of these: 251 // 252 // go doc <pkg> 253 // go doc <sym>[.<methodOrField>] 254 // go doc [<pkg>.]<sym>[.<methodOrField>] 255 // go doc [<pkg>.][<sym>.]<methodOrField> 256 // 257 // The first item in this list matched by the argument is the one whose documentation 258 // is printed. (See the examples below.) However, if the argument starts with a capital 259 // letter it is assumed to identify a symbol or method in the current directory. 260 // 261 // For packages, the order of scanning is determined lexically in breadth-first order. 262 // That is, the package presented is the one that matches the search and is nearest 263 // the root and lexically first at its level of the hierarchy. The GOROOT tree is 264 // always scanned in its entirety before GOPATH. 265 // 266 // If there is no package specified or matched, the package in the current 267 // directory is selected, so "go doc Foo" shows the documentation for symbol Foo in 268 // the current package. 269 // 270 // The package path must be either a qualified path or a proper suffix of a 271 // path. The go tool's usual package mechanism does not apply: package path 272 // elements like . and ... are not implemented by go doc. 273 // 274 // When run with two arguments, the first must be a full package path (not just a 275 // suffix), and the second is a symbol, or symbol with method or struct field. 276 // This is similar to the syntax accepted by godoc: 277 // 278 // go doc <pkg> <sym>[.<methodOrField>] 279 // 280 // In all forms, when matching symbols, lower-case letters in the argument match 281 // either case but upper-case letters match exactly. This means that there may be 282 // multiple matches of a lower-case argument in a package if different symbols have 283 // different cases. If this occurs, documentation for all matches is printed. 284 // 285 // Examples: 286 // go doc 287 // Show documentation for current package. 288 // go doc Foo 289 // Show documentation for Foo in the current package. 290 // (Foo starts with a capital letter so it cannot match 291 // a package path.) 292 // go doc encoding/json 293 // Show documentation for the encoding/json package. 294 // go doc json 295 // Shorthand for encoding/json. 296 // go doc json.Number (or go doc json.number) 297 // Show documentation and method summary for json.Number. 298 // go doc json.Number.Int64 (or go doc json.number.int64) 299 // Show documentation for json.Number's Int64 method. 300 // go doc cmd/doc 301 // Show package docs for the doc command. 302 // go doc -cmd cmd/doc 303 // Show package docs and exported symbols within the doc command. 304 // go doc template.new 305 // Show documentation for html/template's New function. 306 // (html/template is lexically before text/template) 307 // go doc text/template.new # One argument 308 // Show documentation for text/template's New function. 309 // go doc text/template new # Two arguments 310 // Show documentation for text/template's New function. 311 // 312 // At least in the current tree, these invocations all print the 313 // documentation for json.Decoder's Decode method: 314 // 315 // go doc json.Decoder.Decode 316 // go doc json.decoder.decode 317 // go doc json.decode 318 // cd go/src/encoding/json; go doc decode 319 // 320 // Flags: 321 // -c 322 // Respect case when matching symbols. 323 // -cmd 324 // Treat a command (package main) like a regular package. 325 // Otherwise package main's exported symbols are hidden 326 // when showing the package's top-level documentation. 327 // -u 328 // Show documentation for unexported as well as exported 329 // symbols, methods, and fields. 330 // 331 // 332 // Print Go environment information 333 // 334 // Usage: 335 // 336 // go env [-json] [var ...] 337 // 338 // Env prints Go environment information. 339 // 340 // By default env prints information as a shell script 341 // (on Windows, a batch file). If one or more variable 342 // names is given as arguments, env prints the value of 343 // each named variable on its own line. 344 // 345 // The -json flag prints the environment in JSON format 346 // instead of as a shell script. 347 // 348 // For more about environment variables, see 'go help environment'. 349 // 350 // 351 // Start a bug report 352 // 353 // Usage: 354 // 355 // go bug 356 // 357 // Bug opens the default browser and starts a new bug report. 358 // The report includes useful system information. 359 // 360 // 361 // Update packages to use new APIs 362 // 363 // Usage: 364 // 365 // go fix [packages] 366 // 367 // Fix runs the Go fix command on the packages named by the import paths. 368 // 369 // For more about fix, see 'go doc cmd/fix'. 370 // For more about specifying packages, see 'go help packages'. 371 // 372 // To run fix with specific options, run 'go tool fix'. 373 // 374 // See also: go fmt, go vet. 375 // 376 // 377 // Gofmt (reformat) package sources 378 // 379 // Usage: 380 // 381 // go fmt [-n] [-x] [packages] 382 // 383 // Fmt runs the command 'gofmt -l -w' on the packages named 384 // by the import paths. It prints the names of the files that are modified. 385 // 386 // For more about gofmt, see 'go doc cmd/gofmt'. 387 // For more about specifying packages, see 'go help packages'. 388 // 389 // The -n flag prints commands that would be executed. 390 // The -x flag prints commands as they are executed. 391 // 392 // To run gofmt with specific options, run gofmt itself. 393 // 394 // See also: go fix, go vet. 395 // 396 // 397 // Generate Go files by processing source 398 // 399 // Usage: 400 // 401 // go generate [-run regexp] [-n] [-v] [-x] [build flags] [file.go... | packages] 402 // 403 // Generate runs commands described by directives within existing 404 // files. Those commands can run any process but the intent is to 405 // create or update Go source files. 406 // 407 // Go generate is never run automatically by go build, go get, go test, 408 // and so on. It must be run explicitly. 409 // 410 // Go generate scans the file for directives, which are lines of 411 // the form, 412 // 413 // //go:generate command argument... 414 // 415 // (note: no leading spaces and no space in "//go") where command 416 // is the generator to be run, corresponding to an executable file 417 // that can be run locally. It must either be in the shell path 418 // (gofmt), a fully qualified path (/usr/you/bin/mytool), or a 419 // command alias, described below. 420 // 421 // Note that go generate does not parse the file, so lines that look 422 // like directives in comments or multiline strings will be treated 423 // as directives. 424 // 425 // The arguments to the directive are space-separated tokens or 426 // double-quoted strings passed to the generator as individual 427 // arguments when it is run. 428 // 429 // Quoted strings use Go syntax and are evaluated before execution; a 430 // quoted string appears as a single argument to the generator. 431 // 432 // Go generate sets several variables when it runs the generator: 433 // 434 // $GOARCH 435 // The execution architecture (arm, amd64, etc.) 436 // $GOOS 437 // The execution operating system (linux, windows, etc.) 438 // $GOFILE 439 // The base name of the file. 440 // $GOLINE 441 // The line number of the directive in the source file. 442 // $GOPACKAGE 443 // The name of the package of the file containing the directive. 444 // $DOLLAR 445 // A dollar sign. 446 // 447 // Other than variable substitution and quoted-string evaluation, no 448 // special processing such as "globbing" is performed on the command 449 // line. 450 // 451 // As a last step before running the command, any invocations of any 452 // environment variables with alphanumeric names, such as $GOFILE or 453 // $HOME, are expanded throughout the command line. The syntax for 454 // variable expansion is $NAME on all operating systems. Due to the 455 // order of evaluation, variables are expanded even inside quoted 456 // strings. If the variable NAME is not set, $NAME expands to the 457 // empty string. 458 // 459 // A directive of the form, 460 // 461 // //go:generate -command xxx args... 462 // 463 // specifies, for the remainder of this source file only, that the 464 // string xxx represents the command identified by the arguments. This 465 // can be used to create aliases or to handle multiword generators. 466 // For example, 467 // 468 // //go:generate -command foo go tool foo 469 // 470 // specifies that the command "foo" represents the generator 471 // "go tool foo". 472 // 473 // Generate processes packages in the order given on the command line, 474 // one at a time. If the command line lists .go files, they are treated 475 // as a single package. Within a package, generate processes the 476 // source files in a package in file name order, one at a time. Within 477 // a source file, generate runs generators in the order they appear 478 // in the file, one at a time. 479 // 480 // If any generator returns an error exit status, "go generate" skips 481 // all further processing for that package. 482 // 483 // The generator is run in the package's source directory. 484 // 485 // Go generate accepts one specific flag: 486 // 487 // -run="" 488 // if non-empty, specifies a regular expression to select 489 // directives whose full original source text (excluding 490 // any trailing spaces and final newline) matches the 491 // expression. 492 // 493 // It also accepts the standard build flags including -v, -n, and -x. 494 // The -v flag prints the names of packages and files as they are 495 // processed. 496 // The -n flag prints commands that would be executed. 497 // The -x flag prints commands as they are executed. 498 // 499 // For more about build flags, see 'go help build'. 500 // 501 // For more about specifying packages, see 'go help packages'. 502 // 503 // 504 // Download and install packages and dependencies 505 // 506 // Usage: 507 // 508 // go get [-d] [-f] [-fix] [-insecure] [-t] [-u] [-v] [build flags] [packages] 509 // 510 // Get downloads the packages named by the import paths, along with their 511 // dependencies. It then installs the named packages, like 'go install'. 512 // 513 // The -d flag instructs get to stop after downloading the packages; that is, 514 // it instructs get not to install the packages. 515 // 516 // The -f flag, valid only when -u is set, forces get -u not to verify that 517 // each package has been checked out from the source control repository 518 // implied by its import path. This can be useful if the source is a local fork 519 // of the original. 520 // 521 // The -fix flag instructs get to run the fix tool on the downloaded packages 522 // before resolving dependencies or building the code. 523 // 524 // The -insecure flag permits fetching from repositories and resolving 525 // custom domains using insecure schemes such as HTTP. Use with caution. 526 // 527 // The -t flag instructs get to also download the packages required to build 528 // the tests for the specified packages. 529 // 530 // The -u flag instructs get to use the network to update the named packages 531 // and their dependencies. By default, get uses the network to check out 532 // missing packages but does not use it to look for updates to existing packages. 533 // 534 // The -v flag enables verbose progress and debug output. 535 // 536 // Get also accepts build flags to control the installation. See 'go help build'. 537 // 538 // When checking out a new package, get creates the target directory 539 // GOPATH/src/<import-path>. If the GOPATH contains multiple entries, 540 // get uses the first one. For more details see: 'go help gopath'. 541 // 542 // When checking out or updating a package, get looks for a branch or tag 543 // that matches the locally installed version of Go. The most important 544 // rule is that if the local installation is running version "go1", get 545 // searches for a branch or tag named "go1". If no such version exists 546 // it retrieves the default branch of the package. 547 // 548 // When go get checks out or updates a Git repository, 549 // it also updates any git submodules referenced by the repository. 550 // 551 // Get never checks out or updates code stored in vendor directories. 552 // 553 // For more about specifying packages, see 'go help packages'. 554 // 555 // For more about how 'go get' finds source code to 556 // download, see 'go help importpath'. 557 // 558 // See also: go build, go install, go clean. 559 // 560 // 561 // Compile and install packages and dependencies 562 // 563 // Usage: 564 // 565 // go install [-i] [build flags] [packages] 566 // 567 // Install compiles and installs the packages named by the import paths. 568 // 569 // The -i flag installs the dependencies of the named packages as well. 570 // 571 // For more about the build flags, see 'go help build'. 572 // For more about specifying packages, see 'go help packages'. 573 // 574 // See also: go build, go get, go clean. 575 // 576 // 577 // List packages 578 // 579 // Usage: 580 // 581 // go list [-e] [-f format] [-json] [build flags] [packages] 582 // 583 // List lists the packages named by the import paths, one per line. 584 // 585 // The default output shows the package import path: 586 // 587 // bytes 588 // encoding/json 589 // github.com/gorilla/mux 590 // golang.org/x/net/html 591 // 592 // The -f flag specifies an alternate format for the list, using the 593 // syntax of package template. The default output is equivalent to -f 594 // '{{.ImportPath}}'. The struct being passed to the template is: 595 // 596 // type Package struct { 597 // Dir string // directory containing package sources 598 // ImportPath string // import path of package in dir 599 // ImportComment string // path in import comment on package statement 600 // Name string // package name 601 // Doc string // package documentation string 602 // Target string // install path 603 // Shlib string // the shared library that contains this package (only set when -linkshared) 604 // Goroot bool // is this package in the Go root? 605 // Standard bool // is this package part of the standard Go library? 606 // Stale bool // would 'go install' do anything for this package? 607 // StaleReason string // explanation for Stale==true 608 // Root string // Go root or Go path dir containing this package 609 // ConflictDir string // this directory shadows Dir in $GOPATH 610 // BinaryOnly bool // binary-only package: cannot be recompiled from sources 611 // 612 // // Source files 613 // GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles) 614 // CgoFiles []string // .go sources files that import "C" 615 // IgnoredGoFiles []string // .go sources ignored due to build constraints 616 // CFiles []string // .c source files 617 // CXXFiles []string // .cc, .cxx and .cpp source files 618 // MFiles []string // .m source files 619 // HFiles []string // .h, .hh, .hpp and .hxx source files 620 // FFiles []string // .f, .F, .for and .f90 Fortran source files 621 // SFiles []string // .s source files 622 // SwigFiles []string // .swig files 623 // SwigCXXFiles []string // .swigcxx files 624 // SysoFiles []string // .syso object files to add to archive 625 // TestGoFiles []string // _test.go files in package 626 // XTestGoFiles []string // _test.go files outside package 627 // 628 // // Cgo directives 629 // CgoCFLAGS []string // cgo: flags for C compiler 630 // CgoCPPFLAGS []string // cgo: flags for C preprocessor 631 // CgoCXXFLAGS []string // cgo: flags for C++ compiler 632 // CgoFFLAGS []string // cgo: flags for Fortran compiler 633 // CgoLDFLAGS []string // cgo: flags for linker 634 // CgoPkgConfig []string // cgo: pkg-config names 635 // 636 // // Dependency information 637 // Imports []string // import paths used by this package 638 // Deps []string // all (recursively) imported dependencies 639 // TestImports []string // imports from TestGoFiles 640 // XTestImports []string // imports from XTestGoFiles 641 // 642 // // Error information 643 // Incomplete bool // this package or a dependency has an error 644 // Error *PackageError // error loading package 645 // DepsErrors []*PackageError // errors loading dependencies 646 // } 647 // 648 // Packages stored in vendor directories report an ImportPath that includes the 649 // path to the vendor directory (for example, "d/vendor/p" instead of "p"), 650 // so that the ImportPath uniquely identifies a given copy of a package. 651 // The Imports, Deps, TestImports, and XTestImports lists also contain these 652 // expanded imports paths. See golang.org/s/go15vendor for more about vendoring. 653 // 654 // The error information, if any, is 655 // 656 // type PackageError struct { 657 // ImportStack []string // shortest path from package named on command line to this one 658 // Pos string // position of error (if present, file:line:col) 659 // Err string // the error itself 660 // } 661 // 662 // The template function "join" calls strings.Join. 663 // 664 // The template function "context" returns the build context, defined as: 665 // 666 // type Context struct { 667 // GOARCH string // target architecture 668 // GOOS string // target operating system 669 // GOROOT string // Go root 670 // GOPATH string // Go path 671 // CgoEnabled bool // whether cgo can be used 672 // UseAllFiles bool // use files regardless of +build lines, file names 673 // Compiler string // compiler to assume when computing target paths 674 // BuildTags []string // build constraints to match in +build lines 675 // ReleaseTags []string // releases the current release is compatible with 676 // InstallSuffix string // suffix to use in the name of the install dir 677 // } 678 // 679 // For more information about the meaning of these fields see the documentation 680 // for the go/build package's Context type. 681 // 682 // The -json flag causes the package data to be printed in JSON format 683 // instead of using the template format. 684 // 685 // The -e flag changes the handling of erroneous packages, those that 686 // cannot be found or are malformed. By default, the list command 687 // prints an error to standard error for each erroneous package and 688 // omits the packages from consideration during the usual printing. 689 // With the -e flag, the list command never prints errors to standard 690 // error and instead processes the erroneous packages with the usual 691 // printing. Erroneous packages will have a non-empty ImportPath and 692 // a non-nil Error field; other information may or may not be missing 693 // (zeroed). 694 // 695 // For more about build flags, see 'go help build'. 696 // 697 // For more about specifying packages, see 'go help packages'. 698 // 699 // 700 // Compile and run Go program 701 // 702 // Usage: 703 // 704 // go run [build flags] [-exec xprog] gofiles... [arguments...] 705 // 706 // Run compiles and runs the main package comprising the named Go source files. 707 // A Go source file is defined to be a file ending in a literal ".go" suffix. 708 // 709 // By default, 'go run' runs the compiled binary directly: 'a.out arguments...'. 710 // If the -exec flag is given, 'go run' invokes the binary using xprog: 711 // 'xprog a.out arguments...'. 712 // If the -exec flag is not given, GOOS or GOARCH is different from the system 713 // default, and a program named go_$GOOS_$GOARCH_exec can be found 714 // on the current search path, 'go run' invokes the binary using that program, 715 // for example 'go_nacl_386_exec a.out arguments...'. This allows execution of 716 // cross-compiled programs when a simulator or other execution method is 717 // available. 718 // 719 // For more about build flags, see 'go help build'. 720 // 721 // See also: go build. 722 // 723 // 724 // Test packages 725 // 726 // Usage: 727 // 728 // go test [build/test flags] [packages] [build/test flags & test binary flags] 729 // 730 // 'Go test' automates testing the packages named by the import paths. 731 // It prints a summary of the test results in the format: 732 // 733 // ok archive/tar 0.011s 734 // FAIL archive/zip 0.022s 735 // ok compress/gzip 0.033s 736 // ... 737 // 738 // followed by detailed output for each failed package. 739 // 740 // 'Go test' recompiles each package along with any files with names matching 741 // the file pattern "*_test.go". 742 // These additional files can contain test functions, benchmark functions, and 743 // example functions. See 'go help testfunc' for more. 744 // Each listed package causes the execution of a separate test binary. 745 // Files whose names begin with "_" (including "_test.go") or "." are ignored. 746 // 747 // Test files that declare a package with the suffix "_test" will be compiled as a 748 // separate package, and then linked and run with the main test binary. 749 // 750 // The go tool will ignore a directory named "testdata", making it available 751 // to hold ancillary data needed by the tests. 752 // 753 // As part of building a test binary, go test runs go vet on the package 754 // and its test source files to identify significant problems. If go vet 755 // finds any problems, go test reports those and does not run the test binary. 756 // Only a high-confidence subset of the default go vet checks are used. 757 // To disable the running of go vet, use the -vet=off flag. 758 // 759 // All test output and summary lines are printed to the go command's 760 // standard output, even if the test printed them to its own standard 761 // error. (The go command's standard error is reserved for printing 762 // errors building the tests.) 763 // 764 // Go test runs in two different modes: 765 // 766 // The first, called local directory mode, occurs when go test is 767 // invoked with no package arguments (for example, 'go test' or 'go 768 // test -v'). In this mode, go test compiles the package sources and 769 // tests found in the current directory and then runs the resulting 770 // test binary. In this mode, caching (discussed below) is disabled. 771 // After the package test finishes, go test prints a summary line 772 // showing the test status ('ok' or 'FAIL'), package name, and elapsed 773 // time. 774 // 775 // The second, called package list mode, occurs when go test is invoked 776 // with explicit package arguments (for example 'go test math', 'go 777 // test ./...', and even 'go test .'). In this mode, go test compiles 778 // and tests each of the packages listed on the command line. If a 779 // package test passes, go test prints only the final 'ok' summary 780 // line. If a package test fails, go test prints the full test output. 781 // If invoked with the -bench or -v flag, go test prints the full 782 // output even for passing package tests, in order to display the 783 // requested benchmark results or verbose logging. 784 // 785 // In package list mode only, go test caches successful package test 786 // results to avoid unnecessary repeated running of tests. When the 787 // result of a test can be recovered from the cache, go test will 788 // redisplay the previous output instead of running the test binary 789 // again. When this happens, go test prints '(cached)' in place of the 790 // elapsed time in the summary line. 791 // 792 // The rule for a match in the cache is that the run involves the same 793 // test binary and the flags on the command line come entirely from a 794 // restricted set of 'cacheable' test flags, defined as -cpu, -list, 795 // -parallel, -run, -short, and -v. If a run of go test has any test 796 // or non-test flags outside this set, the result is not cached. To 797 // disable test caching, use any test flag or argument other than the 798 // cacheable flags. The idiomatic way to disable test caching explicitly 799 // is to use -count=1. A cached result is treated as executing in no 800 // time at all, so a successful package test result will be cached and 801 // reused regardless of -timeout setting. 802 // 803 // In addition to the build flags, the flags handled by 'go test' itself are: 804 // 805 // -args 806 // Pass the remainder of the command line (everything after -args) 807 // to the test binary, uninterpreted and unchanged. 808 // Because this flag consumes the remainder of the command line, 809 // the package list (if present) must appear before this flag. 810 // 811 // -c 812 // Compile the test binary to pkg.test but do not run it 813 // (where pkg is the last element of the package's import path). 814 // The file name can be changed with the -o flag. 815 // 816 // -exec xprog 817 // Run the test binary using xprog. The behavior is the same as 818 // in 'go run'. See 'go help run' for details. 819 // 820 // -i 821 // Install packages that are dependencies of the test. 822 // Do not run the test. 823 // 824 // -json 825 // Convert test output to JSON suitable for automated processing. 826 // See 'go doc test2json' for the encoding details. 827 // 828 // -o file 829 // Compile the test binary to the named file. 830 // The test still runs (unless -c or -i is specified). 831 // 832 // The test binary also accepts flags that control execution of the test; these 833 // flags are also accessible by 'go test'. See 'go help testflag' for details. 834 // 835 // For more about build flags, see 'go help build'. 836 // For more about specifying packages, see 'go help packages'. 837 // 838 // See also: go build, go vet. 839 // 840 // 841 // Run specified go tool 842 // 843 // Usage: 844 // 845 // go tool [-n] command [args...] 846 // 847 // Tool runs the go tool command identified by the arguments. 848 // With no arguments it prints the list of known tools. 849 // 850 // The -n flag causes tool to print the command that would be 851 // executed but not execute it. 852 // 853 // For more about each tool command, see 'go doc cmd/<command>'. 854 // 855 // 856 // Print Go version 857 // 858 // Usage: 859 // 860 // go version 861 // 862 // Version prints the Go version, as reported by runtime.Version. 863 // 864 // 865 // Report likely mistakes in packages 866 // 867 // Usage: 868 // 869 // go vet [-n] [-x] [build flags] [vet flags] [packages] 870 // 871 // Vet runs the Go vet command on the packages named by the import paths. 872 // 873 // For more about vet and its flags, see 'go doc cmd/vet'. 874 // For more about specifying packages, see 'go help packages'. 875 // 876 // The -n flag prints commands that would be executed. 877 // The -x flag prints commands as they are executed. 878 // 879 // The build flags supported by go vet are those that control package resolution 880 // and execution, such as -n, -x, -v, -tags, and -toolexec. 881 // For more about these flags, see 'go help build'. 882 // 883 // See also: go fmt, go fix. 884 // 885 // 886 // Calling between Go and C 887 // 888 // There are two different ways to call between Go and C/C++ code. 889 // 890 // The first is the cgo tool, which is part of the Go distribution. For 891 // information on how to use it see the cgo documentation (go doc cmd/cgo). 892 // 893 // The second is the SWIG program, which is a general tool for 894 // interfacing between languages. For information on SWIG see 895 // http://swig.org/. When running go build, any file with a .swig 896 // extension will be passed to SWIG. Any file with a .swigcxx extension 897 // will be passed to SWIG with the -c++ option. 898 // 899 // When either cgo or SWIG is used, go build will pass any .c, .m, .s, 900 // or .S files to the C compiler, and any .cc, .cpp, .cxx files to the C++ 901 // compiler. The CC or CXX environment variables may be set to determine 902 // the C or C++ compiler, respectively, to use. 903 // 904 // 905 // Description of build modes 906 // 907 // The 'go build' and 'go install' commands take a -buildmode argument which 908 // indicates which kind of object file is to be built. Currently supported values 909 // are: 910 // 911 // -buildmode=archive 912 // Build the listed non-main packages into .a files. Packages named 913 // main are ignored. 914 // 915 // -buildmode=c-archive 916 // Build the listed main package, plus all packages it imports, 917 // into a C archive file. The only callable symbols will be those 918 // functions exported using a cgo //export comment. Requires 919 // exactly one main package to be listed. 920 // 921 // -buildmode=c-shared 922 // Build the listed main package, plus all packages it imports, 923 // into a C shared library. The only callable symbols will 924 // be those functions exported using a cgo //export comment. 925 // Requires exactly one main package to be listed. 926 // 927 // -buildmode=default 928 // Listed main packages are built into executables and listed 929 // non-main packages are built into .a files (the default 930 // behavior). 931 // 932 // -buildmode=shared 933 // Combine all the listed non-main packages into a single shared 934 // library that will be used when building with the -linkshared 935 // option. Packages named main are ignored. 936 // 937 // -buildmode=exe 938 // Build the listed main packages and everything they import into 939 // executables. Packages not named main are ignored. 940 // 941 // -buildmode=pie 942 // Build the listed main packages and everything they import into 943 // position independent executables (PIE). Packages not named 944 // main are ignored. 945 // 946 // -buildmode=plugin 947 // Build the listed main packages, plus all packages that they 948 // import, into a Go plugin. Packages not named main are ignored. 949 // 950 // 951 // File types 952 // 953 // The go command examines the contents of a restricted set of files 954 // in each directory. It identifies which files to examine based on 955 // the extension of the file name. These extensions are: 956 // 957 // .go 958 // Go source files. 959 // .c, .h 960 // C source files. 961 // If the package uses cgo or SWIG, these will be compiled with the 962 // OS-native compiler (typically gcc); otherwise they will 963 // trigger an error. 964 // .cc, .cpp, .cxx, .hh, .hpp, .hxx 965 // C++ source files. Only useful with cgo or SWIG, and always 966 // compiled with the OS-native compiler. 967 // .m 968 // Objective-C source files. Only useful with cgo, and always 969 // compiled with the OS-native compiler. 970 // .s, .S 971 // Assembler source files. 972 // If the package uses cgo or SWIG, these will be assembled with the 973 // OS-native assembler (typically gcc (sic)); otherwise they 974 // will be assembled with the Go assembler. 975 // .swig, .swigcxx 976 // SWIG definition files. 977 // .syso 978 // System object files. 979 // 980 // Files of each of these types except .syso may contain build 981 // constraints, but the go command stops scanning for build constraints 982 // at the first item in the file that is not a blank line or //-style 983 // line comment. See the go/build package documentation for 984 // more details. 985 // 986 // Non-test Go source files can also include a //go:binary-only-package 987 // comment, indicating that the package sources are included 988 // for documentation only and must not be used to build the 989 // package binary. This enables distribution of Go packages in 990 // their compiled form alone. Even binary-only packages require 991 // accurate import blocks listing required dependencies, so that 992 // those dependencies can be supplied when linking the resulting 993 // command. 994 // 995 // 996 // GOPATH environment variable 997 // 998 // The Go path is used to resolve import statements. 999 // It is implemented by and documented in the go/build package. 1000 // 1001 // The GOPATH environment variable lists places to look for Go code. 1002 // On Unix, the value is a colon-separated string. 1003 // On Windows, the value is a semicolon-separated string. 1004 // On Plan 9, the value is a list. 1005 // 1006 // If the environment variable is unset, GOPATH defaults 1007 // to a subdirectory named "go" in the user's home directory 1008 // ($HOME/go on Unix, %USERPROFILE%\go on Windows), 1009 // unless that directory holds a Go distribution. 1010 // Run "go env GOPATH" to see the current GOPATH. 1011 // 1012 // See https://golang.org/wiki/SettingGOPATH to set a custom GOPATH. 1013 // 1014 // Each directory listed in GOPATH must have a prescribed structure: 1015 // 1016 // The src directory holds source code. The path below src 1017 // determines the import path or executable name. 1018 // 1019 // The pkg directory holds installed package objects. 1020 // As in the Go tree, each target operating system and 1021 // architecture pair has its own subdirectory of pkg 1022 // (pkg/GOOS_GOARCH). 1023 // 1024 // If DIR is a directory listed in the GOPATH, a package with 1025 // source in DIR/src/foo/bar can be imported as "foo/bar" and 1026 // has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a". 1027 // 1028 // The bin directory holds compiled commands. 1029 // Each command is named for its source directory, but only 1030 // the final element, not the entire path. That is, the 1031 // command with source in DIR/src/foo/quux is installed into 1032 // DIR/bin/quux, not DIR/bin/foo/quux. The "foo/" prefix is stripped 1033 // so that you can add DIR/bin to your PATH to get at the 1034 // installed commands. If the GOBIN environment variable is 1035 // set, commands are installed to the directory it names instead 1036 // of DIR/bin. GOBIN must be an absolute path. 1037 // 1038 // Here's an example directory layout: 1039 // 1040 // GOPATH=/home/user/go 1041 // 1042 // /home/user/go/ 1043 // src/ 1044 // foo/ 1045 // bar/ (go code in package bar) 1046 // x.go 1047 // quux/ (go code in package main) 1048 // y.go 1049 // bin/ 1050 // quux (installed command) 1051 // pkg/ 1052 // linux_amd64/ 1053 // foo/ 1054 // bar.a (installed package object) 1055 // 1056 // Go searches each directory listed in GOPATH to find source code, 1057 // but new packages are always downloaded into the first directory 1058 // in the list. 1059 // 1060 // See https://golang.org/doc/code.html for an example. 1061 // 1062 // Internal Directories 1063 // 1064 // Code in or below a directory named "internal" is importable only 1065 // by code in the directory tree rooted at the parent of "internal". 1066 // Here's an extended version of the directory layout above: 1067 // 1068 // /home/user/go/ 1069 // src/ 1070 // crash/ 1071 // bang/ (go code in package bang) 1072 // b.go 1073 // foo/ (go code in package foo) 1074 // f.go 1075 // bar/ (go code in package bar) 1076 // x.go 1077 // internal/ 1078 // baz/ (go code in package baz) 1079 // z.go 1080 // quux/ (go code in package main) 1081 // y.go 1082 // 1083 // 1084 // The code in z.go is imported as "foo/internal/baz", but that 1085 // import statement can only appear in source files in the subtree 1086 // rooted at foo. The source files foo/f.go, foo/bar/x.go, and 1087 // foo/quux/y.go can all import "foo/internal/baz", but the source file 1088 // crash/bang/b.go cannot. 1089 // 1090 // See https://golang.org/s/go14internal for details. 1091 // 1092 // Vendor Directories 1093 // 1094 // Go 1.6 includes support for using local copies of external dependencies 1095 // to satisfy imports of those dependencies, often referred to as vendoring. 1096 // 1097 // Code below a directory named "vendor" is importable only 1098 // by code in the directory tree rooted at the parent of "vendor", 1099 // and only using an import path that omits the prefix up to and 1100 // including the vendor element. 1101 // 1102 // Here's the example from the previous section, 1103 // but with the "internal" directory renamed to "vendor" 1104 // and a new foo/vendor/crash/bang directory added: 1105 // 1106 // /home/user/go/ 1107 // src/ 1108 // crash/ 1109 // bang/ (go code in package bang) 1110 // b.go 1111 // foo/ (go code in package foo) 1112 // f.go 1113 // bar/ (go code in package bar) 1114 // x.go 1115 // vendor/ 1116 // crash/ 1117 // bang/ (go code in package bang) 1118 // b.go 1119 // baz/ (go code in package baz) 1120 // z.go 1121 // quux/ (go code in package main) 1122 // y.go 1123 // 1124 // The same visibility rules apply as for internal, but the code 1125 // in z.go is imported as "baz", not as "foo/vendor/baz". 1126 // 1127 // Code in vendor directories deeper in the source tree shadows 1128 // code in higher directories. Within the subtree rooted at foo, an import 1129 // of "crash/bang" resolves to "foo/vendor/crash/bang", not the 1130 // top-level "crash/bang". 1131 // 1132 // Code in vendor directories is not subject to import path 1133 // checking (see 'go help importpath'). 1134 // 1135 // When 'go get' checks out or updates a git repository, it now also 1136 // updates submodules. 1137 // 1138 // Vendor directories do not affect the placement of new repositories 1139 // being checked out for the first time by 'go get': those are always 1140 // placed in the main GOPATH, never in a vendor subtree. 1141 // 1142 // See https://golang.org/s/go15vendor for details. 1143 // 1144 // 1145 // Environment variables 1146 // 1147 // The go command, and the tools it invokes, examine a few different 1148 // environment variables. For many of these, you can see the default 1149 // value of on your system by running 'go env NAME', where NAME is the 1150 // name of the variable. 1151 // 1152 // General-purpose environment variables: 1153 // 1154 // GCCGO 1155 // The gccgo command to run for 'go build -compiler=gccgo'. 1156 // GOARCH 1157 // The architecture, or processor, for which to compile code. 1158 // Examples are amd64, 386, arm, ppc64. 1159 // GOBIN 1160 // The directory where 'go install' will install a command. 1161 // GOOS 1162 // The operating system for which to compile code. 1163 // Examples are linux, darwin, windows, netbsd. 1164 // GOPATH 1165 // For more details see: 'go help gopath'. 1166 // GORACE 1167 // Options for the race detector. 1168 // See https://golang.org/doc/articles/race_detector.html. 1169 // GOROOT 1170 // The root of the go tree. 1171 // GOTMPDIR 1172 // The directory where the go command will write 1173 // temporary source files, packages, and binaries. 1174 // GOCACHE 1175 // The directory where the go command will store 1176 // cached information for reuse in future builds. 1177 // 1178 // Environment variables for use with cgo: 1179 // 1180 // CC 1181 // The command to use to compile C code. 1182 // CGO_ENABLED 1183 // Whether the cgo command is supported. Either 0 or 1. 1184 // CGO_CFLAGS 1185 // Flags that cgo will pass to the compiler when compiling 1186 // C code. 1187 // CGO_CPPFLAGS 1188 // Flags that cgo will pass to the compiler when compiling 1189 // C or C++ code. 1190 // CGO_CXXFLAGS 1191 // Flags that cgo will pass to the compiler when compiling 1192 // C++ code. 1193 // CGO_FFLAGS 1194 // Flags that cgo will pass to the compiler when compiling 1195 // Fortran code. 1196 // CGO_LDFLAGS 1197 // Flags that cgo will pass to the compiler when linking. 1198 // CXX 1199 // The command to use to compile C++ code. 1200 // PKG_CONFIG 1201 // Path to pkg-config tool. 1202 // 1203 // Architecture-specific environment variables: 1204 // 1205 // GOARM 1206 // For GOARCH=arm, the ARM architecture for which to compile. 1207 // Valid values are 5, 6, 7. 1208 // GO386 1209 // For GOARCH=386, the floating point instruction set. 1210 // Valid values are 387, sse2. 1211 // GOMIPS 1212 // For GOARCH=mips{,le}, whether to use floating point instructions. 1213 // Valid values are hardfloat (default), softfloat. 1214 // 1215 // Special-purpose environment variables: 1216 // 1217 // GOROOT_FINAL 1218 // The root of the installed Go tree, when it is 1219 // installed in a location other than where it is built. 1220 // File names in stack traces are rewritten from GOROOT to 1221 // GOROOT_FINAL. 1222 // GO_EXTLINK_ENABLED 1223 // Whether the linker should use external linking mode 1224 // when using -linkmode=auto with code that uses cgo. 1225 // Set to 0 to disable external linking mode, 1 to enable it. 1226 // GIT_ALLOW_PROTOCOL 1227 // Defined by Git. A colon-separated list of schemes that are allowed to be used 1228 // with git fetch/clone. If set, any scheme not explicitly mentioned will be 1229 // considered insecure by 'go get'. 1230 // 1231 // 1232 // Import path syntax 1233 // 1234 // An import path (see 'go help packages') denotes a package stored in the local 1235 // file system. In general, an import path denotes either a standard package (such 1236 // as "unicode/utf8") or a package found in one of the work spaces (For more 1237 // details see: 'go help gopath'). 1238 // 1239 // Relative import paths 1240 // 1241 // An import path beginning with ./ or ../ is called a relative path. 1242 // The toolchain supports relative import paths as a shortcut in two ways. 1243 // 1244 // First, a relative path can be used as a shorthand on the command line. 1245 // If you are working in the directory containing the code imported as 1246 // "unicode" and want to run the tests for "unicode/utf8", you can type 1247 // "go test ./utf8" instead of needing to specify the full path. 1248 // Similarly, in the reverse situation, "go test .." will test "unicode" from 1249 // the "unicode/utf8" directory. Relative patterns are also allowed, like 1250 // "go test ./..." to test all subdirectories. See 'go help packages' for details 1251 // on the pattern syntax. 1252 // 1253 // Second, if you are compiling a Go program not in a work space, 1254 // you can use a relative path in an import statement in that program 1255 // to refer to nearby code also not in a work space. 1256 // This makes it easy to experiment with small multipackage programs 1257 // outside of the usual work spaces, but such programs cannot be 1258 // installed with "go install" (there is no work space in which to install them), 1259 // so they are rebuilt from scratch each time they are built. 1260 // To avoid ambiguity, Go programs cannot use relative import paths 1261 // within a work space. 1262 // 1263 // Remote import paths 1264 // 1265 // Certain import paths also 1266 // describe how to obtain the source code for the package using 1267 // a revision control system. 1268 // 1269 // A few common code hosting sites have special syntax: 1270 // 1271 // Bitbucket (Git, Mercurial) 1272 // 1273 // import "bitbucket.org/user/project" 1274 // import "bitbucket.org/user/project/sub/directory" 1275 // 1276 // GitHub (Git) 1277 // 1278 // import "github.com/user/project" 1279 // import "github.com/user/project/sub/directory" 1280 // 1281 // Launchpad (Bazaar) 1282 // 1283 // import "launchpad.net/project" 1284 // import "launchpad.net/project/series" 1285 // import "launchpad.net/project/series/sub/directory" 1286 // 1287 // import "launchpad.net/~user/project/branch" 1288 // import "launchpad.net/~user/project/branch/sub/directory" 1289 // 1290 // IBM DevOps Services (Git) 1291 // 1292 // import "hub.jazz.net/git/user/project" 1293 // import "hub.jazz.net/git/user/project/sub/directory" 1294 // 1295 // For code hosted on other servers, import paths may either be qualified 1296 // with the version control type, or the go tool can dynamically fetch 1297 // the import path over https/http and discover where the code resides 1298 // from a <meta> tag in the HTML. 1299 // 1300 // To declare the code location, an import path of the form 1301 // 1302 // repository.vcs/path 1303 // 1304 // specifies the given repository, with or without the .vcs suffix, 1305 // using the named version control system, and then the path inside 1306 // that repository. The supported version control systems are: 1307 // 1308 // Bazaar .bzr 1309 // Git .git 1310 // Mercurial .hg 1311 // Subversion .svn 1312 // 1313 // For example, 1314 // 1315 // import "example.org/user/foo.hg" 1316 // 1317 // denotes the root directory of the Mercurial repository at 1318 // example.org/user/foo or foo.hg, and 1319 // 1320 // import "example.org/repo.git/foo/bar" 1321 // 1322 // denotes the foo/bar directory of the Git repository at 1323 // example.org/repo or repo.git. 1324 // 1325 // When a version control system supports multiple protocols, 1326 // each is tried in turn when downloading. For example, a Git 1327 // download tries https://, then git+ssh://. 1328 // 1329 // By default, downloads are restricted to known secure protocols 1330 // (e.g. https, ssh). To override this setting for Git downloads, the 1331 // GIT_ALLOW_PROTOCOL environment variable can be set (For more details see: 1332 // 'go help environment'). 1333 // 1334 // If the import path is not a known code hosting site and also lacks a 1335 // version control qualifier, the go tool attempts to fetch the import 1336 // over https/http and looks for a <meta> tag in the document's HTML 1337 // <head>. 1338 // 1339 // The meta tag has the form: 1340 // 1341 // <meta name="go-import" content="import-prefix vcs repo-root"> 1342 // 1343 // The import-prefix is the import path corresponding to the repository 1344 // root. It must be a prefix or an exact match of the package being 1345 // fetched with "go get". If it's not an exact match, another http 1346 // request is made at the prefix to verify the <meta> tags match. 1347 // 1348 // The meta tag should appear as early in the file as possible. 1349 // In particular, it should appear before any raw JavaScript or CSS, 1350 // to avoid confusing the go command's restricted parser. 1351 // 1352 // The vcs is one of "git", "hg", "svn", etc, 1353 // 1354 // The repo-root is the root of the version control system 1355 // containing a scheme and not containing a .vcs qualifier. 1356 // 1357 // For example, 1358 // 1359 // import "example.org/pkg/foo" 1360 // 1361 // will result in the following requests: 1362 // 1363 // https://example.org/pkg/foo?go-get=1 (preferred) 1364 // http://example.org/pkg/foo?go-get=1 (fallback, only with -insecure) 1365 // 1366 // If that page contains the meta tag 1367 // 1368 // <meta name="go-import" content="example.org git https://code.org/r/p/exproj"> 1369 // 1370 // the go tool will verify that https://example.org/?go-get=1 contains the 1371 // same meta tag and then git clone https://code.org/r/p/exproj into 1372 // GOPATH/src/example.org. 1373 // 1374 // New downloaded packages are written to the first directory listed in the GOPATH 1375 // environment variable (For more details see: 'go help gopath'). 1376 // 1377 // The go command attempts to download the version of the 1378 // package appropriate for the Go release being used. 1379 // Run 'go help get' for more. 1380 // 1381 // Import path checking 1382 // 1383 // When the custom import path feature described above redirects to a 1384 // known code hosting site, each of the resulting packages has two possible 1385 // import paths, using the custom domain or the known hosting site. 1386 // 1387 // A package statement is said to have an "import comment" if it is immediately 1388 // followed (before the next newline) by a comment of one of these two forms: 1389 // 1390 // package math // import "path" 1391 // package math /* import "path" */ 1392 // 1393 // The go command will refuse to install a package with an import comment 1394 // unless it is being referred to by that import path. In this way, import comments 1395 // let package authors make sure the custom import path is used and not a 1396 // direct path to the underlying code hosting site. 1397 // 1398 // Import path checking is disabled for code found within vendor trees. 1399 // This makes it possible to copy code into alternate locations in vendor trees 1400 // without needing to update import comments. 1401 // 1402 // See https://golang.org/s/go14customimport for details. 1403 // 1404 // 1405 // Description of package lists 1406 // 1407 // Many commands apply to a set of packages: 1408 // 1409 // go action [packages] 1410 // 1411 // Usually, [packages] is a list of import paths. 1412 // 1413 // An import path that is a rooted path or that begins with 1414 // a . or .. element is interpreted as a file system path and 1415 // denotes the package in that directory. 1416 // 1417 // Otherwise, the import path P denotes the package found in 1418 // the directory DIR/src/P for some DIR listed in the GOPATH 1419 // environment variable (For more details see: 'go help gopath'). 1420 // 1421 // If no import paths are given, the action applies to the 1422 // package in the current directory. 1423 // 1424 // There are four reserved names for paths that should not be used 1425 // for packages to be built with the go tool: 1426 // 1427 // - "main" denotes the top-level package in a stand-alone executable. 1428 // 1429 // - "all" expands to all package directories found in all the GOPATH 1430 // trees. For example, 'go list all' lists all the packages on the local 1431 // system. 1432 // 1433 // - "std" is like all but expands to just the packages in the standard 1434 // Go library. 1435 // 1436 // - "cmd" expands to the Go repository's commands and their 1437 // internal libraries. 1438 // 1439 // Import paths beginning with "cmd/" only match source code in 1440 // the Go repository. 1441 // 1442 // An import path is a pattern if it includes one or more "..." wildcards, 1443 // each of which can match any string, including the empty string and 1444 // strings containing slashes. Such a pattern expands to all package 1445 // directories found in the GOPATH trees with names matching the 1446 // patterns. 1447 // 1448 // To make common patterns more convenient, there are two special cases. 1449 // First, /... at the end of the pattern can match an empty string, 1450 // so that net/... matches both net and packages in its subdirectories, like net/http. 1451 // Second, any slash-separated pattern element containing a wildcard never 1452 // participates in a match of the "vendor" element in the path of a vendored 1453 // package, so that ./... does not match packages in subdirectories of 1454 // ./vendor or ./mycode/vendor, but ./vendor/... and ./mycode/vendor/... do. 1455 // Note, however, that a directory named vendor that itself contains code 1456 // is not a vendored package: cmd/vendor would be a command named vendor, 1457 // and the pattern cmd/... matches it. 1458 // See golang.org/s/go15vendor for more about vendoring. 1459 // 1460 // An import path can also name a package to be downloaded from 1461 // a remote repository. Run 'go help importpath' for details. 1462 // 1463 // Every package in a program must have a unique import path. 1464 // By convention, this is arranged by starting each path with a 1465 // unique prefix that belongs to you. For example, paths used 1466 // internally at Google all begin with 'google', and paths 1467 // denoting remote repositories begin with the path to the code, 1468 // such as 'github.com/user/repo'. 1469 // 1470 // Packages in a program need not have unique package names, 1471 // but there are two reserved package names with special meaning. 1472 // The name main indicates a command, not a library. 1473 // Commands are built into binaries and cannot be imported. 1474 // The name documentation indicates documentation for 1475 // a non-Go program in the directory. Files in package documentation 1476 // are ignored by the go command. 1477 // 1478 // As a special case, if the package list is a list of .go files from a 1479 // single directory, the command is applied to a single synthesized 1480 // package made up of exactly those files, ignoring any build constraints 1481 // in those files and ignoring any other files in the directory. 1482 // 1483 // Directory and file names that begin with "." or "_" are ignored 1484 // by the go tool, as are directories named "testdata". 1485 // 1486 // 1487 // Description of testing flags 1488 // 1489 // The 'go test' command takes both flags that apply to 'go test' itself 1490 // and flags that apply to the resulting test binary. 1491 // 1492 // Several of the flags control profiling and write an execution profile 1493 // suitable for "go tool pprof"; run "go tool pprof -h" for more 1494 // information. The --alloc_space, --alloc_objects, and --show_bytes 1495 // options of pprof control how the information is presented. 1496 // 1497 // The following flags are recognized by the 'go test' command and 1498 // control the execution of any test: 1499 // 1500 // -bench regexp 1501 // Run only those benchmarks matching a regular expression. 1502 // By default, no benchmarks are run. 1503 // To run all benchmarks, use '-bench .' or '-bench=.'. 1504 // The regular expression is split by unbracketed slash (/) 1505 // characters into a sequence of regular expressions, and each 1506 // part of a benchmark's identifier must match the corresponding 1507 // element in the sequence, if any. Possible parents of matches 1508 // are run with b.N=1 to identify sub-benchmarks. For example, 1509 // given -bench=X/Y, top-level benchmarks matching X are run 1510 // with b.N=1 to find any sub-benchmarks matching Y, which are 1511 // then run in full. 1512 // 1513 // -benchtime t 1514 // Run enough iterations of each benchmark to take t, specified 1515 // as a time.Duration (for example, -benchtime 1h30s). 1516 // The default is 1 second (1s). 1517 // 1518 // -count n 1519 // Run each test and benchmark n times (default 1). 1520 // If -cpu is set, run n times for each GOMAXPROCS value. 1521 // Examples are always run once. 1522 // 1523 // -cover 1524 // Enable coverage analysis. 1525 // Note that because coverage works by annotating the source 1526 // code before compilation, compilation and test failures with 1527 // coverage enabled may report line numbers that don't correspond 1528 // to the original sources. 1529 // 1530 // -covermode set,count,atomic 1531 // Set the mode for coverage analysis for the package[s] 1532 // being tested. The default is "set" unless -race is enabled, 1533 // in which case it is "atomic". 1534 // The values: 1535 // set: bool: does this statement run? 1536 // count: int: how many times does this statement run? 1537 // atomic: int: count, but correct in multithreaded tests; 1538 // significantly more expensive. 1539 // Sets -cover. 1540 // 1541 // -coverpkg pattern1,pattern2,pattern3 1542 // Apply coverage analysis in each test to packages matching the patterns. 1543 // The default is for each test to analyze only the package being tested. 1544 // See 'go help packages' for a description of package patterns. 1545 // Sets -cover. 1546 // 1547 // -cpu 1,2,4 1548 // Specify a list of GOMAXPROCS values for which the tests or 1549 // benchmarks should be executed. The default is the current value 1550 // of GOMAXPROCS. 1551 // 1552 // -failfast 1553 // Do not start new tests after the first test failure. 1554 // 1555 // -list regexp 1556 // List tests, benchmarks, or examples matching the regular expression. 1557 // No tests, benchmarks or examples will be run. This will only 1558 // list top-level tests. No subtest or subbenchmarks will be shown. 1559 // 1560 // -parallel n 1561 // Allow parallel execution of test functions that call t.Parallel. 1562 // The value of this flag is the maximum number of tests to run 1563 // simultaneously; by default, it is set to the value of GOMAXPROCS. 1564 // Note that -parallel only applies within a single test binary. 1565 // The 'go test' command may run tests for different packages 1566 // in parallel as well, according to the setting of the -p flag 1567 // (see 'go help build'). 1568 // 1569 // -run regexp 1570 // Run only those tests and examples matching the regular expression. 1571 // For tests, the regular expression is split by unbracketed slash (/) 1572 // characters into a sequence of regular expressions, and each part 1573 // of a test's identifier must match the corresponding element in 1574 // the sequence, if any. Note that possible parents of matches are 1575 // run too, so that -run=X/Y matches and runs and reports the result 1576 // of all tests matching X, even those without sub-tests matching Y, 1577 // because it must run them to look for those sub-tests. 1578 // 1579 // -short 1580 // Tell long-running tests to shorten their run time. 1581 // It is off by default but set during all.bash so that installing 1582 // the Go tree can run a sanity check but not spend time running 1583 // exhaustive tests. 1584 // 1585 // -timeout d 1586 // If a test binary runs longer than duration d, panic. 1587 // If d is 0, the timeout is disabled. 1588 // The default is 10 minutes (10m). 1589 // 1590 // -v 1591 // Verbose output: log all tests as they are run. Also print all 1592 // text from Log and Logf calls even if the test succeeds. 1593 // 1594 // -vet list 1595 // Configure the invocation of "go vet" during "go test" 1596 // to use the comma-separated list of vet checks. 1597 // If list is empty, "go test" runs "go vet" with a curated list of 1598 // checks believed to be always worth addressing. 1599 // If list is "off", "go test" does not run "go vet" at all. 1600 // 1601 // The following flags are also recognized by 'go test' and can be used to 1602 // profile the tests during execution: 1603 // 1604 // -benchmem 1605 // Print memory allocation statistics for benchmarks. 1606 // 1607 // -blockprofile block.out 1608 // Write a goroutine blocking profile to the specified file 1609 // when all tests are complete. 1610 // Writes test binary as -c would. 1611 // 1612 // -blockprofilerate n 1613 // Control the detail provided in goroutine blocking profiles by 1614 // calling runtime.SetBlockProfileRate with n. 1615 // See 'go doc runtime.SetBlockProfileRate'. 1616 // The profiler aims to sample, on average, one blocking event every 1617 // n nanoseconds the program spends blocked. By default, 1618 // if -test.blockprofile is set without this flag, all blocking events 1619 // are recorded, equivalent to -test.blockprofilerate=1. 1620 // 1621 // -coverprofile cover.out 1622 // Write a coverage profile to the file after all tests have passed. 1623 // Sets -cover. 1624 // 1625 // -cpuprofile cpu.out 1626 // Write a CPU profile to the specified file before exiting. 1627 // Writes test binary as -c would. 1628 // 1629 // -memprofile mem.out 1630 // Write a memory profile to the file after all tests have passed. 1631 // Writes test binary as -c would. 1632 // 1633 // -memprofilerate n 1634 // Enable more precise (and expensive) memory profiles by setting 1635 // runtime.MemProfileRate. See 'go doc runtime.MemProfileRate'. 1636 // To profile all memory allocations, use -test.memprofilerate=1 1637 // and pass --alloc_space flag to the pprof tool. 1638 // 1639 // -mutexprofile mutex.out 1640 // Write a mutex contention profile to the specified file 1641 // when all tests are complete. 1642 // Writes test binary as -c would. 1643 // 1644 // -mutexprofilefraction n 1645 // Sample 1 in n stack traces of goroutines holding a 1646 // contended mutex. 1647 // 1648 // -outputdir directory 1649 // Place output files from profiling in the specified directory, 1650 // by default the directory in which "go test" is running. 1651 // 1652 // -trace trace.out 1653 // Write an execution trace to the specified file before exiting. 1654 // 1655 // Each of these flags is also recognized with an optional 'test.' prefix, 1656 // as in -test.v. When invoking the generated test binary (the result of 1657 // 'go test -c') directly, however, the prefix is mandatory. 1658 // 1659 // The 'go test' command rewrites or removes recognized flags, 1660 // as appropriate, both before and after the optional package list, 1661 // before invoking the test binary. 1662 // 1663 // For instance, the command 1664 // 1665 // go test -v -myflag testdata -cpuprofile=prof.out -x 1666 // 1667 // will compile the test binary and then run it as 1668 // 1669 // pkg.test -test.v -myflag testdata -test.cpuprofile=prof.out 1670 // 1671 // (The -x flag is removed because it applies only to the go command's 1672 // execution, not to the test itself.) 1673 // 1674 // The test flags that generate profiles (other than for coverage) also 1675 // leave the test binary in pkg.test for use when analyzing the profiles. 1676 // 1677 // When 'go test' runs a test binary, it does so from within the 1678 // corresponding package's source code directory. Depending on the test, 1679 // it may be necessary to do the same when invoking a generated test 1680 // binary directly. 1681 // 1682 // The command-line package list, if present, must appear before any 1683 // flag not known to the go test command. Continuing the example above, 1684 // the package list would have to appear before -myflag, but could appear 1685 // on either side of -v. 1686 // 1687 // To keep an argument for a test binary from being interpreted as a 1688 // known flag or a package name, use -args (see 'go help test') which 1689 // passes the remainder of the command line through to the test binary 1690 // uninterpreted and unaltered. 1691 // 1692 // For instance, the command 1693 // 1694 // go test -v -args -x -v 1695 // 1696 // will compile the test binary and then run it as 1697 // 1698 // pkg.test -test.v -x -v 1699 // 1700 // Similarly, 1701 // 1702 // go test -args math 1703 // 1704 // will compile the test binary and then run it as 1705 // 1706 // pkg.test math 1707 // 1708 // In the first example, the -x and the second -v are passed through to the 1709 // test binary unchanged and with no effect on the go command itself. 1710 // In the second example, the argument math is passed through to the test 1711 // binary, instead of being interpreted as the package list. 1712 // 1713 // 1714 // Description of testing functions 1715 // 1716 // The 'go test' command expects to find test, benchmark, and example functions 1717 // in the "*_test.go" files corresponding to the package under test. 1718 // 1719 // A test function is one named TestXxx (where Xxx does not start with a 1720 // lower case letter) and should have the signature, 1721 // 1722 // func TestXxx(t *testing.T) { ... } 1723 // 1724 // A benchmark function is one named BenchmarkXxx and should have the signature, 1725 // 1726 // func BenchmarkXxx(b *testing.B) { ... } 1727 // 1728 // An example function is similar to a test function but, instead of using 1729 // *testing.T to report success or failure, prints output to os.Stdout. 1730 // If the last comment in the function starts with "Output:" then the output 1731 // is compared exactly against the comment (see examples below). If the last 1732 // comment begins with "Unordered output:" then the output is compared to the 1733 // comment, however the order of the lines is ignored. An example with no such 1734 // comment is compiled but not executed. An example with no text after 1735 // "Output:" is compiled, executed, and expected to produce no output. 1736 // 1737 // Godoc displays the body of ExampleXxx to demonstrate the use 1738 // of the function, constant, or variable Xxx. An example of a method M with 1739 // receiver type T or *T is named ExampleT_M. There may be multiple examples 1740 // for a given function, constant, or variable, distinguished by a trailing _xxx, 1741 // where xxx is a suffix not beginning with an upper case letter. 1742 // 1743 // Here is an example of an example: 1744 // 1745 // func ExamplePrintln() { 1746 // Println("The output of\nthis example.") 1747 // // Output: The output of 1748 // // this example. 1749 // } 1750 // 1751 // Here is another example where the ordering of the output is ignored: 1752 // 1753 // func ExamplePerm() { 1754 // for _, value := range Perm(4) { 1755 // fmt.Println(value) 1756 // } 1757 // 1758 // // Unordered output: 4 1759 // // 2 1760 // // 1 1761 // // 3 1762 // // 0 1763 // } 1764 // 1765 // The entire test file is presented as the example when it contains a single 1766 // example function, at least one other function, type, variable, or constant 1767 // declaration, and no test or benchmark functions. 1768 // 1769 // See the documentation of the testing package for more information. 1770 // 1771 // 1772 package main