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