Skip to content
This repository was archived by the owner on Jul 29, 2021. It is now read-only.

Commit b2a16b2

Browse files
authored
Merge pull request #10 from lordnynex/master
A few fixes
2 parents b99566c + df2d830 commit b2a16b2

File tree

6 files changed

+509
-154
lines changed

6 files changed

+509
-154
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
godoc2md

examples/build/README.md

Lines changed: 88 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
use 'godoc cmd/go/build' for documentation on the go/build command
2+
3+
14

25
# build
3-
import "go/build"
6+
`import "go/build"`
47

8+
* [Overview](#pkg-overview)
9+
* [Index](#pkg-index)
10+
11+
## <a name="pkg-overview">Overview</a>
512
Package build gathers information about Go packages.
613

714
### Go Path
@@ -106,6 +113,8 @@ During a particular build, the following words are satisfied:
106113
- "go1.2", from Go version 1.2 onward
107114
- "go1.3", from Go version 1.3 onward
108115
- "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
109118
- any additional words listed in ctxt.BuildTags
110119

111120
If a file's name, after stripping the extension and a possible _test suffix,
@@ -119,7 +128,7 @@ matches any of the following patterns:
119128
(example: source_windows_amd64.go) where GOOS and GOARCH represent
120129
any known operating system and architecture values respectively, then
121130
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).
123132

124133
To keep a file from being considered for the build:
125134

@@ -150,23 +159,52 @@ in addition to android tags and files.
150159

151160

152161

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+
153181

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>
155188
``` go
156189
var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
157190
```
158191
ToolDir is the directory containing build tools.
159192

160193

161-
## func ArchChar
194+
195+
## <a name="ArchChar">func</a> [ArchChar](/src/target/build.go?s=43569:43613#L1511)
162196
``` go
163197
func ArchChar(goarch string) (string, error)
164198
```
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.
167204

168205

169-
## func IsLocalImport
206+
207+
## <a name="IsLocalImport">func</a> [IsLocalImport](/src/target/build.go?s=43089:43125#L1501)
170208
``` go
171209
func IsLocalImport(path string) bool
172210
```
@@ -175,7 +213,8 @@ a local import path, like ".", "..", "./foo", or "../foo".
175213

176214

177215

178-
## type Context
216+
217+
## <a name="Context">type</a> [Context](/src/target/build.go?s=451:3526#L20)
179218
``` go
180219
type Context struct {
181220
GOARCH string // target architecture
@@ -241,9 +280,6 @@ type Context struct {
241280
A Context specifies the supporting context for a build.
242281

243282

244-
245-
246-
247283
``` go
248284
var Default Context = defaultContext()
249285
```
@@ -257,7 +293,10 @@ if set, or else the compiled code's GOARCH, GOOS, and GOROOT.
257293

258294

259295

260-
### func (\*Context) Import
296+
297+
298+
299+
### <a name="Context.Import">func</a> (\*Context) [Import](/src/target/build.go?s=16014:16104#L465)
261300
``` go
262301
func (ctxt *Context) Import(path string, srcDir string, mode ImportMode) (*Package, error)
263302
```
@@ -280,7 +319,8 @@ If an error occurs, Import returns a non-nil error and a non-nil
280319

281320

282321

283-
### func (\*Context) ImportDir
322+
323+
### <a name="Context.ImportDir">func</a> (\*Context) [ImportDir](/src/target/build.go?s=14177:14254#L413)
284324
``` go
285325
func (ctxt *Context) ImportDir(dir string, mode ImportMode) (*Package, error)
286326
```
@@ -289,7 +329,8 @@ the named directory.
289329

290330

291331

292-
### func (\*Context) MatchFile
332+
333+
### <a name="Context.MatchFile">func</a> (\*Context) [MatchFile](/src/target/build.go?s=30168:30240#L1008)
293334
``` go
294335
func (ctxt *Context) MatchFile(dir, name string) (match bool, err error)
295336
```
@@ -302,7 +343,8 @@ read some or all of the file's content.
302343

303344

304345

305-
### func (\*Context) SrcDirs
346+
347+
### <a name="Context.SrcDirs">func</a> (\*Context) [SrcDirs](/src/target/build.go?s=7480:7519#L227)
306348
``` go
307349
func (ctxt *Context) SrcDirs() []string
308350
```
@@ -312,14 +354,14 @@ that do not exist.
312354

313355

314356

315-
## type ImportMode
357+
358+
## <a name="ImportMode">type</a> [ImportMode](/src/target/build.go?s=9906:9926#L319)
316359
``` go
317360
type ImportMode uint
318361
```
319362
An ImportMode controls the behavior of the Import method.
320363

321364

322-
323365
``` go
324366
const (
325367
// If FindOnly is set, Import stops after locating the directory
@@ -336,6 +378,21 @@ const (
336378
// or finds conflicting comments in multiple source files.
337379
// See golang.org/s/go14customimport for more information.
338380
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
339396
)
340397
```
341398

@@ -346,7 +403,8 @@ const (
346403

347404

348405

349-
## type MultiplePackageError
406+
407+
## <a name="MultiplePackageError">type</a> [MultiplePackageError](/src/target/build.go?s=14730:14938#L430)
350408
``` go
351409
type MultiplePackageError struct {
352410
Dir string // directory containing files
@@ -366,14 +424,14 @@ multiple buildable Go source files for multiple packages.
366424

367425

368426

369-
370-
### func (\*MultiplePackageError) Error
427+
### <a name="MultiplePackageError.Error">func</a> (\*MultiplePackageError) [Error](/src/target/build.go?s=14940:14985#L436)
371428
``` go
372429
func (e *MultiplePackageError) Error() string
373430
```
374431

375432

376-
## type NoGoError
433+
434+
## <a name="NoGoError">type</a> [NoGoError](/src/target/build.go?s=14482:14519#L420)
377435
``` go
378436
type NoGoError struct {
379437
Dir string
@@ -392,14 +450,14 @@ test files, files hidden by build tags, and so on.)
392450

393451

394452

395-
396-
### func (\*NoGoError) Error
453+
### <a name="NoGoError.Error">func</a> (\*NoGoError) [Error](/src/target/build.go?s=14521:14555#L424)
397454
``` go
398455
func (e *NoGoError) Error() string
399456
```
400457

401458

402-
## type Package
459+
460+
## <a name="Package">type</a> [Package](/src/target/build.go?s=11233:13864#L354)
403461
``` go
404462
type Package struct {
405463
Dir string // directory containing package sources
@@ -410,6 +468,7 @@ type Package struct {
410468
Root string // root of Go tree where this package lives
411469
SrcRoot string // package source root directory ("" if unknown)
412470
PkgRoot string // package install root directory ("" if unknown)
471+
PkgTargetRoot string // architecture dependent install root directory ("" if unknown)
413472
BinDir string // command install directory ("" if unknown)
414473
Goroot bool // package found in Go root
415474
PkgObj string // installed .a file
@@ -420,6 +479,7 @@ type Package struct {
420479
GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
421480
CgoFiles []string // .go source files that import "C"
422481
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)
423483
CFiles []string // .c source files
424484
CXXFiles []string // .cc, .cpp and .cxx source files
425485
MFiles []string // .m (Objective-C) source files
@@ -457,16 +517,14 @@ A Package describes the Go package found in a directory.
457517

458518

459519

460-
461-
462-
### func Import
520+
### <a name="Import">func</a> [Import](/src/target/build.go?s=32183:32250#L1085)
463521
``` go
464522
func Import(path, srcDir string, mode ImportMode) (*Package, error)
465523
```
466524
Import is shorthand for Default.Import.
467525

468526

469-
### func ImportDir
527+
### <a name="ImportDir">func</a> [ImportDir](/src/target/build.go?s=32348:32409#L1090)
470528
``` go
471529
func ImportDir(dir string, mode ImportMode) (*Package, error)
472530
```
@@ -475,7 +533,8 @@ ImportDir is shorthand for Default.ImportDir.
475533

476534

477535

478-
### func (\*Package) IsCommand
536+
537+
### <a name="Package.IsCommand">func</a> (\*Package) [IsCommand](/src/target/build.go?s=14022:14056#L407)
479538
``` go
480539
func (p *Package) IsCommand() bool
481540
```
@@ -490,6 +549,5 @@ Packages named "main" are treated as commands.
490549

491550

492551

493-
494552
- - -
495553
Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md)

0 commit comments

Comments
 (0)