github.com/razvanm/vanadium-go-1.3@v0.0.0-20160721203343-4a65068e5915/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 helpC = &Command{ 8 UsageLine: "c", 9 Short: "calling between Go and C", 10 Long: ` 11 There are two different ways to call between Go and C/C++ code. 12 13 The first is the cgo tool, which is part of the Go distribution. For 14 information on how to use it see the cgo documentation (godoc cmd/cgo). 15 16 The second is the SWIG program, which is a general tool for 17 interfacing between languages. For information on SWIG see 18 http://swig.org/. When running go build, any file with a .swig 19 extension will be passed to SWIG. Any file with a .swigcxx extension 20 will be passed to SWIG with the -c++ option. 21 22 When either cgo or SWIG is used, go build will pass any .c, .m, .s, 23 or .S files to the C compiler, and any .cc, .cpp, .cxx files to the C++ 24 compiler. The CC or CXX environment variables may be set to determine 25 the C or C++ compiler, respectively, to use. 26 `, 27 } 28 29 var helpPackages = &Command{ 30 UsageLine: "packages", 31 Short: "description of package lists", 32 Long: ` 33 Many commands apply to a set of packages: 34 35 go action [packages] 36 37 Usually, [packages] is a list of import paths. 38 39 An import path that is a rooted path or that begins with 40 a . or .. element is interpreted as a file system path and 41 denotes the package in that directory. 42 43 Otherwise, the import path P denotes the package found in 44 the directory DIR/src/P for some DIR listed in the GOPATH 45 environment variable (see 'go help gopath'). 46 47 If no import paths are given, the action applies to the 48 package in the current directory. 49 50 There are three reserved names for paths that should not be used 51 for packages to be built with the go tool: 52 53 - "main" denotes the top-level package in a stand-alone executable. 54 55 - "all" expands to all package directories found in all the GOPATH 56 trees. For example, 'go list all' lists all the packages on the local 57 system. 58 59 - "std" is like all but expands to just the packages in the standard 60 Go library. 61 62 An import path is a pattern if it includes one or more "..." wildcards, 63 each of which can match any string, including the empty string and 64 strings containing slashes. Such a pattern expands to all package 65 directories found in the GOPATH trees with names matching the 66 patterns. As a special case, x/... matches x as well as x's subdirectories. 67 For example, net/... expands to net and packages in its subdirectories. 68 69 An import path can also name a package to be downloaded from 70 a remote repository. Run 'go help importpath' for details. 71 72 Every package in a program must have a unique import path. 73 By convention, this is arranged by starting each path with a 74 unique prefix that belongs to you. For example, paths used 75 internally at Google all begin with 'google', and paths 76 denoting remote repositories begin with the path to the code, 77 such as 'code.google.com/p/project'. 78 79 As a special case, if the package list is a list of .go files from a 80 single directory, the command is applied to a single synthesized 81 package made up of exactly those files, ignoring any build constraints 82 in those files and ignoring any other files in the directory. 83 84 Directory and file names that begin with "." or "_" are ignored 85 by the go tool, as are directories named "testdata". 86 `, 87 } 88 89 var helpImportPath = &Command{ 90 UsageLine: "importpath", 91 Short: "import path syntax", 92 Long: ` 93 94 An import path (see 'go help packages') denotes a package 95 stored in the local file system. In general, an import path denotes 96 either a standard package (such as "unicode/utf8") or a package 97 found in one of the work spaces (see 'go help gopath'). 98 99 Relative import paths 100 101 An import path beginning with ./ or ../ is called a relative path. 102 The toolchain supports relative import paths as a shortcut in two ways. 103 104 First, a relative path can be used as a shorthand on the command line. 105 If you are working in the directory containing the code imported as 106 "unicode" and want to run the tests for "unicode/utf8", you can type 107 "go test ./utf8" instead of needing to specify the full path. 108 Similarly, in the reverse situation, "go test .." will test "unicode" from 109 the "unicode/utf8" directory. Relative patterns are also allowed, like 110 "go test ./..." to test all subdirectories. See 'go help packages' for details 111 on the pattern syntax. 112 113 Second, if you are compiling a Go program not in a work space, 114 you can use a relative path in an import statement in that program 115 to refer to nearby code also not in a work space. 116 This makes it easy to experiment with small multipackage programs 117 outside of the usual work spaces, but such programs cannot be 118 installed with "go install" (there is no work space in which to install them), 119 so they are rebuilt from scratch each time they are built. 120 To avoid ambiguity, Go programs cannot use relative import paths 121 within a work space. 122 123 Remote import paths 124 125 Certain import paths also 126 describe how to obtain the source code for the package using 127 a revision control system. 128 129 A few common code hosting sites have special syntax: 130 131 Bitbucket (Git, Mercurial) 132 133 import "bitbucket.org/user/project" 134 import "bitbucket.org/user/project/sub/directory" 135 136 GitHub (Git) 137 138 import "github.com/user/project" 139 import "github.com/user/project/sub/directory" 140 141 Google Code Project Hosting (Git, Mercurial, Subversion) 142 143 import "code.google.com/p/project" 144 import "code.google.com/p/project/sub/directory" 145 146 import "code.google.com/p/project.subrepository" 147 import "code.google.com/p/project.subrepository/sub/directory" 148 149 Launchpad (Bazaar) 150 151 import "launchpad.net/project" 152 import "launchpad.net/project/series" 153 import "launchpad.net/project/series/sub/directory" 154 155 import "launchpad.net/~user/project/branch" 156 import "launchpad.net/~user/project/branch/sub/directory" 157 158 IBM DevOps Services (Git) 159 160 import "hub.jazz.net/git/user/project" 161 import "hub.jazz.net/git/user/project/sub/directory" 162 163 For code hosted on other servers, import paths may either be qualified 164 with the version control type, or the go tool can dynamically fetch 165 the import path over https/http and discover where the code resides 166 from a <meta> tag in the HTML. 167 168 To declare the code location, an import path of the form 169 170 repository.vcs/path 171 172 specifies the given repository, with or without the .vcs suffix, 173 using the named version control system, and then the path inside 174 that repository. The supported version control systems are: 175 176 Bazaar .bzr 177 Git .git 178 Mercurial .hg 179 Subversion .svn 180 181 For example, 182 183 import "example.org/user/foo.hg" 184 185 denotes the root directory of the Mercurial repository at 186 example.org/user/foo or foo.hg, and 187 188 import "example.org/repo.git/foo/bar" 189 190 denotes the foo/bar directory of the Git repository at 191 example.org/repo or repo.git. 192 193 When a version control system supports multiple protocols, 194 each is tried in turn when downloading. For example, a Git 195 download tries git://, then https://, then http://. 196 197 If the import path is not a known code hosting site and also lacks a 198 version control qualifier, the go tool attempts to fetch the import 199 over https/http and looks for a <meta> tag in the document's HTML 200 <head>. 201 202 The meta tag has the form: 203 204 <meta name="go-import" content="import-prefix vcs repo-root"> 205 206 The import-prefix is the import path corresponding to the repository 207 root. It must be a prefix or an exact match of the package being 208 fetched with "go get". If it's not an exact match, another http 209 request is made at the prefix to verify the <meta> tags match. 210 211 The vcs is one of "git", "hg", "svn", etc, 212 213 The repo-root is the root of the version control system 214 containing a scheme and not containing a .vcs qualifier. 215 216 For example, 217 218 import "example.org/pkg/foo" 219 220 will result in the following request(s): 221 222 https://example.org/pkg/foo?go-get=1 (preferred) 223 http://example.org/pkg/foo?go-get=1 (fallback) 224 225 If that page contains the meta tag 226 227 <meta name="go-import" content="example.org git https://code.org/r/p/exproj"> 228 229 the go tool will verify that https://example.org/?go-get=1 contains the 230 same meta tag and then git clone https://code.org/r/p/exproj into 231 GOPATH/src/example.org. 232 233 New downloaded packages are written to the first directory 234 listed in the GOPATH environment variable (see 'go help gopath'). 235 236 The go command attempts to download the version of the 237 package appropriate for the Go release being used. 238 Run 'go help install' for more. 239 `, 240 } 241 242 var helpGopath = &Command{ 243 UsageLine: "gopath", 244 Short: "GOPATH environment variable", 245 Long: ` 246 The Go path is used to resolve import statements. 247 It is implemented by and documented in the go/build package. 248 249 The GOPATH environment variable lists places to look for Go code. 250 On Unix, the value is a colon-separated string. 251 On Windows, the value is a semicolon-separated string. 252 On Plan 9, the value is a list. 253 254 GOPATH must be set to get, build and install packages outside the 255 standard Go tree. 256 257 Each directory listed in GOPATH must have a prescribed structure: 258 259 The src/ directory holds source code. The path below 'src' 260 determines the import path or executable name. 261 262 The pkg/ directory holds installed package objects. 263 As in the Go tree, each target operating system and 264 architecture pair has its own subdirectory of pkg 265 (pkg/GOOS_GOARCH). 266 267 If DIR is a directory listed in the GOPATH, a package with 268 source in DIR/src/foo/bar can be imported as "foo/bar" and 269 has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a". 270 271 The bin/ directory holds compiled commands. 272 Each command is named for its source directory, but only 273 the final element, not the entire path. That is, the 274 command with source in DIR/src/foo/quux is installed into 275 DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is stripped 276 so that you can add DIR/bin to your PATH to get at the 277 installed commands. If the GOBIN environment variable is 278 set, commands are installed to the directory it names instead 279 of DIR/bin. 280 281 Here's an example directory layout: 282 283 GOPATH=/home/user/gocode 284 285 /home/user/gocode/ 286 src/ 287 foo/ 288 bar/ (go code in package bar) 289 x.go 290 quux/ (go code in package main) 291 y.go 292 bin/ 293 quux (installed command) 294 pkg/ 295 linux_amd64/ 296 foo/ 297 bar.a (installed package object) 298 299 Go searches each directory listed in GOPATH to find source code, 300 but new packages are always downloaded into the first directory 301 in the list. 302 `, 303 } 304 305 var helpFileType = &Command{ 306 UsageLine: "filetype", 307 Short: "file types", 308 Long: ` 309 The go command examines the contents of a restricted set of files 310 in each directory. It identifies which files to examine based on 311 the extension of the file name. These extensions are: 312 313 .go 314 Go source files. 315 .c, .h 316 C source files. 317 If the package uses cgo, these will be compiled with the 318 OS-native compiler (typically gcc); otherwise they will be 319 compiled with the Go-specific support compiler, 320 5c, 6c, or 8c, etc. as appropriate. 321 .cc, .cpp, .cxx, .hh, .hpp, .hxx 322 C++ source files. Only useful with cgo or SWIG, and always 323 compiled with the OS-native compiler. 324 .m 325 Objective-C source files. Only useful with cgo, and always 326 compiled with the OS-native compiler. 327 .s, .S 328 Assembler source files. 329 If the package uses cgo, these will be assembled with the 330 OS-native assembler (typically gcc (sic)); otherwise they 331 will be assembled with the Go-specific support assembler, 332 5a, 6a, or 8a, etc., as appropriate. 333 .swig, .swigcxx 334 SWIG definition files. 335 .syso 336 System object files. 337 338 Files of each of these types except .syso may contain build 339 constraints, but the go command stops scanning for build constraints 340 at the first item in the file that is not a blank line or //-style 341 line comment. 342 `, 343 }