github.com/rohankumardubey/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/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, .s, or .S 23 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 File names that begin with "." or "_" are ignored by the go tool. 85 `, 86 } 87 88 var helpImportPath = &Command{ 89 UsageLine: "importpath", 90 Short: "import path syntax", 91 Long: ` 92 93 An import path (see 'go help packages') denotes a package 94 stored in the local file system. In general, an import path denotes 95 either a standard package (such as "unicode/utf8") or a package 96 found in one of the work spaces (see 'go help gopath'). 97 98 Relative import paths 99 100 An import path beginning with ./ or ../ is called a relative path. 101 The toolchain supports relative import paths as a shortcut in two ways. 102 103 First, a relative path can be used as a shorthand on the command line. 104 If you are working in the directory containing the code imported as 105 "unicode" and want to run the tests for "unicode/utf8", you can type 106 "go test ./utf8" instead of needing to specify the full path. 107 Similarly, in the reverse situation, "go test .." will test "unicode" from 108 the "unicode/utf8" directory. Relative patterns are also allowed, like 109 "go test ./..." to test all subdirectories. See 'go help packages' for details 110 on the pattern syntax. 111 112 Second, if you are compiling a Go program not in a work space, 113 you can use a relative path in an import statement in that program 114 to refer to nearby code also not in a work space. 115 This makes it easy to experiment with small multipackage programs 116 outside of the usual work spaces, but such programs cannot be 117 installed with "go install" (there is no work space in which to install them), 118 so they are rebuilt from scratch each time they are built. 119 To avoid ambiguity, Go programs cannot use relative import paths 120 within a work space. 121 122 Remote import paths 123 124 Certain import paths also 125 describe how to obtain the source code for the package using 126 a revision control system. 127 128 A few common code hosting sites have special syntax: 129 130 Bitbucket (Git, Mercurial) 131 132 import "bitbucket.org/user/project" 133 import "bitbucket.org/user/project/sub/directory" 134 135 GitHub (Git) 136 137 import "github.com/user/project" 138 import "github.com/user/project/sub/directory" 139 140 Google Code Project Hosting (Git, Mercurial, Subversion) 141 142 import "code.google.com/p/project" 143 import "code.google.com/p/project/sub/directory" 144 145 import "code.google.com/p/project.subrepository" 146 import "code.google.com/p/project.subrepository/sub/directory" 147 148 Launchpad (Bazaar) 149 150 import "launchpad.net/project" 151 import "launchpad.net/project/series" 152 import "launchpad.net/project/series/sub/directory" 153 154 import "launchpad.net/~user/project/branch" 155 import "launchpad.net/~user/project/branch/sub/directory" 156 157 For code hosted on other servers, import paths may either be qualified 158 with the version control type, or the go tool can dynamically fetch 159 the import path over https/http and discover where the code resides 160 from a <meta> tag in the HTML. 161 162 To declare the code location, an import path of the form 163 164 repository.vcs/path 165 166 specifies the given repository, with or without the .vcs suffix, 167 using the named version control system, and then the path inside 168 that repository. The supported version control systems are: 169 170 Bazaar .bzr 171 Git .git 172 Mercurial .hg 173 Subversion .svn 174 175 For example, 176 177 import "example.org/user/foo.hg" 178 179 denotes the root directory of the Mercurial repository at 180 example.org/user/foo or foo.hg, and 181 182 import "example.org/repo.git/foo/bar" 183 184 denotes the foo/bar directory of the Git repository at 185 example.com/repo or repo.git. 186 187 When a version control system supports multiple protocols, 188 each is tried in turn when downloading. For example, a Git 189 download tries git://, then https://, then http://. 190 191 If the import path is not a known code hosting site and also lacks a 192 version control qualifier, the go tool attempts to fetch the import 193 over https/http and looks for a <meta> tag in the document's HTML 194 <head>. 195 196 The meta tag has the form: 197 198 <meta name="go-import" content="import-prefix vcs repo-root"> 199 200 The import-prefix is the import path corresponding to the repository 201 root. It must be a prefix or an exact match of the package being 202 fetched with "go get". If it's not an exact match, another http 203 request is made at the prefix to verify the <meta> tags match. 204 205 The vcs is one of "git", "hg", "svn", etc, 206 207 The repo-root is the root of the version control system 208 containing a scheme and not containing a .vcs qualifier. 209 210 For example, 211 212 import "example.org/pkg/foo" 213 214 will result in the following request(s): 215 216 https://example.org/pkg/foo?go-get=1 (preferred) 217 http://example.org/pkg/foo?go-get=1 (fallback) 218 219 If that page contains the meta tag 220 221 <meta name="go-import" content="example.org git https://code.org/r/p/exproj"> 222 223 the go tool will verify that https://example.org/?go-get=1 contains the 224 same meta tag and then git clone https://code.org/r/p/exproj into 225 GOPATH/src/example.org. 226 227 New downloaded packages are written to the first directory 228 listed in the GOPATH environment variable (see 'go help gopath'). 229 230 The go command attempts to download the version of the 231 package appropriate for the Go release being used. 232 Run 'go help install' for more. 233 `, 234 } 235 236 var helpGopath = &Command{ 237 UsageLine: "gopath", 238 Short: "GOPATH environment variable", 239 Long: ` 240 The Go path is used to resolve import statements. 241 It is implemented by and documented in the go/build package. 242 243 The GOPATH environment variable lists places to look for Go code. 244 On Unix, the value is a colon-separated string. 245 On Windows, the value is a semicolon-separated string. 246 On Plan 9, the value is a list. 247 248 GOPATH must be set to get, build and install packages outside the 249 standard Go tree. 250 251 Each directory listed in GOPATH must have a prescribed structure: 252 253 The src/ directory holds source code. The path below 'src' 254 determines the import path or executable name. 255 256 The pkg/ directory holds installed package objects. 257 As in the Go tree, each target operating system and 258 architecture pair has its own subdirectory of pkg 259 (pkg/GOOS_GOARCH). 260 261 If DIR is a directory listed in the GOPATH, a package with 262 source in DIR/src/foo/bar can be imported as "foo/bar" and 263 has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a". 264 265 The bin/ directory holds compiled commands. 266 Each command is named for its source directory, but only 267 the final element, not the entire path. That is, the 268 command with source in DIR/src/foo/quux is installed into 269 DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is stripped 270 so that you can add DIR/bin to your PATH to get at the 271 installed commands. If the GOBIN environment variable is 272 set, commands are installed to the directory it names instead 273 of DIR/bin. 274 275 Here's an example directory layout: 276 277 GOPATH=/home/user/gocode 278 279 /home/user/gocode/ 280 src/ 281 foo/ 282 bar/ (go code in package bar) 283 x.go 284 quux/ (go code in package main) 285 y.go 286 bin/ 287 quux (installed command) 288 pkg/ 289 linux_amd64/ 290 foo/ 291 bar.a (installed package object) 292 293 Go searches each directory listed in GOPATH to find source code, 294 but new packages are always downloaded into the first directory 295 in the list. 296 `, 297 }