github.com/roboticscm/goman@v0.0.0-20210203095141-87c07b4a0a55/src/cmd/go/doc.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 mkdoc.sh.
     6  // Edit the documentation in other files and rerun mkdoc.sh to generate this one.
     7  
     8  /*
     9  Go is a tool for managing Go source code.
    10  
    11  Usage:
    12  
    13  	go command [arguments]
    14  
    15  The commands are:
    16  
    17      build       compile packages and dependencies
    18      clean       remove object files
    19      env         print Go environment information
    20      fix         run go tool fix on packages
    21      fmt         run gofmt on package sources
    22      generate    generate Go files by processing source
    23      get         download and install packages and dependencies
    24      install     compile and install packages and dependencies
    25      list        list packages
    26      run         compile and run Go program
    27      test        test packages
    28      tool        run specified go tool
    29      version     print Go version
    30      vet         run go tool vet on packages
    31  
    32  Use "go help [command]" for more information about a command.
    33  
    34  Additional help topics:
    35  
    36      c           calling between Go and C
    37      filetype    file types
    38      gopath      GOPATH environment variable
    39      importpath  import path syntax
    40      packages    description of package lists
    41      testflag    description of testing flags
    42      testfunc    description of testing functions
    43  
    44  Use "go help [topic]" for more information about that topic.
    45  
    46  
    47  Compile packages and dependencies
    48  
    49  Usage:
    50  
    51  	go build [-o output] [-i] [build flags] [packages]
    52  
    53  Build compiles the packages named by the import paths,
    54  along with their dependencies, but it does not install the results.
    55  
    56  If the arguments are a list of .go files, build treats them as a list
    57  of source files specifying a single package.
    58  
    59  When the command line specifies a single main package,
    60  build writes the resulting executable to output.
    61  Otherwise build compiles the packages but discards the results,
    62  serving only as a check that the packages can be built.
    63  
    64  The -o flag specifies the output file name. If not specified, the
    65  output file name depends on the arguments and derives from the name
    66  of the package, such as p.a for package p, unless p is 'main'. If
    67  the package is main and file names are provided, the file name
    68  derives from the first file name mentioned, such as f1 for 'go build
    69  f1.go f2.go'; with no files provided ('go build'), the output file
    70  name is the base name of the containing directory.
    71  
    72  The -i flag installs the packages that are dependencies of the target.
    73  
    74  The build flags are shared by the build, clean, get, install, list, run,
    75  and test commands:
    76  
    77  	-a
    78  		force rebuilding of packages that are already up-to-date.
    79  		In Go releases, does not apply to the standard library.
    80  	-n
    81  		print the commands but do not run them.
    82  	-p n
    83  		the number of builds that can be run in parallel.
    84  		The default is the number of CPUs available.
    85  	-race
    86  		enable data race detection.
    87  		Supported only on linux/amd64, freebsd/amd64, darwin/amd64 and windows/amd64.
    88  	-v
    89  		print the names of packages as they are compiled.
    90  	-work
    91  		print the name of the temporary work directory and
    92  		do not delete it when exiting.
    93  	-x
    94  		print the commands.
    95  
    96  	-ccflags 'arg list'
    97  		arguments to pass on each 5c, 6c, or 8c compiler invocation.
    98  	-compiler name
    99  		name of compiler to use, as in runtime.Compiler (gccgo or gc).
   100  	-gccgoflags 'arg list'
   101  		arguments to pass on each gccgo compiler/linker invocation.
   102  	-gcflags 'arg list'
   103  		arguments to pass on each 5g, 6g, or 8g compiler invocation.
   104  	-installsuffix suffix
   105  		a suffix to use in the name of the package installation directory,
   106  		in order to keep output separate from default builds.
   107  		If using the -race flag, the install suffix is automatically set to race
   108  		or, if set explicitly, has _race appended to it.
   109  	-ldflags 'flag list'
   110  		arguments to pass on each 5l, 6l, or 8l linker invocation.
   111  	-tags 'tag list'
   112  		a list of build tags to consider satisfied during the build.
   113  		For more information about build tags, see the description of
   114  		build constraints in the documentation for the go/build package.
   115  
   116  The list flags accept a space-separated list of strings. To embed spaces
   117  in an element in the list, surround it with either single or double quotes.
   118  
   119  For more about specifying packages, see 'go help packages'.
   120  For more about where packages and binaries are installed,
   121  run 'go help gopath'.  For more about calling between Go and C/C++,
   122  run 'go help c'.
   123  
   124  See also: go install, go get, go clean.
   125  
   126  
   127  Remove object files
   128  
   129  Usage:
   130  
   131  	go clean [-i] [-r] [-n] [-x] [build flags] [packages]
   132  
   133  Clean removes object files from package source directories.
   134  The go command builds most objects in a temporary directory,
   135  so go clean is mainly concerned with object files left by other
   136  tools or by manual invocations of go build.
   137  
   138  Specifically, clean removes the following files from each of the
   139  source directories corresponding to the import paths:
   140  
   141  	_obj/            old object directory, left from Makefiles
   142  	_test/           old test directory, left from Makefiles
   143  	_testmain.go     old gotest file, left from Makefiles
   144  	test.out         old test log, left from Makefiles
   145  	build.out        old test log, left from Makefiles
   146  	*.[568ao]        object files, left from Makefiles
   147  
   148  	DIR(.exe)        from go build
   149  	DIR.test(.exe)   from go test -c
   150  	MAINFILE(.exe)   from go build MAINFILE.go
   151  	*.so             from SWIG
   152  
   153  In the list, DIR represents the final path element of the
   154  directory, and MAINFILE is the base name of any Go source
   155  file in the directory that is not included when building
   156  the package.
   157  
   158  The -i flag causes clean to remove the corresponding installed
   159  archive or binary (what 'go install' would create).
   160  
   161  The -n flag causes clean to print the remove commands it would execute,
   162  but not run them.
   163  
   164  The -r flag causes clean to be applied recursively to all the
   165  dependencies of the packages named by the import paths.
   166  
   167  The -x flag causes clean to print remove commands as it executes them.
   168  
   169  For more about build flags, see 'go help build'.
   170  
   171  For more about specifying packages, see 'go help packages'.
   172  
   173  
   174  Print Go environment information
   175  
   176  Usage:
   177  
   178  	go env [var ...]
   179  
   180  Env prints Go environment information.
   181  
   182  By default env prints information as a shell script
   183  (on Windows, a batch file).  If one or more variable
   184  names is given as arguments,  env prints the value of
   185  each named variable on its own line.
   186  
   187  
   188  Run go tool fix on packages
   189  
   190  Usage:
   191  
   192  	go fix [packages]
   193  
   194  Fix runs the Go fix command on the packages named by the import paths.
   195  
   196  For more about fix, see 'godoc fix'.
   197  For more about specifying packages, see 'go help packages'.
   198  
   199  To run fix with specific options, run 'go tool fix'.
   200  
   201  See also: go fmt, go vet.
   202  
   203  
   204  Run gofmt on package sources
   205  
   206  Usage:
   207  
   208  	go fmt [-n] [-x] [packages]
   209  
   210  Fmt runs the command 'gofmt -l -w' on the packages named
   211  by the import paths.  It prints the names of the files that are modified.
   212  
   213  For more about gofmt, see 'godoc gofmt'.
   214  For more about specifying packages, see 'go help packages'.
   215  
   216  The -n flag prints commands that would be executed.
   217  The -x flag prints commands as they are executed.
   218  
   219  To run gofmt with specific options, run gofmt itself.
   220  
   221  See also: go fix, go vet.
   222  
   223  
   224  Generate Go files by processing source
   225  
   226  Usage:
   227  
   228  	go generate [-run regexp] [file.go... | packages]
   229  
   230  Generate runs commands described by directives within existing
   231  files. Those commands can run any process but the intent is to
   232  create or update Go source files, for instance by running yacc.
   233  
   234  Go generate is never run automatically by go build, go get, go test,
   235  and so on. It must be run explicitly.
   236  
   237  Go generate scans the file for directives, which are lines of
   238  the form,
   239  
   240  	//go:generate command argument...
   241  
   242  (note: no leading spaces and no space in "//go") where command
   243  is the generator to be run, corresponding to an executable file
   244  that can be run locally. It must either be in the shell path
   245  (gofmt), a fully qualified path (/usr/you/bin/mytool), or a
   246  command alias, described below.
   247  
   248  Note that go generate does not parse the file, so lines that look
   249  like directives in comments or multiline strings will be treated
   250  as directives.
   251  
   252  The arguments to the directive are space-separated tokens or
   253  double-quoted strings passed to the generator as individual
   254  arguments when it is run.
   255  
   256  Quoted strings use Go syntax and are evaluated before execution; a
   257  quoted string appears as a single argument to the generator.
   258  
   259  Go generate sets several variables when it runs the generator:
   260  
   261  	$GOARCH
   262  		The execution architecture (arm, amd64, etc.)
   263  	$GOOS
   264  		The execution operating system (linux, windows, etc.)
   265  	$GOFILE
   266  		The base name of the file.
   267  	$GOPACKAGE
   268  		The name of the package of the file containing the directive.
   269  
   270  Other than variable substitution and quoted-string evaluation, no
   271  special processing such as "globbing" is performed on the command
   272  line.
   273  
   274  As a last step before running the command, any invocations of any
   275  environment variables with alphanumeric names, such as $GOFILE or
   276  $HOME, are expanded throughout the command line. The syntax for
   277  variable expansion is $NAME on all operating systems.  Due to the
   278  order of evaluation, variables are expanded even inside quoted
   279  strings. If the variable NAME is not set, $NAME expands to the
   280  empty string.
   281  
   282  A directive of the form,
   283  
   284  	//go:generate -command xxx args...
   285  
   286  specifies, for the remainder of this source file only, that the
   287  string xxx represents the command identified by the arguments. This
   288  can be used to create aliases or to handle multiword generators.
   289  For example,
   290  
   291  	//go:generate -command yacc go tool yacc
   292  
   293  specifies that the command "yacc" represents the generator
   294  "go tool yacc".
   295  
   296  Generate processes packages in the order given on the command line,
   297  one at a time. If the command line lists .go files, they are treated
   298  as a single package. Within a package, generate processes the
   299  source files in a package in file name order, one at a time. Within
   300  a source file, generate runs generators in the order they appear
   301  in the file, one at a time.
   302  
   303  If any generator returns an error exit status, "go generate" skips
   304  all further processing for that package.
   305  
   306  The generator is run in the package's source directory.
   307  
   308  Go generate accepts one specific flag:
   309  
   310  	-run=""
   311  		TODO: This flag is unimplemented.
   312  		if non-empty, specifies a regular expression to
   313  		select directives whose command matches the expression.
   314  
   315  It also accepts the standard build flags -v, -n, and -x.
   316  The -v flag prints the names of packages and files as they are
   317  processed.
   318  The -n flag prints commands that would be executed.
   319  The -x flag prints commands as they are executed.
   320  
   321  For more about specifying packages, see 'go help packages'.
   322  
   323  
   324  Download and install packages and dependencies
   325  
   326  Usage:
   327  
   328  	go get [-d] [-f] [-fix] [-t] [-u] [build flags] [packages]
   329  
   330  Get downloads and installs the packages named by the import paths,
   331  along with their dependencies.
   332  
   333  The -d flag instructs get to stop after downloading the packages; that is,
   334  it instructs get not to install the packages.
   335  
   336  The -f flag, valid only when -u is set, forces get -u not to verify that
   337  each package has been checked out from the source control repository
   338  implied by its import path. This can be useful if the source is a local fork
   339  of the original.
   340  
   341  The -fix flag instructs get to run the fix tool on the downloaded packages
   342  before resolving dependencies or building the code.
   343  
   344  The -t flag instructs get to also download the packages required to build
   345  the tests for the specified packages.
   346  
   347  The -u flag instructs get to use the network to update the named packages
   348  and their dependencies.  By default, get uses the network to check out
   349  missing packages but does not use it to look for updates to existing packages.
   350  
   351  Get also accepts build flags to control the installation. See 'go help build'.
   352  
   353  When checking out or updating a package, get looks for a branch or tag
   354  that matches the locally installed version of Go. The most important
   355  rule is that if the local installation is running version "go1", get
   356  searches for a branch or tag named "go1". If no such version exists it
   357  retrieves the most recent version of the package.
   358  
   359  For more about specifying packages, see 'go help packages'.
   360  
   361  For more about how 'go get' finds source code to
   362  download, see 'go help importpath'.
   363  
   364  See also: go build, go install, go clean.
   365  
   366  
   367  Compile and install packages and dependencies
   368  
   369  Usage:
   370  
   371  	go install [build flags] [packages]
   372  
   373  Install compiles and installs the packages named by the import paths,
   374  along with their dependencies.
   375  
   376  For more about the build flags, see 'go help build'.
   377  For more about specifying packages, see 'go help packages'.
   378  
   379  See also: go build, go get, go clean.
   380  
   381  
   382  List packages
   383  
   384  Usage:
   385  
   386  	go list [-e] [-f format] [-json] [build flags] [packages]
   387  
   388  List lists the packages named by the import paths, one per line.
   389  
   390  The default output shows the package import path:
   391  
   392      code.google.com/p/google-api-go-client/books/v1
   393      code.google.com/p/goauth2/oauth
   394      code.google.com/p/sqlite
   395  
   396  The -f flag specifies an alternate format for the list, using the
   397  syntax of package template.  The default output is equivalent to -f
   398  '{{.ImportPath}}'. The struct being passed to the template is:
   399  
   400      type Package struct {
   401          Dir           string // directory containing package sources
   402          ImportPath    string // import path of package in dir
   403          ImportComment string // path in import comment on package statement
   404          Name          string // package name
   405          Doc           string // package documentation string
   406          Target        string // install path
   407          Goroot        bool   // is this package in the Go root?
   408          Standard      bool   // is this package part of the standard Go library?
   409          Stale         bool   // would 'go install' do anything for this package?
   410          Root          string // Go root or Go path dir containing this package
   411  
   412          // Source files
   413          GoFiles        []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
   414          CgoFiles       []string // .go sources files that import "C"
   415          IgnoredGoFiles []string // .go sources ignored due to build constraints
   416          CFiles         []string // .c source files
   417          CXXFiles       []string // .cc, .cxx and .cpp source files
   418          MFiles         []string // .m source files
   419          HFiles         []string // .h, .hh, .hpp and .hxx source files
   420          SFiles         []string // .s source files
   421          SwigFiles      []string // .swig files
   422          SwigCXXFiles   []string // .swigcxx files
   423          SysoFiles      []string // .syso object files to add to archive
   424  
   425          // Cgo directives
   426          CgoCFLAGS    []string // cgo: flags for C compiler
   427          CgoCPPFLAGS  []string // cgo: flags for C preprocessor
   428          CgoCXXFLAGS  []string // cgo: flags for C++ compiler
   429          CgoLDFLAGS   []string // cgo: flags for linker
   430          CgoPkgConfig []string // cgo: pkg-config names
   431  
   432          // Dependency information
   433          Imports []string // import paths used by this package
   434          Deps    []string // all (recursively) imported dependencies
   435  
   436          // Error information
   437          Incomplete bool            // this package or a dependency has an error
   438          Error      *PackageError   // error loading package
   439          DepsErrors []*PackageError // errors loading dependencies
   440  
   441          TestGoFiles  []string // _test.go files in package
   442          TestImports  []string // imports from TestGoFiles
   443          XTestGoFiles []string // _test.go files outside package
   444          XTestImports []string // imports from XTestGoFiles
   445      }
   446  
   447  The template function "join" calls strings.Join.
   448  
   449  The template function "context" returns the build context, defined as:
   450  
   451  	type Context struct {
   452  		GOARCH        string   // target architecture
   453  		GOOS          string   // target operating system
   454  		GOROOT        string   // Go root
   455  		GOPATH        string   // Go path
   456  		CgoEnabled    bool     // whether cgo can be used
   457  		UseAllFiles   bool     // use files regardless of +build lines, file names
   458  		Compiler      string   // compiler to assume when computing target paths
   459  		BuildTags     []string // build constraints to match in +build lines
   460  		ReleaseTags   []string // releases the current release is compatible with
   461  		InstallSuffix string   // suffix to use in the name of the install dir
   462  	}
   463  
   464  For more information about the meaning of these fields see the documentation
   465  for the go/build package's Context type.
   466  
   467  The -json flag causes the package data to be printed in JSON format
   468  instead of using the template format.
   469  
   470  The -e flag changes the handling of erroneous packages, those that
   471  cannot be found or are malformed.  By default, the list command
   472  prints an error to standard error for each erroneous package and
   473  omits the packages from consideration during the usual printing.
   474  With the -e flag, the list command never prints errors to standard
   475  error and instead processes the erroneous packages with the usual
   476  printing.  Erroneous packages will have a non-empty ImportPath and
   477  a non-nil Error field; other information may or may not be missing
   478  (zeroed).
   479  
   480  For more about build flags, see 'go help build'.
   481  
   482  For more about specifying packages, see 'go help packages'.
   483  
   484  
   485  Compile and run Go program
   486  
   487  Usage:
   488  
   489  	go run [build flags] [-exec xprog] gofiles... [arguments...]
   490  
   491  Run compiles and runs the main package comprising the named Go source files.
   492  A Go source file is defined to be a file ending in a literal ".go" suffix.
   493  
   494  By default, 'go run' runs the compiled binary directly: 'a.out arguments...'.
   495  If the -exec flag is given, 'go run' invokes the binary using xprog: 'xprog a.out arguments...'.
   496  If the -exec flag is not given, GOOS or GOARCH is different from the system
   497  default, and a program named go_$GOOS_$GOARCH_exec can be found
   498  on the current search path, 'go run' invokes the binary using that program,
   499  for example 'go_nacl_386_exec a.out arguments...'. This allows execution of
   500  cross-compiled programs when a simulator or other execution method is
   501  available.
   502  
   503  For more about build flags, see 'go help build'.
   504  
   505  See also: go build.
   506  
   507  
   508  Test packages
   509  
   510  Usage:
   511  
   512  	go test [-c] [-i] [build and test flags] [packages] [flags for test binary]
   513  
   514  'Go test' automates testing the packages named by the import paths.
   515  It prints a summary of the test results in the format:
   516  
   517  	ok   archive/tar   0.011s
   518  	FAIL archive/zip   0.022s
   519  	ok   compress/gzip 0.033s
   520  	...
   521  
   522  followed by detailed output for each failed package.
   523  
   524  'Go test' recompiles each package along with any files with names matching
   525  the file pattern "*_test.go".
   526  Files whose names begin with "_" (including "_test.go") or "." are ignored.
   527  These additional files can contain test functions, benchmark functions, and
   528  example functions.  See 'go help testfunc' for more.
   529  Each listed package causes the execution of a separate test binary.
   530  
   531  Test files that declare a package with the suffix "_test" will be compiled as a
   532  separate package, and then linked and run with the main test binary.
   533  
   534  By default, go test needs no arguments.  It compiles and tests the package
   535  with source in the current directory, including tests, and runs the tests.
   536  
   537  The package is built in a temporary directory so it does not interfere with the
   538  non-test installation.
   539  
   540  In addition to the build flags, the flags handled by 'go test' itself are:
   541  
   542  	-c
   543  		Compile the test binary to pkg.test but do not run it
   544  		(where pkg is the last element of the package's import path).
   545  		The file name can be changed with the -o flag.
   546  
   547  	-exec xprog
   548  	    Run the test binary using xprog. The behavior is the same as
   549  	    in 'go run'. See 'go help run' for details.
   550  
   551  	-i
   552  	    Install packages that are dependencies of the test.
   553  	    Do not run the test.
   554  
   555  	-o file
   556  		Compile the test binary to the named file.
   557  		The test still runs (unless -c or -i is specified).
   558  
   559  
   560  The test binary also accepts flags that control execution of the test; these
   561  flags are also accessible by 'go test'.  See 'go help testflag' for details.
   562  
   563  If the test binary needs any other flags, they should be presented after the
   564  package names. The go tool treats as a flag the first argument that begins with
   565  a minus sign that it does not recognize itself; that argument and all subsequent
   566  arguments are passed as arguments to the test binary.
   567  
   568  For more about build flags, see 'go help build'.
   569  For more about specifying packages, see 'go help packages'.
   570  
   571  See also: go build, go vet.
   572  
   573  
   574  Run specified go tool
   575  
   576  Usage:
   577  
   578  	go tool [-n] command [args...]
   579  
   580  Tool runs the go tool command identified by the arguments.
   581  With no arguments it prints the list of known tools.
   582  
   583  The -n flag causes tool to print the command that would be
   584  executed but not execute it.
   585  
   586  For more about each tool command, see 'go tool command -h'.
   587  
   588  
   589  Print Go version
   590  
   591  Usage:
   592  
   593  	go version
   594  
   595  Version prints the Go version, as reported by runtime.Version.
   596  
   597  
   598  Run go tool vet on packages
   599  
   600  Usage:
   601  
   602  	go vet [-n] [-x] [packages]
   603  
   604  Vet runs the Go vet command on the packages named by the import paths.
   605  
   606  For more about vet, see 'godoc golang.org/x/tools/cmd/vet'.
   607  For more about specifying packages, see 'go help packages'.
   608  
   609  To run the vet tool with specific options, run 'go tool vet'.
   610  
   611  The -n flag prints commands that would be executed.
   612  The -x flag prints commands as they are executed.
   613  
   614  See also: go fmt, go fix.
   615  
   616  
   617  Calling between Go and C
   618  
   619  There are two different ways to call between Go and C/C++ code.
   620  
   621  The first is the cgo tool, which is part of the Go distribution.  For
   622  information on how to use it see the cgo documentation (godoc cmd/cgo).
   623  
   624  The second is the SWIG program, which is a general tool for
   625  interfacing between languages.  For information on SWIG see
   626  http://swig.org/.  When running go build, any file with a .swig
   627  extension will be passed to SWIG.  Any file with a .swigcxx extension
   628  will be passed to SWIG with the -c++ option.
   629  
   630  When either cgo or SWIG is used, go build will pass any .c, .m, .s,
   631  or .S files to the C compiler, and any .cc, .cpp, .cxx files to the C++
   632  compiler.  The CC or CXX environment variables may be set to determine
   633  the C or C++ compiler, respectively, to use.
   634  
   635  
   636  File types
   637  
   638  The go command examines the contents of a restricted set of files
   639  in each directory. It identifies which files to examine based on
   640  the extension of the file name. These extensions are:
   641  
   642  	.go
   643  		Go source files.
   644  	.c, .h
   645  		C source files.
   646  		If the package uses cgo, these will be compiled with the
   647  		OS-native compiler (typically gcc); otherwise they will be
   648  		compiled with the Go-specific support compiler,
   649  		5c, 6c, or 8c, etc. as appropriate.
   650  	.cc, .cpp, .cxx, .hh, .hpp, .hxx
   651  		C++ source files. Only useful with cgo or SWIG, and always
   652  		compiled with the OS-native compiler.
   653  	.m
   654  		Objective-C source files. Only useful with cgo, and always
   655  		compiled with the OS-native compiler.
   656  	.s, .S
   657  		Assembler source files.
   658  		If the package uses cgo, these will be assembled with the
   659  		OS-native assembler (typically gcc (sic)); otherwise they
   660  		will be assembled with the Go-specific support assembler,
   661  		5a, 6a, or 8a, etc., as appropriate.
   662  	.swig, .swigcxx
   663  		SWIG definition files.
   664  	.syso
   665  		System object files.
   666  
   667  Files of each of these types except .syso may contain build
   668  constraints, but the go command stops scanning for build constraints
   669  at the first item in the file that is not a blank line or //-style
   670  line comment.
   671  
   672  
   673  GOPATH environment variable
   674  
   675  The Go path is used to resolve import statements.
   676  It is implemented by and documented in the go/build package.
   677  
   678  The GOPATH environment variable lists places to look for Go code.
   679  On Unix, the value is a colon-separated string.
   680  On Windows, the value is a semicolon-separated string.
   681  On Plan 9, the value is a list.
   682  
   683  GOPATH must be set to get, build and install packages outside the
   684  standard Go tree.
   685  
   686  Each directory listed in GOPATH must have a prescribed structure:
   687  
   688  The src/ directory holds source code.  The path below 'src'
   689  determines the import path or executable name.
   690  
   691  The pkg/ directory holds installed package objects.
   692  As in the Go tree, each target operating system and
   693  architecture pair has its own subdirectory of pkg
   694  (pkg/GOOS_GOARCH).
   695  
   696  If DIR is a directory listed in the GOPATH, a package with
   697  source in DIR/src/foo/bar can be imported as "foo/bar" and
   698  has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a".
   699  
   700  The bin/ directory holds compiled commands.
   701  Each command is named for its source directory, but only
   702  the final element, not the entire path.  That is, the
   703  command with source in DIR/src/foo/quux is installed into
   704  DIR/bin/quux, not DIR/bin/foo/quux.  The foo/ is stripped
   705  so that you can add DIR/bin to your PATH to get at the
   706  installed commands.  If the GOBIN environment variable is
   707  set, commands are installed to the directory it names instead
   708  of DIR/bin.
   709  
   710  Here's an example directory layout:
   711  
   712      GOPATH=/home/user/gocode
   713  
   714      /home/user/gocode/
   715          src/
   716              foo/
   717                  bar/               (go code in package bar)
   718                      x.go
   719                  quux/              (go code in package main)
   720                      y.go
   721          bin/
   722              quux                   (installed command)
   723          pkg/
   724              linux_amd64/
   725                  foo/
   726                      bar.a          (installed package object)
   727  
   728  Go searches each directory listed in GOPATH to find source code,
   729  but new packages are always downloaded into the first directory
   730  in the list.
   731  
   732  
   733  Import path syntax
   734  
   735  An import path (see 'go help packages') denotes a package
   736  stored in the local file system.  In general, an import path denotes
   737  either a standard package (such as "unicode/utf8") or a package
   738  found in one of the work spaces (see 'go help gopath').
   739  
   740  Relative import paths
   741  
   742  An import path beginning with ./ or ../ is called a relative path.
   743  The toolchain supports relative import paths as a shortcut in two ways.
   744  
   745  First, a relative path can be used as a shorthand on the command line.
   746  If you are working in the directory containing the code imported as
   747  "unicode" and want to run the tests for "unicode/utf8", you can type
   748  "go test ./utf8" instead of needing to specify the full path.
   749  Similarly, in the reverse situation, "go test .." will test "unicode" from
   750  the "unicode/utf8" directory. Relative patterns are also allowed, like
   751  "go test ./..." to test all subdirectories. See 'go help packages' for details
   752  on the pattern syntax.
   753  
   754  Second, if you are compiling a Go program not in a work space,
   755  you can use a relative path in an import statement in that program
   756  to refer to nearby code also not in a work space.
   757  This makes it easy to experiment with small multipackage programs
   758  outside of the usual work spaces, but such programs cannot be
   759  installed with "go install" (there is no work space in which to install them),
   760  so they are rebuilt from scratch each time they are built.
   761  To avoid ambiguity, Go programs cannot use relative import paths
   762  within a work space.
   763  
   764  Remote import paths
   765  
   766  Certain import paths also
   767  describe how to obtain the source code for the package using
   768  a revision control system.
   769  
   770  A few common code hosting sites have special syntax:
   771  
   772  	Bitbucket (Git, Mercurial)
   773  
   774  		import "bitbucket.org/user/project"
   775  		import "bitbucket.org/user/project/sub/directory"
   776  
   777  	GitHub (Git)
   778  
   779  		import "github.com/user/project"
   780  		import "github.com/user/project/sub/directory"
   781  
   782  	Google Code Project Hosting (Git, Mercurial, Subversion)
   783  
   784  		import "code.google.com/p/project"
   785  		import "code.google.com/p/project/sub/directory"
   786  
   787  		import "code.google.com/p/project.subrepository"
   788  		import "code.google.com/p/project.subrepository/sub/directory"
   789  
   790  	Launchpad (Bazaar)
   791  
   792  		import "launchpad.net/project"
   793  		import "launchpad.net/project/series"
   794  		import "launchpad.net/project/series/sub/directory"
   795  
   796  		import "launchpad.net/~user/project/branch"
   797  		import "launchpad.net/~user/project/branch/sub/directory"
   798  
   799  	IBM DevOps Services (Git)
   800  
   801  		import "hub.jazz.net/git/user/project"
   802  		import "hub.jazz.net/git/user/project/sub/directory"
   803  
   804  For code hosted on other servers, import paths may either be qualified
   805  with the version control type, or the go tool can dynamically fetch
   806  the import path over https/http and discover where the code resides
   807  from a <meta> tag in the HTML.
   808  
   809  To declare the code location, an import path of the form
   810  
   811  	repository.vcs/path
   812  
   813  specifies the given repository, with or without the .vcs suffix,
   814  using the named version control system, and then the path inside
   815  that repository.  The supported version control systems are:
   816  
   817  	Bazaar      .bzr
   818  	Git         .git
   819  	Mercurial   .hg
   820  	Subversion  .svn
   821  
   822  For example,
   823  
   824  	import "example.org/user/foo.hg"
   825  
   826  denotes the root directory of the Mercurial repository at
   827  example.org/user/foo or foo.hg, and
   828  
   829  	import "example.org/repo.git/foo/bar"
   830  
   831  denotes the foo/bar directory of the Git repository at
   832  example.org/repo or repo.git.
   833  
   834  When a version control system supports multiple protocols,
   835  each is tried in turn when downloading.  For example, a Git
   836  download tries git://, then https://, then http://.
   837  
   838  If the import path is not a known code hosting site and also lacks a
   839  version control qualifier, the go tool attempts to fetch the import
   840  over https/http and looks for a <meta> tag in the document's HTML
   841  <head>.
   842  
   843  The meta tag has the form:
   844  
   845  	<meta name="go-import" content="import-prefix vcs repo-root">
   846  
   847  The import-prefix is the import path corresponding to the repository
   848  root. It must be a prefix or an exact match of the package being
   849  fetched with "go get". If it's not an exact match, another http
   850  request is made at the prefix to verify the <meta> tags match.
   851  
   852  The vcs is one of "git", "hg", "svn", etc,
   853  
   854  The repo-root is the root of the version control system
   855  containing a scheme and not containing a .vcs qualifier.
   856  
   857  For example,
   858  
   859  	import "example.org/pkg/foo"
   860  
   861  will result in the following request(s):
   862  
   863  	https://example.org/pkg/foo?go-get=1 (preferred)
   864  	http://example.org/pkg/foo?go-get=1  (fallback)
   865  
   866  If that page contains the meta tag
   867  
   868  	<meta name="go-import" content="example.org git https://code.org/r/p/exproj">
   869  
   870  the go tool will verify that https://example.org/?go-get=1 contains the
   871  same meta tag and then git clone https://code.org/r/p/exproj into
   872  GOPATH/src/example.org.
   873  
   874  New downloaded packages are written to the first directory
   875  listed in the GOPATH environment variable (see 'go help gopath').
   876  
   877  The go command attempts to download the version of the
   878  package appropriate for the Go release being used.
   879  Run 'go help get' for more.
   880  
   881  Import path checking
   882  
   883  When the custom import path feature described above redirects to a
   884  known code hosting site, each of the resulting packages has two possible
   885  import paths, using the custom domain or the known hosting site.
   886  
   887  A package statement is said to have an "import comment" if it is immediately
   888  followed (before the next newline) by a comment of one of these two forms:
   889  
   890  	package math // import "path"
   891  	package math /* import "path" * /
   892  
   893  The go command will refuse to install a package with an import comment
   894  unless it is being referred to by that import path. In this way, import comments
   895  let package authors make sure the custom import path is used and not a
   896  direct path to the underlying code hosting site.
   897  
   898  See https://golang.org/s/go14customimport for details.
   899  
   900  
   901  Description of package lists
   902  
   903  Many commands apply to a set of packages:
   904  
   905  	go action [packages]
   906  
   907  Usually, [packages] is a list of import paths.
   908  
   909  An import path that is a rooted path or that begins with
   910  a . or .. element is interpreted as a file system path and
   911  denotes the package in that directory.
   912  
   913  Otherwise, the import path P denotes the package found in
   914  the directory DIR/src/P for some DIR listed in the GOPATH
   915  environment variable (see 'go help gopath').
   916  
   917  If no import paths are given, the action applies to the
   918  package in the current directory.
   919  
   920  There are three reserved names for paths that should not be used
   921  for packages to be built with the go tool:
   922  
   923  - "main" denotes the top-level package in a stand-alone executable.
   924  
   925  - "all" expands to all package directories found in all the GOPATH
   926  trees. For example, 'go list all' lists all the packages on the local
   927  system.
   928  
   929  - "std" is like all but expands to just the packages in the standard
   930  Go library.
   931  
   932  An import path is a pattern if it includes one or more "..." wildcards,
   933  each of which can match any string, including the empty string and
   934  strings containing slashes.  Such a pattern expands to all package
   935  directories found in the GOPATH trees with names matching the
   936  patterns.  As a special case, x/... matches x as well as x's subdirectories.
   937  For example, net/... expands to net and packages in its subdirectories.
   938  
   939  An import path can also name a package to be downloaded from
   940  a remote repository.  Run 'go help importpath' for details.
   941  
   942  Every package in a program must have a unique import path.
   943  By convention, this is arranged by starting each path with a
   944  unique prefix that belongs to you.  For example, paths used
   945  internally at Google all begin with 'google', and paths
   946  denoting remote repositories begin with the path to the code,
   947  such as 'code.google.com/p/project'.
   948  
   949  As a special case, if the package list is a list of .go files from a
   950  single directory, the command is applied to a single synthesized
   951  package made up of exactly those files, ignoring any build constraints
   952  in those files and ignoring any other files in the directory.
   953  
   954  Directory and file names that begin with "." or "_" are ignored
   955  by the go tool, as are directories named "testdata".
   956  
   957  
   958  Description of testing flags
   959  
   960  The 'go test' command takes both flags that apply to 'go test' itself
   961  and flags that apply to the resulting test binary.
   962  
   963  Several of the flags control profiling and write an execution profile
   964  suitable for "go tool pprof"; run "go tool pprof help" for more
   965  information.  The --alloc_space, --alloc_objects, and --show_bytes
   966  options of pprof control how the information is presented.
   967  
   968  The following flags are recognized by the 'go test' command and
   969  control the execution of any test:
   970  
   971  	-bench regexp
   972  	    Run benchmarks matching the regular expression.
   973  	    By default, no benchmarks run. To run all benchmarks,
   974  	    use '-bench .' or '-bench=.'.
   975  
   976  	-benchmem
   977  	    Print memory allocation statistics for benchmarks.
   978  
   979  	-benchtime t
   980  	    Run enough iterations of each benchmark to take t, specified
   981  	    as a time.Duration (for example, -benchtime 1h30s).
   982  	    The default is 1 second (1s).
   983  
   984  	-blockprofile block.out
   985  	    Write a goroutine blocking profile to the specified file
   986  	    when all tests are complete.
   987  	    Writes test binary as -c would.
   988  
   989  	-blockprofilerate n
   990  	    Control the detail provided in goroutine blocking profiles by
   991  	    calling runtime.SetBlockProfileRate with n.
   992  	    See 'godoc runtime SetBlockProfileRate'.
   993  	    The profiler aims to sample, on average, one blocking event every
   994  	    n nanoseconds the program spends blocked.  By default,
   995  	    if -test.blockprofile is set without this flag, all blocking events
   996  	    are recorded, equivalent to -test.blockprofilerate=1.
   997  
   998  	-cover
   999  	    Enable coverage analysis.
  1000  
  1001  	-covermode set,count,atomic
  1002  	    Set the mode for coverage analysis for the package[s]
  1003  	    being tested. The default is "set" unless -race is enabled,
  1004  	    in which case it is "atomic".
  1005  	    The values:
  1006  		set: bool: does this statement run?
  1007  		count: int: how many times does this statement run?
  1008  		atomic: int: count, but correct in multithreaded tests;
  1009  			significantly more expensive.
  1010  	    Sets -cover.
  1011  
  1012  	-coverpkg pkg1,pkg2,pkg3
  1013  	    Apply coverage analysis in each test to the given list of packages.
  1014  	    The default is for each test to analyze only the package being tested.
  1015  	    Packages are specified as import paths.
  1016  	    Sets -cover.
  1017  
  1018  	-coverprofile cover.out
  1019  	    Write a coverage profile to the file after all tests have passed.
  1020  	    Sets -cover.
  1021  
  1022  	-cpu 1,2,4
  1023  	    Specify a list of GOMAXPROCS values for which the tests or
  1024  	    benchmarks should be executed.  The default is the current value
  1025  	    of GOMAXPROCS.
  1026  
  1027  	-cpuprofile cpu.out
  1028  	    Write a CPU profile to the specified file before exiting.
  1029  	    Writes test binary as -c would.
  1030  
  1031  	-memprofile mem.out
  1032  	    Write a memory profile to the file after all tests have passed.
  1033  	    Writes test binary as -c would.
  1034  
  1035  	-memprofilerate n
  1036  	    Enable more precise (and expensive) memory profiles by setting
  1037  	    runtime.MemProfileRate.  See 'godoc runtime MemProfileRate'.
  1038  	    To profile all memory allocations, use -test.memprofilerate=1
  1039  	    and pass --alloc_space flag to the pprof tool.
  1040  
  1041  	-outputdir directory
  1042  	    Place output files from profiling in the specified directory,
  1043  	    by default the directory in which "go test" is running.
  1044  
  1045  	-parallel n
  1046  	    Allow parallel execution of test functions that call t.Parallel.
  1047  	    The value of this flag is the maximum number of tests to run
  1048  	    simultaneously; by default, it is set to the value of GOMAXPROCS.
  1049  
  1050  	-run regexp
  1051  	    Run only those tests and examples matching the regular
  1052  	    expression.
  1053  
  1054  	-short
  1055  	    Tell long-running tests to shorten their run time.
  1056  	    It is off by default but set during all.bash so that installing
  1057  	    the Go tree can run a sanity check but not spend time running
  1058  	    exhaustive tests.
  1059  
  1060  	-timeout t
  1061  	    If a test runs longer than t, panic.
  1062  
  1063  	-v
  1064  	    Verbose output: log all tests as they are run. Also print all
  1065  	    text from Log and Logf calls even if the test succeeds.
  1066  
  1067  The test binary, called pkg.test where pkg is the name of the
  1068  directory containing the package sources, can be invoked directly
  1069  after building it with 'go test -c'. When invoking the test binary
  1070  directly, each of the standard flag names must be prefixed with 'test.',
  1071  as in -test.run=TestMyFunc or -test.v.
  1072  
  1073  When running 'go test', flags not listed above are passed through
  1074  unaltered. For instance, the command
  1075  
  1076  	go test -x -v -cpuprofile=prof.out -dir=testdata -update
  1077  
  1078  will compile the test binary and then run it as
  1079  
  1080  	pkg.test -test.v -test.cpuprofile=prof.out -dir=testdata -update
  1081  
  1082  The test flags that generate profiles (other than for coverage) also
  1083  leave the test binary in pkg.test for use when analyzing the profiles.
  1084  
  1085  Flags not recognized by 'go test' must be placed after any specified packages.
  1086  
  1087  
  1088  Description of testing functions
  1089  
  1090  The 'go test' command expects to find test, benchmark, and example functions
  1091  in the "*_test.go" files corresponding to the package under test.
  1092  
  1093  A test function is one named TestXXX (where XXX is any alphanumeric string
  1094  not starting with a lower case letter) and should have the signature,
  1095  
  1096  	func TestXXX(t *testing.T) { ... }
  1097  
  1098  A benchmark function is one named BenchmarkXXX and should have the signature,
  1099  
  1100  	func BenchmarkXXX(b *testing.B) { ... }
  1101  
  1102  An example function is similar to a test function but, instead of using
  1103  *testing.T to report success or failure, prints output to os.Stdout.
  1104  That output is compared against the function's "Output:" comment, which
  1105  must be the last comment in the function body (see example below). An
  1106  example with no such comment, or with no text after "Output:" is compiled
  1107  but not executed.
  1108  
  1109  Godoc displays the body of ExampleXXX to demonstrate the use
  1110  of the function, constant, or variable XXX.  An example of a method M with
  1111  receiver type T or *T is named ExampleT_M.  There may be multiple examples
  1112  for a given function, constant, or variable, distinguished by a trailing _xxx,
  1113  where xxx is a suffix not beginning with an upper case letter.
  1114  
  1115  Here is an example of an example:
  1116  
  1117  	func ExamplePrintln() {
  1118  		Println("The output of\nthis example.")
  1119  		// Output: The output of
  1120  		// this example.
  1121  	}
  1122  
  1123  The entire test file is presented as the example when it contains a single
  1124  example function, at least one other function, type, variable, or constant
  1125  declaration, and no test or benchmark functions.
  1126  
  1127  See the documentation of the testing package for more information.
  1128  
  1129  
  1130  */
  1131  package main