github.com/varialus/godfly@v0.0.0-20130904042352-1934f9f095ab/src/cmd/go/help.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  package main
     6  
     7  var helpPackages = &Command{
     8  	UsageLine: "packages",
     9  	Short:     "description of package lists",
    10  	Long: `
    11  Many commands apply to a set of packages:
    12  
    13  	go action [packages]
    14  
    15  Usually, [packages] is a list of import paths.
    16  
    17  An import path that is a rooted path or that begins with
    18  a . or .. element is interpreted as a file system path and
    19  denotes the package in that directory.
    20  
    21  Otherwise, the import path P denotes the package found in
    22  the directory DIR/src/P for some DIR listed in the GOPATH
    23  environment variable (see 'go help gopath').
    24  
    25  If no import paths are given, the action applies to the
    26  package in the current directory.
    27  
    28  The special import path "all" expands to all package directories
    29  found in all the GOPATH trees.  For example, 'go list all'
    30  lists all the packages on the local system.
    31  
    32  The special import path "std" is like all but expands to just the
    33  packages in the standard Go library.
    34  
    35  An import path is a pattern if it includes one or more "..." wildcards,
    36  each of which can match any string, including the empty string and
    37  strings containing slashes.  Such a pattern expands to all package
    38  directories found in the GOPATH trees with names matching the
    39  patterns.  As a special case, x/... matches x as well as x's subdirectories.
    40  For example, net/... expands to net and packages in its subdirectories.
    41  
    42  An import path can also name a package to be downloaded from
    43  a remote repository.  Run 'go help remote' for details.
    44  
    45  Every package in a program must have a unique import path.
    46  By convention, this is arranged by starting each path with a
    47  unique prefix that belongs to you.  For example, paths used
    48  internally at Google all begin with 'google', and paths
    49  denoting remote repositories begin with the path to the code,
    50  such as 'code.google.com/p/project'.
    51  
    52  As a special case, if the package list is a list of .go files from a
    53  single directory, the command is applied to a single synthesized
    54  package made up of exactly those files, ignoring any build constraints
    55  in those files and ignoring any other files in the directory.
    56  
    57  File names that begin with "." or "_" are ignored by the go tool.
    58  	`,
    59  }
    60  
    61  var helpRemote = &Command{
    62  	UsageLine: "remote",
    63  	Short:     "remote import path syntax",
    64  	Long: `
    65  
    66  An import path (see 'go help packages') denotes a package
    67  stored in the local file system.  Certain import paths also
    68  describe how to obtain the source code for the package using
    69  a revision control system.
    70  
    71  A few common code hosting sites have special syntax:
    72  
    73  	Bitbucket (Git, Mercurial)
    74  
    75  		import "bitbucket.org/user/project"
    76  		import "bitbucket.org/user/project/sub/directory"
    77  
    78  	GitHub (Git)
    79  
    80  		import "github.com/user/project"
    81  		import "github.com/user/project/sub/directory"
    82  
    83  	Google Code Project Hosting (Git, Mercurial, Subversion)
    84  
    85  		import "code.google.com/p/project"
    86  		import "code.google.com/p/project/sub/directory"
    87  
    88  		import "code.google.com/p/project.subrepository"
    89  		import "code.google.com/p/project.subrepository/sub/directory"
    90  
    91  	Launchpad (Bazaar)
    92  
    93  		import "launchpad.net/project"
    94  		import "launchpad.net/project/series"
    95  		import "launchpad.net/project/series/sub/directory"
    96  
    97  		import "launchpad.net/~user/project/branch"
    98  		import "launchpad.net/~user/project/branch/sub/directory"
    99  
   100  For code hosted on other servers, import paths may either be qualified
   101  with the version control type, or the go tool can dynamically fetch
   102  the import path over https/http and discover where the code resides
   103  from a <meta> tag in the HTML.
   104  
   105  To declare the code location, an import path of the form
   106  
   107  	repository.vcs/path
   108  
   109  specifies the given repository, with or without the .vcs suffix,
   110  using the named version control system, and then the path inside
   111  that repository.  The supported version control systems are:
   112  
   113  	Bazaar      .bzr
   114  	Git         .git
   115  	Mercurial   .hg
   116  	Subversion  .svn
   117  
   118  For example,
   119  
   120  	import "example.org/user/foo.hg"
   121  
   122  denotes the root directory of the Mercurial repository at
   123  example.org/user/foo or foo.hg, and
   124  
   125  	import "example.org/repo.git/foo/bar"
   126  
   127  denotes the foo/bar directory of the Git repository at
   128  example.com/repo or repo.git.
   129  
   130  When a version control system supports multiple protocols,
   131  each is tried in turn when downloading.  For example, a Git
   132  download tries git://, then https://, then http://.
   133  
   134  If the import path is not a known code hosting site and also lacks a
   135  version control qualifier, the go tool attempts to fetch the import
   136  over https/http and looks for a <meta> tag in the document's HTML
   137  <head>.
   138  
   139  The meta tag has the form:
   140  
   141  	<meta name="go-import" content="import-prefix vcs repo-root">
   142  
   143  The import-prefix is the import path corresponding to the repository
   144  root. It must be a prefix or an exact match of the package being
   145  fetched with "go get". If it's not an exact match, another http
   146  request is made at the prefix to verify the <meta> tags match.
   147  
   148  The vcs is one of "git", "hg", "svn", etc,
   149  
   150  The repo-root is the root of the version control system
   151  containing a scheme and not containing a .vcs qualifier.
   152  
   153  For example,
   154  
   155  	import "example.org/pkg/foo"
   156  
   157  will result in the following request(s):
   158  
   159  	https://example.org/pkg/foo?go-get=1 (preferred)
   160  	http://example.org/pkg/foo?go-get=1  (fallback)
   161  
   162  If that page contains the meta tag
   163  
   164  	<meta name="go-import" content="example.org git https://code.org/r/p/exproj">
   165  
   166  the go tool will verify that https://example.org/?go-get=1 contains the
   167  same meta tag and then git clone https://code.org/r/p/exproj into
   168  GOPATH/src/example.org.
   169  
   170  New downloaded packages are written to the first directory
   171  listed in the GOPATH environment variable (see 'go help gopath').
   172  
   173  The go command attempts to download the version of the
   174  package appropriate for the Go release being used.
   175  Run 'go help install' for more.
   176  	`,
   177  }
   178  
   179  var helpGopath = &Command{
   180  	UsageLine: "gopath",
   181  	Short:     "GOPATH environment variable",
   182  	Long: `
   183  The Go path is used to resolve import statements.
   184  It is implemented by and documented in the go/build package.
   185  
   186  The GOPATH environment variable lists places to look for Go code.
   187  On Unix, the value is a colon-separated string.
   188  On Windows, the value is a semicolon-separated string.
   189  On Plan 9, the value is a list.
   190  
   191  GOPATH must be set to get, build and install packages outside the
   192  standard Go tree.
   193  
   194  Each directory listed in GOPATH must have a prescribed structure:
   195  
   196  The src/ directory holds source code.  The path below 'src'
   197  determines the import path or executable name.
   198  
   199  The pkg/ directory holds installed package objects.
   200  As in the Go tree, each target operating system and
   201  architecture pair has its own subdirectory of pkg
   202  (pkg/GOOS_GOARCH).
   203  
   204  If DIR is a directory listed in the GOPATH, a package with
   205  source in DIR/src/foo/bar can be imported as "foo/bar" and
   206  has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a".
   207  
   208  The bin/ directory holds compiled commands.
   209  Each command is named for its source directory, but only
   210  the final element, not the entire path.  That is, the
   211  command with source in DIR/src/foo/quux is installed into
   212  DIR/bin/quux, not DIR/bin/foo/quux.  The foo/ is stripped
   213  so that you can add DIR/bin to your PATH to get at the
   214  installed commands.  If the GOBIN environment variable is
   215  set, commands are installed to the directory it names instead
   216  of DIR/bin.
   217  
   218  Here's an example directory layout:
   219  
   220      GOPATH=/home/user/gocode
   221  
   222      /home/user/gocode/
   223          src/
   224              foo/
   225                  bar/               (go code in package bar)
   226                      x.go
   227                  quux/              (go code in package main)
   228                      y.go
   229          bin/
   230              quux                   (installed command)
   231          pkg/
   232              linux_amd64/
   233                  foo/
   234                      bar.a          (installed package object)
   235  
   236  Go searches each directory listed in GOPATH to find source code,
   237  but new packages are always downloaded into the first directory
   238  in the list.
   239  	`,
   240  }