1
+ use 'godoc cmd/go/build' for documentation on the go/build command
2
+
3
+
1
4
2
5
# build
3
- import "go/build"
6
+ ` import "go/build" `
4
7
8
+ * [ Overview] ( #pkg-overview )
9
+ * [ Index] ( #pkg-index )
10
+
11
+ ## <a name =" pkg-overview " >Overview</a >
5
12
Package build gathers information about Go packages.
6
13
7
14
### Go Path
@@ -106,6 +113,8 @@ During a particular build, the following words are satisfied:
106
113
- "go1.2", from Go version 1.2 onward
107
114
- "go1.3", from Go version 1.3 onward
108
115
- "go1.4", from Go version 1.4 onward
116
+ - "go1.5", from Go version 1.5 onward
117
+ - "go1.6", from Go version 1.6 onward
109
118
- any additional words listed in ctxt.BuildTags
110
119
111
120
If a file's name, after stripping the extension and a possible _ test suffix,
@@ -119,7 +128,7 @@ matches any of the following patterns:
119
128
(example: source_windows_amd64.go) where GOOS and GOARCH represent
120
129
any known operating system and architecture values respectively, then
121
130
the file is considered to have an implicit build constraint requiring
122
- those terms.
131
+ those terms (in addition to any explicit constraints in the file) .
123
132
124
133
To keep a file from being considered for the build:
125
134
@@ -150,23 +159,52 @@ in addition to android tags and files.
150
159
151
160
152
161
162
+ ## <a name =" pkg-index " >Index</a >
163
+ * [ Variables] ( #pkg-variables )
164
+ * [ func ArchChar(goarch string) (string, error)] ( #ArchChar )
165
+ * [ func IsLocalImport(path string) bool] ( #IsLocalImport )
166
+ * [ type Context] ( #Context )
167
+ * [ func (ctxt * Context) Import(path string, srcDir string, mode ImportMode) (* Package, error)] ( #Context.Import )
168
+ * [ func (ctxt * Context) ImportDir(dir string, mode ImportMode) (* Package, error)] ( #Context.ImportDir )
169
+ * [ func (ctxt * Context) MatchFile(dir, name string) (match bool, err error)] ( #Context.MatchFile )
170
+ * [ func (ctxt * Context) SrcDirs() [ ] string] ( #Context.SrcDirs )
171
+ * [ type ImportMode] ( #ImportMode )
172
+ * [ type MultiplePackageError] ( #MultiplePackageError )
173
+ * [ func (e * MultiplePackageError) Error() string] ( #MultiplePackageError.Error )
174
+ * [ type NoGoError] ( #NoGoError )
175
+ * [ func (e * NoGoError) Error() string] ( #NoGoError.Error )
176
+ * [ type Package] ( #Package )
177
+ * [ func Import(path, srcDir string, mode ImportMode) (* Package, error)] ( #Import )
178
+ * [ func ImportDir(dir string, mode ImportMode) (* Package, error)] ( #ImportDir )
179
+ * [ func (p * Package) IsCommand() bool] ( #Package.IsCommand )
180
+
153
181
154
- ## Variables
182
+ #### <a name =" pkg-files " >Package files</a >
183
+ [ build.go] ( /src/go/build/build.go ) [ doc.go] ( /src/go/build/doc.go ) [ read.go] ( /src/go/build/read.go ) [ syslist.go] ( /src/go/build/syslist.go )
184
+
185
+
186
+
187
+ ## <a name =" pkg-variables " >Variables</a >
155
188
``` go
156
189
var ToolDir = filepath.Join (runtime.GOROOT (), " pkg/tool/" +runtime.GOOS +" _" +runtime.GOARCH )
157
190
```
158
191
ToolDir is the directory containing build tools.
159
192
160
193
161
- ## func ArchChar
194
+
195
+ ## <a name =" ArchChar " >func</a > [ ArchChar] ( /src/target/build.go?s=43569:43613#L1511 )
162
196
``` go
163
197
func ArchChar (goarch string ) (string , error )
164
198
```
165
- ArchChar returns the architecture character for the given goarch.
166
- For example, ArchChar("amd64") returns "6".
199
+ ArchChar returns "?" and an error.
200
+ In earlier versions of Go, the returned string was used to derive
201
+ the compiler and linker tool names, the default object file suffix,
202
+ and the default linker output name. As of Go 1.5, those strings
203
+ no longer vary by architecture; they are compile, link, .o, and a.out, respectively.
167
204
168
205
169
- ## func IsLocalImport
206
+
207
+ ## <a name="IsLocalImport">func</a> [IsLocalImport](/src/target/build.go?s=43089:43125#L1501)
170
208
``` go
171
209
func IsLocalImport(path string) bool
172
210
```
@@ -175,7 +213,8 @@ a local import path, like ".", "..", "./foo", or "../foo".
175
213
176
214
177
215
178
- ## type Context
216
+
217
+ ## <a name="Context">type</a> [Context](/src/target/build.go?s=451:3526#L20)
179
218
``` go
180
219
type Context struct {
181
220
GOARCH string // target architecture
@@ -241,9 +280,6 @@ type Context struct {
241
280
A Context specifies the supporting context for a build.
242
281
243
282
244
-
245
-
246
-
247
283
``` go
248
284
var Default Context = defaultContext ()
249
285
```
@@ -257,7 +293,10 @@ if set, or else the compiled code's GOARCH, GOOS, and GOROOT.
257
293
258
294
259
295
260
- ### func (\* Context) Import
296
+
297
+
298
+
299
+ ### <a name =" Context.Import " >func</a > (\* Context) [ Import] ( /src/target/build.go?s=16014:16104#L465 )
261
300
``` go
262
301
func (ctxt *Context ) Import (path string , srcDir string , mode ImportMode ) (*Package , error )
263
302
```
@@ -280,7 +319,8 @@ If an error occurs, Import returns a non-nil error and a non-nil
280
319
281
320
282
321
283
- ### func (\*Context) ImportDir
322
+
323
+ ### <a name="Context.ImportDir">func</a> (\*Context) [ImportDir](/src/target/build.go?s=14177:14254#L413)
284
324
``` go
285
325
func (ctxt *Context) ImportDir(dir string, mode ImportMode) (*Package, error)
286
326
```
@@ -289,7 +329,8 @@ the named directory.
289
329
290
330
291
331
292
- ### func (\*Context) MatchFile
332
+
333
+ ### <a name="Context.MatchFile">func</a> (\*Context) [MatchFile](/src/target/build.go?s=30168:30240#L1008)
293
334
``` go
294
335
func (ctxt *Context) MatchFile(dir, name string) (match bool, err error)
295
336
```
@@ -302,7 +343,8 @@ read some or all of the file's content.
302
343
303
344
304
345
305
- ### func (\*Context) SrcDirs
346
+
347
+ ### <a name="Context.SrcDirs">func</a> (\*Context) [SrcDirs](/src/target/build.go?s=7480:7519#L227)
306
348
``` go
307
349
func (ctxt *Context) SrcDirs() []string
308
350
```
@@ -312,14 +354,14 @@ that do not exist.
312
354
313
355
314
356
315
- ## type ImportMode
357
+
358
+ ## <a name="ImportMode">type</a> [ImportMode](/src/target/build.go?s=9906:9926#L319)
316
359
``` go
317
360
type ImportMode uint
318
361
```
319
362
An ImportMode controls the behavior of the Import method.
320
363
321
364
322
-
323
365
``` go
324
366
const (
325
367
// If FindOnly is set, Import stops after locating the directory
@@ -336,6 +378,21 @@ const (
336
378
// or finds conflicting comments in multiple source files.
337
379
// See golang.org/s/go14customimport for more information.
338
380
ImportComment
381
+
382
+ // By default, Import searches vendor directories
383
+ // that apply in the given source directory before searching
384
+ // the GOROOT and GOPATH roots.
385
+ // If an Import finds and returns a package using a vendor
386
+ // directory, the resulting ImportPath is the complete path
387
+ // to the package, including the path elements leading up
388
+ // to and including "vendor".
389
+ // For example, if Import("y", "x/subdir", 0) finds
390
+ // "x/vendor/y", the returned package's ImportPath is "x/vendor/y",
391
+ // not plain "y".
392
+ // See golang.org/s/go15vendor for more information.
393
+ //
394
+ // Setting IgnoreVendor ignores vendor directories.
395
+ IgnoreVendor
339
396
)
340
397
```
341
398
@@ -346,7 +403,8 @@ const (
346
403
347
404
348
405
349
- ## type MultiplePackageError
406
+
407
+ ## <a name="MultiplePackageError">type</a> [MultiplePackageError](/src/target/build.go?s=14730:14938#L430)
350
408
``` go
351
409
type MultiplePackageError struct {
352
410
Dir string // directory containing files
@@ -366,14 +424,14 @@ multiple buildable Go source files for multiple packages.
366
424
367
425
368
426
369
-
370
- ### func (\* MultiplePackageError) Error
427
+ ### <a name =" MultiplePackageError.Error " >func</a > (\* MultiplePackageError) [ Error] ( /src/target/build.go?s=14940:14985#L436 )
371
428
``` go
372
429
func (e *MultiplePackageError ) Error () string
373
430
```
374
431
375
432
376
- ## type NoGoError
433
+
434
+ ## <a name="NoGoError">type</a> [NoGoError](/src/target/build.go?s=14482:14519#L420)
377
435
``` go
378
436
type NoGoError struct {
379
437
Dir string
@@ -392,14 +450,14 @@ test files, files hidden by build tags, and so on.)
392
450
393
451
394
452
395
-
396
- ### func (\* NoGoError) Error
453
+ ### <a name =" NoGoError.Error " >func</a > (\* NoGoError) [ Error] ( /src/target/build.go?s=14521:14555#L424 )
397
454
``` go
398
455
func (e *NoGoError ) Error () string
399
456
```
400
457
401
458
402
- ## type Package
459
+
460
+ ## <a name="Package">type</a> [Package](/src/target/build.go?s=11233:13864#L354)
403
461
``` go
404
462
type Package struct {
405
463
Dir string // directory containing package sources
@@ -410,6 +468,7 @@ type Package struct {
410
468
Root string // root of Go tree where this package lives
411
469
SrcRoot string // package source root directory ("" if unknown)
412
470
PkgRoot string // package install root directory ("" if unknown)
471
+ PkgTargetRoot string // architecture dependent install root directory ("" if unknown)
413
472
BinDir string // command install directory ("" if unknown)
414
473
Goroot bool // package found in Go root
415
474
PkgObj string // installed .a file
@@ -420,6 +479,7 @@ type Package struct {
420
479
GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
421
480
CgoFiles []string // .go source files that import "C"
422
481
IgnoredGoFiles []string // .go source files ignored for this build
482
+ InvalidGoFiles []string // .go source files with detected problems (parse error, wrong package name, and so on)
423
483
CFiles []string // .c source files
424
484
CXXFiles []string // .cc, .cpp and .cxx source files
425
485
MFiles []string // .m (Objective-C) source files
@@ -457,16 +517,14 @@ A Package describes the Go package found in a directory.
457
517
458
518
459
519
460
-
461
-
462
- ### func Import
520
+ ### <a name =" Import " >func</a > [ Import] ( /src/target/build.go?s=32183:32250#L1085 )
463
521
``` go
464
522
func Import (path , srcDir string , mode ImportMode ) (*Package , error )
465
523
```
466
524
Import is shorthand for Default.Import.
467
525
468
526
469
- ### func ImportDir
527
+ ### <a name="ImportDir"> func</a> [ ImportDir](/src/target/build.go?s=32348:32409#L1090)
470
528
``` go
471
529
func ImportDir(dir string, mode ImportMode) (*Package, error)
472
530
```
@@ -475,7 +533,8 @@ ImportDir is shorthand for Default.ImportDir.
475
533
476
534
477
535
478
- ### func (\*Package) IsCommand
536
+
537
+ ### <a name="Package.IsCommand">func</a> (\*Package) [IsCommand](/src/target/build.go?s=14022:14056#L407)
479
538
``` go
480
539
func (p *Package) IsCommand() bool
481
540
```
@@ -490,6 +549,5 @@ Packages named "main" are treated as commands.
490
549
491
550
492
551
493
-
494
552
- - -
495
553
Generated by [godoc2md](http:// godoc.org/github.com/davecheney/godoc2md)
0 commit comments