mirror of
https://github.com/golang/go.git
synced 2026-01-30 23:52:05 +03:00
Compare commits
89 Commits
go1.10
...
dev.typeal
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a5ef1501d | ||
|
|
352996a381 | ||
|
|
bb5055d6f1 | ||
|
|
439c0c8be8 | ||
|
|
e396667ba3 | ||
|
|
daf6706f37 | ||
|
|
958c64bbab | ||
|
|
195e20a976 | ||
|
|
f55bc1c4eb | ||
|
|
51f508bb4a | ||
|
|
243dee1737 | ||
|
|
a43c0d2dc8 | ||
|
|
1054085dcf | ||
|
|
18a13d373a | ||
|
|
6efa2f22ac | ||
|
|
fb9770f09b | ||
|
|
b6a8fc8d8c | ||
|
|
59870f9e19 | ||
|
|
c9688ddb6b | ||
|
|
38d35f49e7 | ||
|
|
1ba29926f3 | ||
|
|
a4c18f063b | ||
|
|
8babce23e3 | ||
|
|
853d533ed6 | ||
|
|
166f2159d8 | ||
|
|
95a5b80e6d | ||
|
|
fe79c75268 | ||
|
|
d7989b784e | ||
|
|
056be9f79c | ||
|
|
02240408a1 | ||
|
|
04017ffadf | ||
|
|
2d0043014f | ||
|
|
3ca0d34fa1 | ||
|
|
84192f2734 | ||
|
|
752b8b773d | ||
|
|
ff5695d0fd | ||
|
|
517a38c630 | ||
|
|
dc70a5efd1 | ||
|
|
77476e81d9 | ||
|
|
bf71119d54 | ||
|
|
11a224bc56 | ||
|
|
3a8841bcaf | ||
|
|
6c5abcf21a | ||
|
|
43fa04c23c | ||
|
|
e35c01b404 | ||
|
|
c955eb1935 | ||
|
|
f8ed4539eb | ||
|
|
d43130743c | ||
|
|
0a5cec792f | ||
|
|
8890527476 | ||
|
|
ea6781bcd0 | ||
|
|
2327d696c1 | ||
|
|
ba48d2002e | ||
|
|
b43fabfb30 | ||
|
|
6a712dfac1 | ||
|
|
865536b197 | ||
|
|
bae53daa72 | ||
|
|
0954fdd51e | ||
|
|
d4ee1f4a40 | ||
|
|
991ee8f4ac | ||
|
|
3b4fc5d1c6 | ||
|
|
cd6b6202dd | ||
|
|
606eb9b0c1 | ||
|
|
bcda91c18d | ||
|
|
7d7a0a9d64 | ||
|
|
cedc511a6e | ||
|
|
ae13ccfd6d | ||
|
|
7cec9a583d | ||
|
|
d84dee069a | ||
|
|
f1e44a4b74 | ||
|
|
3ade54063e | ||
|
|
0545006bdb | ||
|
|
1363eeba65 | ||
|
|
1edfd64761 | ||
|
|
6eb0f5440e | ||
|
|
c543cc353d | ||
|
|
f0749fe163 | ||
|
|
ba878ac0c8 | ||
|
|
6177f6d448 | ||
|
|
67cd1fa780 | ||
|
|
758a7281ab | ||
|
|
470704531d | ||
|
|
648bb34484 | ||
|
|
d8d2f036a5 | ||
|
|
2a5f65a98c | ||
|
|
2f6c20b46c | ||
|
|
59f181b6fd | ||
|
|
d18087cb25 | ||
|
|
3de6e96e4b |
3
.github/CODE_OF_CONDUCT.md
vendored
3
.github/CODE_OF_CONDUCT.md
vendored
@@ -1,3 +0,0 @@
|
||||
# Code of Conduct
|
||||
|
||||
Please read the [Go Community Code of Conduct](https://golang.org/conduct).
|
||||
6
.github/ISSUE_TEMPLATE
vendored
6
.github/ISSUE_TEMPLATE
vendored
@@ -1,17 +1,12 @@
|
||||
Please answer these questions before submitting your issue. Thanks!
|
||||
|
||||
|
||||
### What version of Go are you using (`go version`)?
|
||||
|
||||
|
||||
### Does this issue reproduce with the latest release?
|
||||
|
||||
|
||||
### What operating system and processor architecture are you using (`go env`)?
|
||||
|
||||
|
||||
### What did you do?
|
||||
|
||||
If possible, provide a recipe for reproducing the error.
|
||||
A complete runnable program is good.
|
||||
A link on play.golang.org is best.
|
||||
@@ -22,3 +17,4 @@ A link on play.golang.org is best.
|
||||
|
||||
### What did you see instead?
|
||||
|
||||
|
||||
|
||||
7
.github/PULL_REQUEST_TEMPLATE
vendored
Normal file
7
.github/PULL_REQUEST_TEMPLATE
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Please do not send pull requests to the golang/* repositories.
|
||||
|
||||
We do, however, take contributions gladly.
|
||||
|
||||
See https://golang.org/doc/contribute.html
|
||||
|
||||
Thanks!
|
||||
14
.github/SUPPORT.md
vendored
14
.github/SUPPORT.md
vendored
@@ -1,14 +0,0 @@
|
||||
Unlike many projects on GitHub, the Go project does not use its bug tracker for general discussion or asking questions.
|
||||
We only use our bug tracker for tracking bugs and tracking proposals going through the [Proposal Process](https://golang.org/s/proposal-process).
|
||||
|
||||
For asking questions, see:
|
||||
|
||||
* [The golang-nuts mailing list](https://groups.google.com/d/forum/golang-nuts)
|
||||
|
||||
* [The Go Forum](https://forum.golangbridge.org/), a web-based forum
|
||||
|
||||
* [Gophers Slack](https://gophers.slack.com), use the [invite app](https://invite.slack.golangbridge.org/) for access
|
||||
|
||||
* [Stack Overflow](http://stackoverflow.com/questions/tagged/go) with questions tagged "go"
|
||||
|
||||
* **IRC** channel #go-nuts on Freenode
|
||||
12
.gitignore
vendored
12
.gitignore
vendored
@@ -31,10 +31,9 @@ _testmain.go
|
||||
/pkg/
|
||||
/src/*.*/
|
||||
/src/cmd/cgo/zdefaultcc.go
|
||||
/src/cmd/dist/dist
|
||||
/src/cmd/go/internal/cfg/zdefaultcc.go
|
||||
/src/cmd/go/internal/cfg/zosarch.go
|
||||
/src/cmd/internal/objabi/zbootstrap.go
|
||||
/src/cmd/go/zdefaultcc.go
|
||||
/src/cmd/go/zosarch.go
|
||||
/src/cmd/internal/obj/zbootstrap.go
|
||||
/src/go/build/zcgo.go
|
||||
/src/go/doc/headscan
|
||||
/src/runtime/internal/sys/zversion.go
|
||||
@@ -44,8 +43,3 @@ _testmain.go
|
||||
/test/pass.out
|
||||
/test/run.out
|
||||
/test/times.out
|
||||
|
||||
# This file includes artifacts of Go build that should not be checked in.
|
||||
# For files created by specific development environment (e.g. editor),
|
||||
# use alternative ways to exclude files from git.
|
||||
# For example, set up .git/info/exclude or use a global .gitignore.
|
||||
|
||||
@@ -4,19 +4,15 @@ Go is an open source project.
|
||||
|
||||
It is the work of hundreds of contributors. We appreciate your help!
|
||||
|
||||
## Before filing an issue
|
||||
|
||||
If you are unsure whether you have found a bug, please consider asking in the [golang-nuts mailing
|
||||
list](https://groups.google.com/forum/#!forum/golang-nuts) or [other forums](https://golang.org/help/) first. If
|
||||
the behavior you are seeing is confirmed as a bug or issue, it can easily be re-raised in the issue tracker.
|
||||
|
||||
## Filing issues
|
||||
|
||||
Sensitive security-related issues should be reported to [security@golang.org](mailto:security@golang.org).
|
||||
See the [security policy](https://golang.org/security) for details.
|
||||
General questions should go to the
|
||||
[golang-nuts mailing list](https://groups.google.com/group/golang-nuts) or
|
||||
[other forum](https://golang.org/wiki/Questions) instead of the issue tracker.
|
||||
The gophers there will answer or ask you to file an issue if you've tripped over a bug.
|
||||
|
||||
The recommended way to file an issue is by running `go bug`.
|
||||
Otherwise, when filing an issue, make sure to answer these five questions:
|
||||
When filing an issue, make sure to answer these five questions:
|
||||
|
||||
1. What version of Go are you using (`go version`)?
|
||||
2. What operating system and processor architecture are you using?
|
||||
@@ -26,9 +22,17 @@ Otherwise, when filing an issue, make sure to answer these five questions:
|
||||
|
||||
For change proposals, see [Proposing Changes To Go](https://github.com/golang/proposal/).
|
||||
|
||||
Sensitive security-related issues should be reported to [security@golang.org](mailto:security@golang.org).
|
||||
|
||||
## Contributing code
|
||||
|
||||
Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) before sending patches.
|
||||
Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html)
|
||||
before sending patches.
|
||||
|
||||
**We do not accept GitHub pull requests**
|
||||
(we use [an instance](https://go-review.googlesource.com/) of the
|
||||
[Gerrit](https://www.gerritcodereview.com/) code review system instead).
|
||||
Also, please do not post patches on the issue tracker.
|
||||
|
||||
Unless otherwise noted, the Go source files are distributed under
|
||||
the BSD-style license found in the LICENSE file.
|
||||
|
||||
437
CONTRIBUTORS
437
CONTRIBUTORS
File diff suppressed because it is too large
Load Diff
11
README.md
11
README.md
@@ -4,7 +4,6 @@ Go is an open source programming language that makes it easy to build simple,
|
||||
reliable, and efficient software.
|
||||
|
||||

|
||||
*Gopher image by [Renee French][rf], licensed under [Creative Commons 3.0 Attributions license][cc3-by].*
|
||||
|
||||
Our canonical Git repository is located at https://go.googlesource.com/go.
|
||||
There is a mirror of the repository at https://github.com/golang/go.
|
||||
@@ -36,9 +35,7 @@ Go is the work of hundreds of contributors. We appreciate your help!
|
||||
To contribute, please read the contribution guidelines:
|
||||
https://golang.org/doc/contribute.html
|
||||
|
||||
Note that the Go project uses the issue tracker for bug reports and
|
||||
proposals only. See https://golang.org/wiki/Questions for a list of
|
||||
places to ask questions about the Go language.
|
||||
|
||||
[rf]: https://reneefrench.blogspot.com/
|
||||
[cc3-by]: https://creativecommons.org/licenses/by/3.0/
|
||||
Note that the Go project does not use GitHub pull requests, and that
|
||||
we use the issue tracker for bug reports and proposals only. See
|
||||
https://golang.org/wiki/Questions for a list of places to ask
|
||||
questions about the Go language.
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
pkg encoding/json, method (*RawMessage) MarshalJSON() ([]uint8, error)
|
||||
pkg math/big, const MaxBase = 36
|
||||
pkg math/big, type Word uintptr
|
||||
pkg net, func ListenUnixgram(string, *UnixAddr) (*UDPConn, error)
|
||||
pkg os (linux-arm), const O_SYNC = 4096
|
||||
pkg os (linux-arm-cgo), const O_SYNC = 4096
|
||||
@@ -344,4 +342,3 @@ pkg syscall (openbsd-386), const SYS_KILL = 37
|
||||
pkg syscall (openbsd-386-cgo), const SYS_KILL = 37
|
||||
pkg syscall (openbsd-amd64), const SYS_KILL = 37
|
||||
pkg syscall (openbsd-amd64-cgo), const SYS_KILL = 37
|
||||
pkg unicode, const Version = "9.0.0"
|
||||
|
||||
627
api/go1.10.txt
627
api/go1.10.txt
@@ -1,627 +0,0 @@
|
||||
pkg archive/tar, const FormatGNU = 8
|
||||
pkg archive/tar, const FormatGNU Format
|
||||
pkg archive/tar, const FormatPAX = 4
|
||||
pkg archive/tar, const FormatPAX Format
|
||||
pkg archive/tar, const FormatUSTAR = 2
|
||||
pkg archive/tar, const FormatUSTAR Format
|
||||
pkg archive/tar, const FormatUnknown = 0
|
||||
pkg archive/tar, const FormatUnknown Format
|
||||
pkg archive/tar, method (Format) String() string
|
||||
pkg archive/tar, type Format int
|
||||
pkg archive/tar, type Header struct, Format Format
|
||||
pkg archive/tar, type Header struct, PAXRecords map[string]string
|
||||
pkg archive/zip, method (*Writer) SetComment(string) error
|
||||
pkg archive/zip, type FileHeader struct, Modified time.Time
|
||||
pkg archive/zip, type FileHeader struct, NonUTF8 bool
|
||||
pkg bufio, method (*Reader) Size() int
|
||||
pkg bufio, method (*Writer) Size() int
|
||||
pkg crypto/tls, const ECDSAWithSHA1 = 515
|
||||
pkg crypto/tls, const ECDSAWithSHA1 SignatureScheme
|
||||
pkg crypto/x509, const CANotAuthorizedForExtKeyUsage = 9
|
||||
pkg crypto/x509, const CANotAuthorizedForExtKeyUsage InvalidReason
|
||||
pkg crypto/x509, const ExtKeyUsageMicrosoftCommercialCodeSigning = 12
|
||||
pkg crypto/x509, const ExtKeyUsageMicrosoftCommercialCodeSigning ExtKeyUsage
|
||||
pkg crypto/x509, const ExtKeyUsageMicrosoftKernelCodeSigning = 13
|
||||
pkg crypto/x509, const ExtKeyUsageMicrosoftKernelCodeSigning ExtKeyUsage
|
||||
pkg crypto/x509, const NameConstraintsWithoutSANs = 6
|
||||
pkg crypto/x509, const NameConstraintsWithoutSANs InvalidReason
|
||||
pkg crypto/x509, const TooManyConstraints = 8
|
||||
pkg crypto/x509, const TooManyConstraints InvalidReason
|
||||
pkg crypto/x509, const UnconstrainedName = 7
|
||||
pkg crypto/x509, const UnconstrainedName InvalidReason
|
||||
pkg crypto/x509, func MarshalPKCS1PublicKey(*rsa.PublicKey) []uint8
|
||||
pkg crypto/x509, func MarshalPKCS8PrivateKey(interface{}) ([]uint8, error)
|
||||
pkg crypto/x509, func ParsePKCS1PublicKey([]uint8) (*rsa.PublicKey, error)
|
||||
pkg crypto/x509, method (PublicKeyAlgorithm) String() string
|
||||
pkg crypto/x509, type Certificate struct, ExcludedEmailAddresses []string
|
||||
pkg crypto/x509, type Certificate struct, ExcludedIPRanges []*net.IPNet
|
||||
pkg crypto/x509, type Certificate struct, ExcludedURIDomains []string
|
||||
pkg crypto/x509, type Certificate struct, PermittedEmailAddresses []string
|
||||
pkg crypto/x509, type Certificate struct, PermittedIPRanges []*net.IPNet
|
||||
pkg crypto/x509, type Certificate struct, PermittedURIDomains []string
|
||||
pkg crypto/x509, type Certificate struct, URIs []*url.URL
|
||||
pkg crypto/x509, type CertificateInvalidError struct, Detail string
|
||||
pkg crypto/x509, type CertificateRequest struct, URIs []*url.URL
|
||||
pkg crypto/x509, type VerifyOptions struct, MaxConstraintComparisions int
|
||||
pkg crypto/x509/pkix, method (Name) String() string
|
||||
pkg crypto/x509/pkix, method (RDNSequence) String() string
|
||||
pkg database/sql, func OpenDB(driver.Connector) *DB
|
||||
pkg database/sql/driver, type Connector interface { Connect, Driver }
|
||||
pkg database/sql/driver, type Connector interface, Connect(context.Context) (Conn, error)
|
||||
pkg database/sql/driver, type Connector interface, Driver() Driver
|
||||
pkg database/sql/driver, type DriverContext interface { OpenConnector }
|
||||
pkg database/sql/driver, type DriverContext interface, OpenConnector(string) (Connector, error)
|
||||
pkg database/sql/driver, type SessionResetter interface { ResetSession }
|
||||
pkg database/sql/driver, type SessionResetter interface, ResetSession(context.Context) error
|
||||
pkg debug/elf, const R_386_16 = 20
|
||||
pkg debug/elf, const R_386_16 R_386
|
||||
pkg debug/elf, const R_386_32PLT = 11
|
||||
pkg debug/elf, const R_386_32PLT R_386
|
||||
pkg debug/elf, const R_386_8 = 22
|
||||
pkg debug/elf, const R_386_8 R_386
|
||||
pkg debug/elf, const R_386_GOT32X = 43
|
||||
pkg debug/elf, const R_386_GOT32X R_386
|
||||
pkg debug/elf, const R_386_IRELATIVE = 42
|
||||
pkg debug/elf, const R_386_IRELATIVE R_386
|
||||
pkg debug/elf, const R_386_PC16 = 21
|
||||
pkg debug/elf, const R_386_PC16 R_386
|
||||
pkg debug/elf, const R_386_PC8 = 23
|
||||
pkg debug/elf, const R_386_PC8 R_386
|
||||
pkg debug/elf, const R_386_SIZE32 = 38
|
||||
pkg debug/elf, const R_386_SIZE32 R_386
|
||||
pkg debug/elf, const R_386_TLS_DESC = 41
|
||||
pkg debug/elf, const R_386_TLS_DESC R_386
|
||||
pkg debug/elf, const R_386_TLS_DESC_CALL = 40
|
||||
pkg debug/elf, const R_386_TLS_DESC_CALL R_386
|
||||
pkg debug/elf, const R_386_TLS_GOTDESC = 39
|
||||
pkg debug/elf, const R_386_TLS_GOTDESC R_386
|
||||
pkg debug/elf, const R_AARCH64_LD64_GOTOFF_LO15 = 310
|
||||
pkg debug/elf, const R_AARCH64_LD64_GOTOFF_LO15 R_AARCH64
|
||||
pkg debug/elf, const R_AARCH64_LD64_GOTPAGE_LO15 = 313
|
||||
pkg debug/elf, const R_AARCH64_LD64_GOTPAGE_LO15 R_AARCH64
|
||||
pkg debug/elf, const R_AARCH64_TLSGD_ADR_PREL21 = 512
|
||||
pkg debug/elf, const R_AARCH64_TLSGD_ADR_PREL21 R_AARCH64
|
||||
pkg debug/elf, const R_AARCH64_TLSGD_MOVW_G0_NC = 516
|
||||
pkg debug/elf, const R_AARCH64_TLSGD_MOVW_G0_NC R_AARCH64
|
||||
pkg debug/elf, const R_AARCH64_TLSGD_MOVW_G1 = 515
|
||||
pkg debug/elf, const R_AARCH64_TLSGD_MOVW_G1 R_AARCH64
|
||||
pkg debug/elf, const R_AARCH64_TLSLD_ADR_PAGE21 = 518
|
||||
pkg debug/elf, const R_AARCH64_TLSLD_ADR_PAGE21 R_AARCH64
|
||||
pkg debug/elf, const R_AARCH64_TLSLD_ADR_PREL21 = 517
|
||||
pkg debug/elf, const R_AARCH64_TLSLD_ADR_PREL21 R_AARCH64
|
||||
pkg debug/elf, const R_AARCH64_TLSLD_LDST128_DTPREL_LO12 = 572
|
||||
pkg debug/elf, const R_AARCH64_TLSLD_LDST128_DTPREL_LO12 R_AARCH64
|
||||
pkg debug/elf, const R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC = 573
|
||||
pkg debug/elf, const R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC R_AARCH64
|
||||
pkg debug/elf, const R_AARCH64_TLSLE_LDST128_TPREL_LO12 = 570
|
||||
pkg debug/elf, const R_AARCH64_TLSLE_LDST128_TPREL_LO12 R_AARCH64
|
||||
pkg debug/elf, const R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC = 571
|
||||
pkg debug/elf, const R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC R_AARCH64
|
||||
pkg debug/elf, const R_ARM_ABS32_NOI = 55
|
||||
pkg debug/elf, const R_ARM_ABS32_NOI R_ARM
|
||||
pkg debug/elf, const R_ARM_ALU_PCREL_15_8 = 33
|
||||
pkg debug/elf, const R_ARM_ALU_PCREL_15_8 R_ARM
|
||||
pkg debug/elf, const R_ARM_ALU_PCREL_23_15 = 34
|
||||
pkg debug/elf, const R_ARM_ALU_PCREL_23_15 R_ARM
|
||||
pkg debug/elf, const R_ARM_ALU_PCREL_7_0 = 32
|
||||
pkg debug/elf, const R_ARM_ALU_PCREL_7_0 R_ARM
|
||||
pkg debug/elf, const R_ARM_ALU_PC_G0 = 58
|
||||
pkg debug/elf, const R_ARM_ALU_PC_G0 R_ARM
|
||||
pkg debug/elf, const R_ARM_ALU_PC_G0_NC = 57
|
||||
pkg debug/elf, const R_ARM_ALU_PC_G0_NC R_ARM
|
||||
pkg debug/elf, const R_ARM_ALU_PC_G1 = 60
|
||||
pkg debug/elf, const R_ARM_ALU_PC_G1 R_ARM
|
||||
pkg debug/elf, const R_ARM_ALU_PC_G1_NC = 59
|
||||
pkg debug/elf, const R_ARM_ALU_PC_G1_NC R_ARM
|
||||
pkg debug/elf, const R_ARM_ALU_PC_G2 = 61
|
||||
pkg debug/elf, const R_ARM_ALU_PC_G2 R_ARM
|
||||
pkg debug/elf, const R_ARM_ALU_SBREL_19_12_NC = 36
|
||||
pkg debug/elf, const R_ARM_ALU_SBREL_19_12_NC R_ARM
|
||||
pkg debug/elf, const R_ARM_ALU_SBREL_27_20_CK = 37
|
||||
pkg debug/elf, const R_ARM_ALU_SBREL_27_20_CK R_ARM
|
||||
pkg debug/elf, const R_ARM_ALU_SB_G0 = 71
|
||||
pkg debug/elf, const R_ARM_ALU_SB_G0 R_ARM
|
||||
pkg debug/elf, const R_ARM_ALU_SB_G0_NC = 70
|
||||
pkg debug/elf, const R_ARM_ALU_SB_G0_NC R_ARM
|
||||
pkg debug/elf, const R_ARM_ALU_SB_G1 = 73
|
||||
pkg debug/elf, const R_ARM_ALU_SB_G1 R_ARM
|
||||
pkg debug/elf, const R_ARM_ALU_SB_G1_NC = 72
|
||||
pkg debug/elf, const R_ARM_ALU_SB_G1_NC R_ARM
|
||||
pkg debug/elf, const R_ARM_ALU_SB_G2 = 74
|
||||
pkg debug/elf, const R_ARM_ALU_SB_G2 R_ARM
|
||||
pkg debug/elf, const R_ARM_BASE_ABS = 31
|
||||
pkg debug/elf, const R_ARM_BASE_ABS R_ARM
|
||||
pkg debug/elf, const R_ARM_CALL = 28
|
||||
pkg debug/elf, const R_ARM_CALL R_ARM
|
||||
pkg debug/elf, const R_ARM_GOTOFF12 = 98
|
||||
pkg debug/elf, const R_ARM_GOTOFF12 R_ARM
|
||||
pkg debug/elf, const R_ARM_GOTRELAX = 99
|
||||
pkg debug/elf, const R_ARM_GOTRELAX R_ARM
|
||||
pkg debug/elf, const R_ARM_GOT_ABS = 95
|
||||
pkg debug/elf, const R_ARM_GOT_ABS R_ARM
|
||||
pkg debug/elf, const R_ARM_GOT_BREL12 = 97
|
||||
pkg debug/elf, const R_ARM_GOT_BREL12 R_ARM
|
||||
pkg debug/elf, const R_ARM_GOT_PREL = 96
|
||||
pkg debug/elf, const R_ARM_GOT_PREL R_ARM
|
||||
pkg debug/elf, const R_ARM_IRELATIVE = 160
|
||||
pkg debug/elf, const R_ARM_IRELATIVE R_ARM
|
||||
pkg debug/elf, const R_ARM_JUMP24 = 29
|
||||
pkg debug/elf, const R_ARM_JUMP24 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDC_PC_G0 = 67
|
||||
pkg debug/elf, const R_ARM_LDC_PC_G0 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDC_PC_G1 = 68
|
||||
pkg debug/elf, const R_ARM_LDC_PC_G1 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDC_PC_G2 = 69
|
||||
pkg debug/elf, const R_ARM_LDC_PC_G2 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDC_SB_G0 = 81
|
||||
pkg debug/elf, const R_ARM_LDC_SB_G0 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDC_SB_G1 = 82
|
||||
pkg debug/elf, const R_ARM_LDC_SB_G1 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDC_SB_G2 = 83
|
||||
pkg debug/elf, const R_ARM_LDC_SB_G2 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDRS_PC_G0 = 64
|
||||
pkg debug/elf, const R_ARM_LDRS_PC_G0 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDRS_PC_G1 = 65
|
||||
pkg debug/elf, const R_ARM_LDRS_PC_G1 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDRS_PC_G2 = 66
|
||||
pkg debug/elf, const R_ARM_LDRS_PC_G2 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDRS_SB_G0 = 78
|
||||
pkg debug/elf, const R_ARM_LDRS_SB_G0 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDRS_SB_G1 = 79
|
||||
pkg debug/elf, const R_ARM_LDRS_SB_G1 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDRS_SB_G2 = 80
|
||||
pkg debug/elf, const R_ARM_LDRS_SB_G2 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDR_PC_G1 = 62
|
||||
pkg debug/elf, const R_ARM_LDR_PC_G1 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDR_PC_G2 = 63
|
||||
pkg debug/elf, const R_ARM_LDR_PC_G2 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDR_SBREL_11_10_NC = 35
|
||||
pkg debug/elf, const R_ARM_LDR_SBREL_11_10_NC R_ARM
|
||||
pkg debug/elf, const R_ARM_LDR_SB_G0 = 75
|
||||
pkg debug/elf, const R_ARM_LDR_SB_G0 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDR_SB_G1 = 76
|
||||
pkg debug/elf, const R_ARM_LDR_SB_G1 R_ARM
|
||||
pkg debug/elf, const R_ARM_LDR_SB_G2 = 77
|
||||
pkg debug/elf, const R_ARM_LDR_SB_G2 R_ARM
|
||||
pkg debug/elf, const R_ARM_ME_TOO = 128
|
||||
pkg debug/elf, const R_ARM_ME_TOO R_ARM
|
||||
pkg debug/elf, const R_ARM_MOVT_ABS = 44
|
||||
pkg debug/elf, const R_ARM_MOVT_ABS R_ARM
|
||||
pkg debug/elf, const R_ARM_MOVT_BREL = 85
|
||||
pkg debug/elf, const R_ARM_MOVT_BREL R_ARM
|
||||
pkg debug/elf, const R_ARM_MOVT_PREL = 46
|
||||
pkg debug/elf, const R_ARM_MOVT_PREL R_ARM
|
||||
pkg debug/elf, const R_ARM_MOVW_ABS_NC = 43
|
||||
pkg debug/elf, const R_ARM_MOVW_ABS_NC R_ARM
|
||||
pkg debug/elf, const R_ARM_MOVW_BREL = 86
|
||||
pkg debug/elf, const R_ARM_MOVW_BREL R_ARM
|
||||
pkg debug/elf, const R_ARM_MOVW_BREL_NC = 84
|
||||
pkg debug/elf, const R_ARM_MOVW_BREL_NC R_ARM
|
||||
pkg debug/elf, const R_ARM_MOVW_PREL_NC = 45
|
||||
pkg debug/elf, const R_ARM_MOVW_PREL_NC R_ARM
|
||||
pkg debug/elf, const R_ARM_PLT32_ABS = 94
|
||||
pkg debug/elf, const R_ARM_PLT32_ABS R_ARM
|
||||
pkg debug/elf, const R_ARM_PREL31 = 42
|
||||
pkg debug/elf, const R_ARM_PREL31 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_0 = 112
|
||||
pkg debug/elf, const R_ARM_PRIVATE_0 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_1 = 113
|
||||
pkg debug/elf, const R_ARM_PRIVATE_1 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_10 = 122
|
||||
pkg debug/elf, const R_ARM_PRIVATE_10 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_11 = 123
|
||||
pkg debug/elf, const R_ARM_PRIVATE_11 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_12 = 124
|
||||
pkg debug/elf, const R_ARM_PRIVATE_12 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_13 = 125
|
||||
pkg debug/elf, const R_ARM_PRIVATE_13 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_14 = 126
|
||||
pkg debug/elf, const R_ARM_PRIVATE_14 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_15 = 127
|
||||
pkg debug/elf, const R_ARM_PRIVATE_15 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_2 = 114
|
||||
pkg debug/elf, const R_ARM_PRIVATE_2 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_3 = 115
|
||||
pkg debug/elf, const R_ARM_PRIVATE_3 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_4 = 116
|
||||
pkg debug/elf, const R_ARM_PRIVATE_4 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_5 = 117
|
||||
pkg debug/elf, const R_ARM_PRIVATE_5 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_6 = 118
|
||||
pkg debug/elf, const R_ARM_PRIVATE_6 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_7 = 119
|
||||
pkg debug/elf, const R_ARM_PRIVATE_7 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_8 = 120
|
||||
pkg debug/elf, const R_ARM_PRIVATE_8 R_ARM
|
||||
pkg debug/elf, const R_ARM_PRIVATE_9 = 121
|
||||
pkg debug/elf, const R_ARM_PRIVATE_9 R_ARM
|
||||
pkg debug/elf, const R_ARM_REL32_NOI = 56
|
||||
pkg debug/elf, const R_ARM_REL32_NOI R_ARM
|
||||
pkg debug/elf, const R_ARM_RXPC25 = 249
|
||||
pkg debug/elf, const R_ARM_RXPC25 R_ARM
|
||||
pkg debug/elf, const R_ARM_SBREL31 = 39
|
||||
pkg debug/elf, const R_ARM_SBREL31 R_ARM
|
||||
pkg debug/elf, const R_ARM_TARGET1 = 38
|
||||
pkg debug/elf, const R_ARM_TARGET1 R_ARM
|
||||
pkg debug/elf, const R_ARM_TARGET2 = 41
|
||||
pkg debug/elf, const R_ARM_TARGET2 R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_ALU_ABS_G0_NC = 132
|
||||
pkg debug/elf, const R_ARM_THM_ALU_ABS_G0_NC R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_ALU_ABS_G1_NC = 133
|
||||
pkg debug/elf, const R_ARM_THM_ALU_ABS_G1_NC R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_ALU_ABS_G2_NC = 134
|
||||
pkg debug/elf, const R_ARM_THM_ALU_ABS_G2_NC R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_ALU_ABS_G3 = 135
|
||||
pkg debug/elf, const R_ARM_THM_ALU_ABS_G3 R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_ALU_PREL_11_0 = 53
|
||||
pkg debug/elf, const R_ARM_THM_ALU_PREL_11_0 R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_GOT_BREL12 = 131
|
||||
pkg debug/elf, const R_ARM_THM_GOT_BREL12 R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_JUMP11 = 102
|
||||
pkg debug/elf, const R_ARM_THM_JUMP11 R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_JUMP19 = 51
|
||||
pkg debug/elf, const R_ARM_THM_JUMP19 R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_JUMP24 = 30
|
||||
pkg debug/elf, const R_ARM_THM_JUMP24 R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_JUMP6 = 52
|
||||
pkg debug/elf, const R_ARM_THM_JUMP6 R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_JUMP8 = 103
|
||||
pkg debug/elf, const R_ARM_THM_JUMP8 R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_MOVT_ABS = 48
|
||||
pkg debug/elf, const R_ARM_THM_MOVT_ABS R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_MOVT_BREL = 88
|
||||
pkg debug/elf, const R_ARM_THM_MOVT_BREL R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_MOVT_PREL = 50
|
||||
pkg debug/elf, const R_ARM_THM_MOVT_PREL R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_MOVW_ABS_NC = 47
|
||||
pkg debug/elf, const R_ARM_THM_MOVW_ABS_NC R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_MOVW_BREL = 89
|
||||
pkg debug/elf, const R_ARM_THM_MOVW_BREL R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_MOVW_BREL_NC = 87
|
||||
pkg debug/elf, const R_ARM_THM_MOVW_BREL_NC R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_MOVW_PREL_NC = 49
|
||||
pkg debug/elf, const R_ARM_THM_MOVW_PREL_NC R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_PC12 = 54
|
||||
pkg debug/elf, const R_ARM_THM_PC12 R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_TLS_CALL = 93
|
||||
pkg debug/elf, const R_ARM_THM_TLS_CALL R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_TLS_DESCSEQ16 = 129
|
||||
pkg debug/elf, const R_ARM_THM_TLS_DESCSEQ16 R_ARM
|
||||
pkg debug/elf, const R_ARM_THM_TLS_DESCSEQ32 = 130
|
||||
pkg debug/elf, const R_ARM_THM_TLS_DESCSEQ32 R_ARM
|
||||
pkg debug/elf, const R_ARM_TLS_CALL = 91
|
||||
pkg debug/elf, const R_ARM_TLS_CALL R_ARM
|
||||
pkg debug/elf, const R_ARM_TLS_DESCSEQ = 92
|
||||
pkg debug/elf, const R_ARM_TLS_DESCSEQ R_ARM
|
||||
pkg debug/elf, const R_ARM_TLS_DTPMOD32 = 17
|
||||
pkg debug/elf, const R_ARM_TLS_DTPMOD32 R_ARM
|
||||
pkg debug/elf, const R_ARM_TLS_DTPOFF32 = 18
|
||||
pkg debug/elf, const R_ARM_TLS_DTPOFF32 R_ARM
|
||||
pkg debug/elf, const R_ARM_TLS_GD32 = 104
|
||||
pkg debug/elf, const R_ARM_TLS_GD32 R_ARM
|
||||
pkg debug/elf, const R_ARM_TLS_GOTDESC = 90
|
||||
pkg debug/elf, const R_ARM_TLS_GOTDESC R_ARM
|
||||
pkg debug/elf, const R_ARM_TLS_IE12GP = 111
|
||||
pkg debug/elf, const R_ARM_TLS_IE12GP R_ARM
|
||||
pkg debug/elf, const R_ARM_TLS_IE32 = 107
|
||||
pkg debug/elf, const R_ARM_TLS_IE32 R_ARM
|
||||
pkg debug/elf, const R_ARM_TLS_LDM32 = 105
|
||||
pkg debug/elf, const R_ARM_TLS_LDM32 R_ARM
|
||||
pkg debug/elf, const R_ARM_TLS_LDO12 = 109
|
||||
pkg debug/elf, const R_ARM_TLS_LDO12 R_ARM
|
||||
pkg debug/elf, const R_ARM_TLS_LDO32 = 106
|
||||
pkg debug/elf, const R_ARM_TLS_LDO32 R_ARM
|
||||
pkg debug/elf, const R_ARM_TLS_LE12 = 110
|
||||
pkg debug/elf, const R_ARM_TLS_LE12 R_ARM
|
||||
pkg debug/elf, const R_ARM_TLS_LE32 = 108
|
||||
pkg debug/elf, const R_ARM_TLS_LE32 R_ARM
|
||||
pkg debug/elf, const R_ARM_TLS_TPOFF32 = 19
|
||||
pkg debug/elf, const R_ARM_TLS_TPOFF32 R_ARM
|
||||
pkg debug/elf, const R_ARM_V4BX = 40
|
||||
pkg debug/elf, const R_ARM_V4BX R_ARM
|
||||
pkg debug/elf, const R_PPC64_ADDR16_HIGH = 110
|
||||
pkg debug/elf, const R_PPC64_ADDR16_HIGH R_PPC64
|
||||
pkg debug/elf, const R_PPC64_ADDR16_HIGHA = 111
|
||||
pkg debug/elf, const R_PPC64_ADDR16_HIGHA R_PPC64
|
||||
pkg debug/elf, const R_PPC64_ADDR64_LOCAL = 117
|
||||
pkg debug/elf, const R_PPC64_ADDR64_LOCAL R_PPC64
|
||||
pkg debug/elf, const R_PPC64_DTPREL16_HIGH = 114
|
||||
pkg debug/elf, const R_PPC64_DTPREL16_HIGH R_PPC64
|
||||
pkg debug/elf, const R_PPC64_DTPREL16_HIGHA = 115
|
||||
pkg debug/elf, const R_PPC64_DTPREL16_HIGHA R_PPC64
|
||||
pkg debug/elf, const R_PPC64_ENTRY = 118
|
||||
pkg debug/elf, const R_PPC64_ENTRY R_PPC64
|
||||
pkg debug/elf, const R_PPC64_IRELATIVE = 248
|
||||
pkg debug/elf, const R_PPC64_IRELATIVE R_PPC64
|
||||
pkg debug/elf, const R_PPC64_JMP_IREL = 247
|
||||
pkg debug/elf, const R_PPC64_JMP_IREL R_PPC64
|
||||
pkg debug/elf, const R_PPC64_PLT16_LO_DS = 60
|
||||
pkg debug/elf, const R_PPC64_PLT16_LO_DS R_PPC64
|
||||
pkg debug/elf, const R_PPC64_PLTGOT16 = 52
|
||||
pkg debug/elf, const R_PPC64_PLTGOT16 R_PPC64
|
||||
pkg debug/elf, const R_PPC64_PLTGOT16_DS = 65
|
||||
pkg debug/elf, const R_PPC64_PLTGOT16_DS R_PPC64
|
||||
pkg debug/elf, const R_PPC64_PLTGOT16_HA = 55
|
||||
pkg debug/elf, const R_PPC64_PLTGOT16_HA R_PPC64
|
||||
pkg debug/elf, const R_PPC64_PLTGOT16_HI = 54
|
||||
pkg debug/elf, const R_PPC64_PLTGOT16_HI R_PPC64
|
||||
pkg debug/elf, const R_PPC64_PLTGOT16_LO = 53
|
||||
pkg debug/elf, const R_PPC64_PLTGOT16_LO R_PPC64
|
||||
pkg debug/elf, const R_PPC64_PLTGOT_LO_DS = 66
|
||||
pkg debug/elf, const R_PPC64_PLTGOT_LO_DS R_PPC64
|
||||
pkg debug/elf, const R_PPC64_REL16DX_HA = 246
|
||||
pkg debug/elf, const R_PPC64_REL16DX_HA R_PPC64
|
||||
pkg debug/elf, const R_PPC64_REL24_NOTOC = 116
|
||||
pkg debug/elf, const R_PPC64_REL24_NOTOC R_PPC64
|
||||
pkg debug/elf, const R_PPC64_SECTOFF_DS = 61
|
||||
pkg debug/elf, const R_PPC64_SECTOFF_DS R_PPC64
|
||||
pkg debug/elf, const R_PPC64_SECTOFF_LO_DS = 61
|
||||
pkg debug/elf, const R_PPC64_SECTOFF_LO_DS R_PPC64
|
||||
pkg debug/elf, const R_PPC64_TOCSAVE = 109
|
||||
pkg debug/elf, const R_PPC64_TOCSAVE R_PPC64
|
||||
pkg debug/elf, const R_PPC64_TPREL16_HIGH = 112
|
||||
pkg debug/elf, const R_PPC64_TPREL16_HIGH R_PPC64
|
||||
pkg debug/elf, const R_PPC64_TPREL16_HIGHA = 113
|
||||
pkg debug/elf, const R_PPC64_TPREL16_HIGHA R_PPC64
|
||||
pkg debug/elf, const R_X86_64_GOT64 = 27
|
||||
pkg debug/elf, const R_X86_64_GOT64 R_X86_64
|
||||
pkg debug/elf, const R_X86_64_GOTOFF64 = 25
|
||||
pkg debug/elf, const R_X86_64_GOTOFF64 R_X86_64
|
||||
pkg debug/elf, const R_X86_64_GOTPC32 = 26
|
||||
pkg debug/elf, const R_X86_64_GOTPC32 R_X86_64
|
||||
pkg debug/elf, const R_X86_64_GOTPC32_TLSDESC = 34
|
||||
pkg debug/elf, const R_X86_64_GOTPC32_TLSDESC R_X86_64
|
||||
pkg debug/elf, const R_X86_64_GOTPC64 = 29
|
||||
pkg debug/elf, const R_X86_64_GOTPC64 R_X86_64
|
||||
pkg debug/elf, const R_X86_64_GOTPCREL64 = 28
|
||||
pkg debug/elf, const R_X86_64_GOTPCREL64 R_X86_64
|
||||
pkg debug/elf, const R_X86_64_GOTPCRELX = 41
|
||||
pkg debug/elf, const R_X86_64_GOTPCRELX R_X86_64
|
||||
pkg debug/elf, const R_X86_64_GOTPLT64 = 30
|
||||
pkg debug/elf, const R_X86_64_GOTPLT64 R_X86_64
|
||||
pkg debug/elf, const R_X86_64_IRELATIVE = 37
|
||||
pkg debug/elf, const R_X86_64_IRELATIVE R_X86_64
|
||||
pkg debug/elf, const R_X86_64_PC32_BND = 39
|
||||
pkg debug/elf, const R_X86_64_PC32_BND R_X86_64
|
||||
pkg debug/elf, const R_X86_64_PC64 = 24
|
||||
pkg debug/elf, const R_X86_64_PC64 R_X86_64
|
||||
pkg debug/elf, const R_X86_64_PLT32_BND = 40
|
||||
pkg debug/elf, const R_X86_64_PLT32_BND R_X86_64
|
||||
pkg debug/elf, const R_X86_64_PLTOFF64 = 31
|
||||
pkg debug/elf, const R_X86_64_PLTOFF64 R_X86_64
|
||||
pkg debug/elf, const R_X86_64_RELATIVE64 = 38
|
||||
pkg debug/elf, const R_X86_64_RELATIVE64 R_X86_64
|
||||
pkg debug/elf, const R_X86_64_REX_GOTPCRELX = 42
|
||||
pkg debug/elf, const R_X86_64_REX_GOTPCRELX R_X86_64
|
||||
pkg debug/elf, const R_X86_64_SIZE32 = 32
|
||||
pkg debug/elf, const R_X86_64_SIZE32 R_X86_64
|
||||
pkg debug/elf, const R_X86_64_SIZE64 = 33
|
||||
pkg debug/elf, const R_X86_64_SIZE64 R_X86_64
|
||||
pkg debug/elf, const R_X86_64_TLSDESC = 36
|
||||
pkg debug/elf, const R_X86_64_TLSDESC R_X86_64
|
||||
pkg debug/elf, const R_X86_64_TLSDESC_CALL = 35
|
||||
pkg debug/elf, const R_X86_64_TLSDESC_CALL R_X86_64
|
||||
pkg debug/macho, const ARM64_RELOC_ADDEND = 10
|
||||
pkg debug/macho, const ARM64_RELOC_ADDEND RelocTypeARM64
|
||||
pkg debug/macho, const ARM64_RELOC_BRANCH26 = 2
|
||||
pkg debug/macho, const ARM64_RELOC_BRANCH26 RelocTypeARM64
|
||||
pkg debug/macho, const ARM64_RELOC_GOT_LOAD_PAGE21 = 5
|
||||
pkg debug/macho, const ARM64_RELOC_GOT_LOAD_PAGE21 RelocTypeARM64
|
||||
pkg debug/macho, const ARM64_RELOC_GOT_LOAD_PAGEOFF12 = 6
|
||||
pkg debug/macho, const ARM64_RELOC_GOT_LOAD_PAGEOFF12 RelocTypeARM64
|
||||
pkg debug/macho, const ARM64_RELOC_PAGE21 = 3
|
||||
pkg debug/macho, const ARM64_RELOC_PAGE21 RelocTypeARM64
|
||||
pkg debug/macho, const ARM64_RELOC_PAGEOFF12 = 4
|
||||
pkg debug/macho, const ARM64_RELOC_PAGEOFF12 RelocTypeARM64
|
||||
pkg debug/macho, const ARM64_RELOC_POINTER_TO_GOT = 7
|
||||
pkg debug/macho, const ARM64_RELOC_POINTER_TO_GOT RelocTypeARM64
|
||||
pkg debug/macho, const ARM64_RELOC_SUBTRACTOR = 1
|
||||
pkg debug/macho, const ARM64_RELOC_SUBTRACTOR RelocTypeARM64
|
||||
pkg debug/macho, const ARM64_RELOC_TLVP_LOAD_PAGE21 = 8
|
||||
pkg debug/macho, const ARM64_RELOC_TLVP_LOAD_PAGE21 RelocTypeARM64
|
||||
pkg debug/macho, const ARM64_RELOC_TLVP_LOAD_PAGEOFF12 = 9
|
||||
pkg debug/macho, const ARM64_RELOC_TLVP_LOAD_PAGEOFF12 RelocTypeARM64
|
||||
pkg debug/macho, const ARM64_RELOC_UNSIGNED = 0
|
||||
pkg debug/macho, const ARM64_RELOC_UNSIGNED RelocTypeARM64
|
||||
pkg debug/macho, const ARM_RELOC_BR24 = 5
|
||||
pkg debug/macho, const ARM_RELOC_BR24 RelocTypeARM
|
||||
pkg debug/macho, const ARM_RELOC_HALF = 8
|
||||
pkg debug/macho, const ARM_RELOC_HALF RelocTypeARM
|
||||
pkg debug/macho, const ARM_RELOC_HALF_SECTDIFF = 9
|
||||
pkg debug/macho, const ARM_RELOC_HALF_SECTDIFF RelocTypeARM
|
||||
pkg debug/macho, const ARM_RELOC_LOCAL_SECTDIFF = 3
|
||||
pkg debug/macho, const ARM_RELOC_LOCAL_SECTDIFF RelocTypeARM
|
||||
pkg debug/macho, const ARM_RELOC_PAIR = 1
|
||||
pkg debug/macho, const ARM_RELOC_PAIR RelocTypeARM
|
||||
pkg debug/macho, const ARM_RELOC_PB_LA_PTR = 4
|
||||
pkg debug/macho, const ARM_RELOC_PB_LA_PTR RelocTypeARM
|
||||
pkg debug/macho, const ARM_RELOC_SECTDIFF = 2
|
||||
pkg debug/macho, const ARM_RELOC_SECTDIFF RelocTypeARM
|
||||
pkg debug/macho, const ARM_RELOC_VANILLA = 0
|
||||
pkg debug/macho, const ARM_RELOC_VANILLA RelocTypeARM
|
||||
pkg debug/macho, const ARM_THUMB_32BIT_BRANCH = 7
|
||||
pkg debug/macho, const ARM_THUMB_32BIT_BRANCH RelocTypeARM
|
||||
pkg debug/macho, const ARM_THUMB_RELOC_BR22 = 6
|
||||
pkg debug/macho, const ARM_THUMB_RELOC_BR22 RelocTypeARM
|
||||
pkg debug/macho, const FlagAllModsBound = 4096
|
||||
pkg debug/macho, const FlagAllModsBound uint32
|
||||
pkg debug/macho, const FlagAllowStackExecution = 131072
|
||||
pkg debug/macho, const FlagAllowStackExecution uint32
|
||||
pkg debug/macho, const FlagAppExtensionSafe = 33554432
|
||||
pkg debug/macho, const FlagAppExtensionSafe uint32
|
||||
pkg debug/macho, const FlagBindAtLoad = 8
|
||||
pkg debug/macho, const FlagBindAtLoad uint32
|
||||
pkg debug/macho, const FlagBindsToWeak = 65536
|
||||
pkg debug/macho, const FlagBindsToWeak uint32
|
||||
pkg debug/macho, const FlagCanonical = 16384
|
||||
pkg debug/macho, const FlagCanonical uint32
|
||||
pkg debug/macho, const FlagDeadStrippableDylib = 4194304
|
||||
pkg debug/macho, const FlagDeadStrippableDylib uint32
|
||||
pkg debug/macho, const FlagDyldLink = 4
|
||||
pkg debug/macho, const FlagDyldLink uint32
|
||||
pkg debug/macho, const FlagForceFlat = 256
|
||||
pkg debug/macho, const FlagForceFlat uint32
|
||||
pkg debug/macho, const FlagHasTLVDescriptors = 8388608
|
||||
pkg debug/macho, const FlagHasTLVDescriptors uint32
|
||||
pkg debug/macho, const FlagIncrLink = 2
|
||||
pkg debug/macho, const FlagIncrLink uint32
|
||||
pkg debug/macho, const FlagLazyInit = 64
|
||||
pkg debug/macho, const FlagLazyInit uint32
|
||||
pkg debug/macho, const FlagNoFixPrebinding = 1024
|
||||
pkg debug/macho, const FlagNoFixPrebinding uint32
|
||||
pkg debug/macho, const FlagNoHeapExecution = 16777216
|
||||
pkg debug/macho, const FlagNoHeapExecution uint32
|
||||
pkg debug/macho, const FlagNoMultiDefs = 512
|
||||
pkg debug/macho, const FlagNoMultiDefs uint32
|
||||
pkg debug/macho, const FlagNoReexportedDylibs = 1048576
|
||||
pkg debug/macho, const FlagNoReexportedDylibs uint32
|
||||
pkg debug/macho, const FlagNoUndefs = 1
|
||||
pkg debug/macho, const FlagNoUndefs uint32
|
||||
pkg debug/macho, const FlagPIE = 2097152
|
||||
pkg debug/macho, const FlagPIE uint32
|
||||
pkg debug/macho, const FlagPrebindable = 2048
|
||||
pkg debug/macho, const FlagPrebindable uint32
|
||||
pkg debug/macho, const FlagPrebound = 16
|
||||
pkg debug/macho, const FlagPrebound uint32
|
||||
pkg debug/macho, const FlagRootSafe = 262144
|
||||
pkg debug/macho, const FlagRootSafe uint32
|
||||
pkg debug/macho, const FlagSetuidSafe = 524288
|
||||
pkg debug/macho, const FlagSetuidSafe uint32
|
||||
pkg debug/macho, const FlagSplitSegs = 32
|
||||
pkg debug/macho, const FlagSplitSegs uint32
|
||||
pkg debug/macho, const FlagSubsectionsViaSymbols = 8192
|
||||
pkg debug/macho, const FlagSubsectionsViaSymbols uint32
|
||||
pkg debug/macho, const FlagTwoLevel = 128
|
||||
pkg debug/macho, const FlagTwoLevel uint32
|
||||
pkg debug/macho, const FlagWeakDefines = 32768
|
||||
pkg debug/macho, const FlagWeakDefines uint32
|
||||
pkg debug/macho, const GENERIC_RELOC_LOCAL_SECTDIFF = 4
|
||||
pkg debug/macho, const GENERIC_RELOC_LOCAL_SECTDIFF RelocTypeGeneric
|
||||
pkg debug/macho, const GENERIC_RELOC_PAIR = 1
|
||||
pkg debug/macho, const GENERIC_RELOC_PAIR RelocTypeGeneric
|
||||
pkg debug/macho, const GENERIC_RELOC_PB_LA_PTR = 3
|
||||
pkg debug/macho, const GENERIC_RELOC_PB_LA_PTR RelocTypeGeneric
|
||||
pkg debug/macho, const GENERIC_RELOC_SECTDIFF = 2
|
||||
pkg debug/macho, const GENERIC_RELOC_SECTDIFF RelocTypeGeneric
|
||||
pkg debug/macho, const GENERIC_RELOC_TLV = 5
|
||||
pkg debug/macho, const GENERIC_RELOC_TLV RelocTypeGeneric
|
||||
pkg debug/macho, const GENERIC_RELOC_VANILLA = 0
|
||||
pkg debug/macho, const GENERIC_RELOC_VANILLA RelocTypeGeneric
|
||||
pkg debug/macho, const LoadCmdRpath = 2147483676
|
||||
pkg debug/macho, const LoadCmdRpath LoadCmd
|
||||
pkg debug/macho, const X86_64_RELOC_BRANCH = 2
|
||||
pkg debug/macho, const X86_64_RELOC_BRANCH RelocTypeX86_64
|
||||
pkg debug/macho, const X86_64_RELOC_GOT = 4
|
||||
pkg debug/macho, const X86_64_RELOC_GOT RelocTypeX86_64
|
||||
pkg debug/macho, const X86_64_RELOC_GOT_LOAD = 3
|
||||
pkg debug/macho, const X86_64_RELOC_GOT_LOAD RelocTypeX86_64
|
||||
pkg debug/macho, const X86_64_RELOC_SIGNED = 1
|
||||
pkg debug/macho, const X86_64_RELOC_SIGNED RelocTypeX86_64
|
||||
pkg debug/macho, const X86_64_RELOC_SIGNED_1 = 6
|
||||
pkg debug/macho, const X86_64_RELOC_SIGNED_1 RelocTypeX86_64
|
||||
pkg debug/macho, const X86_64_RELOC_SIGNED_2 = 7
|
||||
pkg debug/macho, const X86_64_RELOC_SIGNED_2 RelocTypeX86_64
|
||||
pkg debug/macho, const X86_64_RELOC_SIGNED_4 = 8
|
||||
pkg debug/macho, const X86_64_RELOC_SIGNED_4 RelocTypeX86_64
|
||||
pkg debug/macho, const X86_64_RELOC_SUBTRACTOR = 5
|
||||
pkg debug/macho, const X86_64_RELOC_SUBTRACTOR RelocTypeX86_64
|
||||
pkg debug/macho, const X86_64_RELOC_TLV = 9
|
||||
pkg debug/macho, const X86_64_RELOC_TLV RelocTypeX86_64
|
||||
pkg debug/macho, const X86_64_RELOC_UNSIGNED = 0
|
||||
pkg debug/macho, const X86_64_RELOC_UNSIGNED RelocTypeX86_64
|
||||
pkg debug/macho, method (RelocTypeARM) GoString() string
|
||||
pkg debug/macho, method (RelocTypeARM) String() string
|
||||
pkg debug/macho, method (RelocTypeARM64) GoString() string
|
||||
pkg debug/macho, method (RelocTypeARM64) String() string
|
||||
pkg debug/macho, method (RelocTypeGeneric) GoString() string
|
||||
pkg debug/macho, method (RelocTypeGeneric) String() string
|
||||
pkg debug/macho, method (RelocTypeX86_64) GoString() string
|
||||
pkg debug/macho, method (RelocTypeX86_64) String() string
|
||||
pkg debug/macho, method (Rpath) Raw() []uint8
|
||||
pkg debug/macho, method (Type) GoString() string
|
||||
pkg debug/macho, method (Type) String() string
|
||||
pkg debug/macho, type Reloc struct
|
||||
pkg debug/macho, type Reloc struct, Addr uint32
|
||||
pkg debug/macho, type Reloc struct, Extern bool
|
||||
pkg debug/macho, type Reloc struct, Len uint8
|
||||
pkg debug/macho, type Reloc struct, Pcrel bool
|
||||
pkg debug/macho, type Reloc struct, Scattered bool
|
||||
pkg debug/macho, type Reloc struct, Type uint8
|
||||
pkg debug/macho, type Reloc struct, Value uint32
|
||||
pkg debug/macho, type RelocTypeARM int
|
||||
pkg debug/macho, type RelocTypeARM64 int
|
||||
pkg debug/macho, type RelocTypeGeneric int
|
||||
pkg debug/macho, type RelocTypeX86_64 int
|
||||
pkg debug/macho, type Rpath struct
|
||||
pkg debug/macho, type Rpath struct, Path string
|
||||
pkg debug/macho, type Rpath struct, embedded LoadBytes
|
||||
pkg debug/macho, type RpathCmd struct
|
||||
pkg debug/macho, type RpathCmd struct, Cmd LoadCmd
|
||||
pkg debug/macho, type RpathCmd struct, Len uint32
|
||||
pkg debug/macho, type RpathCmd struct, Path uint32
|
||||
pkg debug/macho, type Section struct, Relocs []Reloc
|
||||
pkg encoding/asn1, const TagNumericString = 18
|
||||
pkg encoding/asn1, const TagNumericString ideal-int
|
||||
pkg encoding/asn1, func MarshalWithParams(interface{}, string) ([]uint8, error)
|
||||
pkg encoding/csv, type ParseError struct, StartLine int
|
||||
pkg encoding/hex, func NewDecoder(io.Reader) io.Reader
|
||||
pkg encoding/hex, func NewEncoder(io.Writer) io.Writer
|
||||
pkg encoding/json, method (*Decoder) DisallowUnknownFields()
|
||||
pkg encoding/xml, func NewTokenDecoder(TokenReader) *Decoder
|
||||
pkg encoding/xml, type TokenReader interface { Token }
|
||||
pkg encoding/xml, type TokenReader interface, Token() (Token, error)
|
||||
pkg flag, method (*FlagSet) ErrorHandling() ErrorHandling
|
||||
pkg flag, method (*FlagSet) Name() string
|
||||
pkg flag, method (*FlagSet) Output() io.Writer
|
||||
pkg html/template, type Srcset string
|
||||
pkg math, func Erfcinv(float64) float64
|
||||
pkg math, func Erfinv(float64) float64
|
||||
pkg math, func Round(float64) float64
|
||||
pkg math, func RoundToEven(float64) float64
|
||||
pkg math/big, const MaxBase = 62
|
||||
pkg math/big, method (*Float) Sqrt(*Float) *Float
|
||||
pkg math/big, method (*Int) CmpAbs(*Int) int
|
||||
pkg math/rand, func Shuffle(int, func(int, int))
|
||||
pkg math/rand, method (*Rand) Shuffle(int, func(int, int))
|
||||
pkg net, method (*TCPListener) SyscallConn() (syscall.RawConn, error)
|
||||
pkg net, method (*UnixListener) SyscallConn() (syscall.RawConn, error)
|
||||
pkg net/smtp, method (*Client) Noop() error
|
||||
pkg os, func IsTimeout(error) bool
|
||||
pkg os, method (*File) SetDeadline(time.Time) error
|
||||
pkg os, method (*File) SetReadDeadline(time.Time) error
|
||||
pkg os, method (*File) SetWriteDeadline(time.Time) error
|
||||
pkg os, method (*PathError) Timeout() bool
|
||||
pkg os, method (*SyscallError) Timeout() bool
|
||||
pkg os, var ErrNoDeadline error
|
||||
pkg strings, method (*Builder) Grow(int)
|
||||
pkg strings, method (*Builder) Len() int
|
||||
pkg strings, method (*Builder) Reset()
|
||||
pkg strings, method (*Builder) String() string
|
||||
pkg strings, method (*Builder) Write([]uint8) (int, error)
|
||||
pkg strings, method (*Builder) WriteByte(uint8) error
|
||||
pkg strings, method (*Builder) WriteRune(int32) (int, error)
|
||||
pkg strings, method (*Builder) WriteString(string) (int, error)
|
||||
pkg strings, type Builder struct
|
||||
pkg syscall (freebsd-386), const SYS_UTIMENSAT = 547
|
||||
pkg syscall (freebsd-386), const SYS_UTIMENSAT ideal-int
|
||||
pkg syscall (freebsd-386-cgo), const SYS_UTIMENSAT = 547
|
||||
pkg syscall (freebsd-386-cgo), const SYS_UTIMENSAT ideal-int
|
||||
pkg syscall (freebsd-amd64), const SYS_UTIMENSAT = 547
|
||||
pkg syscall (freebsd-amd64), const SYS_UTIMENSAT ideal-int
|
||||
pkg syscall (freebsd-amd64-cgo), const SYS_UTIMENSAT = 547
|
||||
pkg syscall (freebsd-amd64-cgo), const SYS_UTIMENSAT ideal-int
|
||||
pkg syscall (freebsd-arm), const SYS_UTIMENSAT = 547
|
||||
pkg syscall (freebsd-arm), const SYS_UTIMENSAT ideal-int
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_UTIMENSAT = 547
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_UTIMENSAT ideal-int
|
||||
pkg syscall (windows-386), func CreateProcessAsUser(Token, *uint16, *uint16, *SecurityAttributes, *SecurityAttributes, bool, uint32, *uint16, *uint16, *StartupInfo, *ProcessInformation) error
|
||||
pkg syscall (windows-386), type SysProcAttr struct, Token Token
|
||||
pkg syscall (windows-amd64), func CreateProcessAsUser(Token, *uint16, *uint16, *SecurityAttributes, *SecurityAttributes, bool, uint32, *uint16, *uint16, *StartupInfo, *ProcessInformation) error
|
||||
pkg syscall (windows-amd64), type SysProcAttr struct, Token Token
|
||||
pkg time, func LoadLocationFromTZData(string, []uint8) (*Location, error)
|
||||
pkg unicode, const Version = "10.0.0"
|
||||
pkg unicode, var Masaram_Gondi *RangeTable
|
||||
pkg unicode, var Nushu *RangeTable
|
||||
pkg unicode, var Regional_Indicator *RangeTable
|
||||
pkg unicode, var Soyombo *RangeTable
|
||||
pkg unicode, var Zanabazar_Square *RangeTable
|
||||
169
api/go1.9.txt
169
api/go1.9.txt
@@ -1,169 +0,0 @@
|
||||
pkg crypto, const BLAKE2b_256 = 17
|
||||
pkg crypto, const BLAKE2b_256 Hash
|
||||
pkg crypto, const BLAKE2b_384 = 18
|
||||
pkg crypto, const BLAKE2b_384 Hash
|
||||
pkg crypto, const BLAKE2b_512 = 19
|
||||
pkg crypto, const BLAKE2b_512 Hash
|
||||
pkg crypto, const BLAKE2s_256 = 16
|
||||
pkg crypto, const BLAKE2s_256 Hash
|
||||
pkg crypto/x509, type Certificate struct, ExcludedDNSDomains []string
|
||||
pkg database/sql, method (*Conn) BeginTx(context.Context, *TxOptions) (*Tx, error)
|
||||
pkg database/sql, method (*Conn) Close() error
|
||||
pkg database/sql, method (*Conn) ExecContext(context.Context, string, ...interface{}) (Result, error)
|
||||
pkg database/sql, method (*Conn) PingContext(context.Context) error
|
||||
pkg database/sql, method (*Conn) PrepareContext(context.Context, string) (*Stmt, error)
|
||||
pkg database/sql, method (*Conn) QueryContext(context.Context, string, ...interface{}) (*Rows, error)
|
||||
pkg database/sql, method (*Conn) QueryRowContext(context.Context, string, ...interface{}) *Row
|
||||
pkg database/sql, method (*DB) Conn(context.Context) (*Conn, error)
|
||||
pkg database/sql, type Conn struct
|
||||
pkg database/sql, type Out struct
|
||||
pkg database/sql, type Out struct, Dest interface{}
|
||||
pkg database/sql, type Out struct, In bool
|
||||
pkg database/sql, var ErrConnDone error
|
||||
pkg database/sql/driver, type NamedValueChecker interface { CheckNamedValue }
|
||||
pkg database/sql/driver, type NamedValueChecker interface, CheckNamedValue(*NamedValue) error
|
||||
pkg database/sql/driver, var ErrRemoveArgument error
|
||||
pkg encoding/asn1, const TagNull = 5
|
||||
pkg encoding/asn1, const TagNull ideal-int
|
||||
pkg encoding/asn1, var NullBytes []uint8
|
||||
pkg encoding/asn1, var NullRawValue RawValue
|
||||
pkg encoding/base32, const NoPadding = -1
|
||||
pkg encoding/base32, const NoPadding int32
|
||||
pkg encoding/base32, const StdPadding = 61
|
||||
pkg encoding/base32, const StdPadding int32
|
||||
pkg encoding/base32, method (Encoding) WithPadding(int32) *Encoding
|
||||
pkg encoding/csv, type Reader struct, ReuseRecord bool
|
||||
pkg encoding/json, func Valid([]uint8) bool
|
||||
pkg go/ast, type TypeSpec struct, Assign token.Pos
|
||||
pkg go/types, func SizesFor(string, string) Sizes
|
||||
pkg go/types, method (*TypeName) IsAlias() bool
|
||||
pkg hash/fnv, func New128() hash.Hash
|
||||
pkg hash/fnv, func New128a() hash.Hash
|
||||
pkg html/template, const ErrPredefinedEscaper = 11
|
||||
pkg html/template, const ErrPredefinedEscaper ErrorCode
|
||||
pkg image/png, type Encoder struct, BufferPool EncoderBufferPool
|
||||
pkg image/png, type EncoderBuffer struct
|
||||
pkg image/png, type EncoderBufferPool interface { Get, Put }
|
||||
pkg image/png, type EncoderBufferPool interface, Get() *EncoderBuffer
|
||||
pkg image/png, type EncoderBufferPool interface, Put(*EncoderBuffer)
|
||||
pkg math/big, method (*Int) IsInt64() bool
|
||||
pkg math/big, method (*Int) IsUint64() bool
|
||||
pkg math/big, type Word uint
|
||||
pkg math/bits, const UintSize = 64
|
||||
pkg math/bits, const UintSize ideal-int
|
||||
pkg math/bits, func LeadingZeros(uint) int
|
||||
pkg math/bits, func LeadingZeros16(uint16) int
|
||||
pkg math/bits, func LeadingZeros32(uint32) int
|
||||
pkg math/bits, func LeadingZeros64(uint64) int
|
||||
pkg math/bits, func LeadingZeros8(uint8) int
|
||||
pkg math/bits, func Len(uint) int
|
||||
pkg math/bits, func Len16(uint16) int
|
||||
pkg math/bits, func Len32(uint32) int
|
||||
pkg math/bits, func Len64(uint64) int
|
||||
pkg math/bits, func Len8(uint8) int
|
||||
pkg math/bits, func OnesCount(uint) int
|
||||
pkg math/bits, func OnesCount16(uint16) int
|
||||
pkg math/bits, func OnesCount32(uint32) int
|
||||
pkg math/bits, func OnesCount64(uint64) int
|
||||
pkg math/bits, func OnesCount8(uint8) int
|
||||
pkg math/bits, func Reverse(uint) uint
|
||||
pkg math/bits, func Reverse16(uint16) uint16
|
||||
pkg math/bits, func Reverse32(uint32) uint32
|
||||
pkg math/bits, func Reverse64(uint64) uint64
|
||||
pkg math/bits, func Reverse8(uint8) uint8
|
||||
pkg math/bits, func ReverseBytes(uint) uint
|
||||
pkg math/bits, func ReverseBytes16(uint16) uint16
|
||||
pkg math/bits, func ReverseBytes32(uint32) uint32
|
||||
pkg math/bits, func ReverseBytes64(uint64) uint64
|
||||
pkg math/bits, func RotateLeft(uint, int) uint
|
||||
pkg math/bits, func RotateLeft16(uint16, int) uint16
|
||||
pkg math/bits, func RotateLeft32(uint32, int) uint32
|
||||
pkg math/bits, func RotateLeft64(uint64, int) uint64
|
||||
pkg math/bits, func RotateLeft8(uint8, int) uint8
|
||||
pkg math/bits, func TrailingZeros(uint) int
|
||||
pkg math/bits, func TrailingZeros16(uint16) int
|
||||
pkg math/bits, func TrailingZeros32(uint32) int
|
||||
pkg math/bits, func TrailingZeros64(uint64) int
|
||||
pkg math/bits, func TrailingZeros8(uint8) int
|
||||
pkg mime, var ErrInvalidMediaParameter error
|
||||
pkg mime/multipart, type FileHeader struct, Size int64
|
||||
pkg mime/multipart, var ErrMessageTooLarge error
|
||||
pkg net, method (*IPConn) SyscallConn() (syscall.RawConn, error)
|
||||
pkg net, method (*TCPConn) SyscallConn() (syscall.RawConn, error)
|
||||
pkg net, method (*UDPConn) SyscallConn() (syscall.RawConn, error)
|
||||
pkg net, method (*UnixConn) SyscallConn() (syscall.RawConn, error)
|
||||
pkg net, type Resolver struct, Dial func(context.Context, string, string) (Conn, error)
|
||||
pkg net, type Resolver struct, StrictErrors bool
|
||||
pkg net/http, func ServeTLS(net.Listener, Handler, string, string) error
|
||||
pkg net/http, method (*Server) RegisterOnShutdown(func())
|
||||
pkg net/http, method (*Server) ServeTLS(net.Listener, string, string) error
|
||||
pkg net/http/fcgi, func ProcessEnv(*http.Request) map[string]string
|
||||
pkg net/http/httptest, method (*Server) Certificate() *x509.Certificate
|
||||
pkg net/http/httptest, method (*Server) Client() *http.Client
|
||||
pkg reflect, func MakeMapWithSize(Type, int) Value
|
||||
pkg runtime/pprof, func Do(context.Context, LabelSet, func(context.Context))
|
||||
pkg runtime/pprof, func ForLabels(context.Context, func(string, string) bool)
|
||||
pkg runtime/pprof, func Label(context.Context, string) (string, bool)
|
||||
pkg runtime/pprof, func Labels(...string) LabelSet
|
||||
pkg runtime/pprof, func SetGoroutineLabels(context.Context)
|
||||
pkg runtime/pprof, func WithLabels(context.Context, LabelSet) context.Context
|
||||
pkg runtime/pprof, type LabelSet struct
|
||||
pkg sync, method (*Map) Delete(interface{})
|
||||
pkg sync, method (*Map) Load(interface{}) (interface{}, bool)
|
||||
pkg sync, method (*Map) LoadOrStore(interface{}, interface{}) (interface{}, bool)
|
||||
pkg sync, method (*Map) Range(func(interface{}, interface{}) bool)
|
||||
pkg sync, method (*Map) Store(interface{}, interface{})
|
||||
pkg sync, type Map struct
|
||||
pkg syscall (darwin-386-cgo), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (darwin-386), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (darwin-amd64-cgo), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (darwin-amd64), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (freebsd-386-cgo), func Pipe2([]int, int) error
|
||||
pkg syscall (freebsd-386-cgo), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (freebsd-386), func Pipe2([]int, int) error
|
||||
pkg syscall (freebsd-386), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (freebsd-amd64-cgo), func Pipe2([]int, int) error
|
||||
pkg syscall (freebsd-amd64-cgo), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (freebsd-amd64), func Pipe2([]int, int) error
|
||||
pkg syscall (freebsd-amd64), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (freebsd-arm-cgo), func Pipe2([]int, int) error
|
||||
pkg syscall (freebsd-arm-cgo), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (freebsd-arm), func Pipe2([]int, int) error
|
||||
pkg syscall (freebsd-arm), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (linux-386-cgo), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (linux-386-cgo), type SysProcAttr struct, AmbientCaps []uintptr
|
||||
pkg syscall (linux-386), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (linux-386), type SysProcAttr struct, AmbientCaps []uintptr
|
||||
pkg syscall (linux-amd64-cgo), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (linux-amd64-cgo), type SysProcAttr struct, AmbientCaps []uintptr
|
||||
pkg syscall (linux-amd64), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (linux-amd64), type SysProcAttr struct, AmbientCaps []uintptr
|
||||
pkg syscall (linux-arm-cgo), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (linux-arm-cgo), type SysProcAttr struct, AmbientCaps []uintptr
|
||||
pkg syscall (linux-arm), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (linux-arm), type SysProcAttr struct, AmbientCaps []uintptr
|
||||
pkg syscall (netbsd-386-cgo), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (netbsd-386), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (netbsd-amd64-cgo), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (netbsd-amd64), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (netbsd-arm-cgo), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (netbsd-arm), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (openbsd-386-cgo), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (openbsd-386), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (openbsd-amd64-cgo), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (openbsd-amd64), type Credential struct, NoSetGroups bool
|
||||
pkg syscall (windows-386), const WSAECONNABORTED = 10053
|
||||
pkg syscall (windows-386), const WSAECONNABORTED Errno
|
||||
pkg syscall (windows-amd64), const WSAECONNABORTED = 10053
|
||||
pkg syscall (windows-amd64), const WSAECONNABORTED Errno
|
||||
pkg syscall, type Conn interface { SyscallConn }
|
||||
pkg syscall, type Conn interface, SyscallConn() (RawConn, error)
|
||||
pkg syscall, type RawConn interface { Control, Read, Write }
|
||||
pkg syscall, type RawConn interface, Control(func(uintptr)) error
|
||||
pkg syscall, type RawConn interface, Read(func(uintptr) bool) error
|
||||
pkg syscall, type RawConn interface, Write(func(uintptr) bool) error
|
||||
pkg testing, method (*B) Helper()
|
||||
pkg testing, method (*T) Helper()
|
||||
pkg testing, type TB interface, Helper()
|
||||
pkg time, method (Duration) Round(Duration) Duration
|
||||
pkg time, method (Duration) Truncate(Duration) Duration
|
||||
@@ -134,7 +134,7 @@ be able to adapt to changing build environments and conditions. For
|
||||
example, if we allowed extra configuration such as compiler flags or
|
||||
command line recipes, then that configuration would need to be updated
|
||||
each time the build tools changed; it would also be inherently tied
|
||||
to the use of a specific toolchain.</p>
|
||||
to the use of a specific tool chain.</p>
|
||||
|
||||
<h2>Getting started with the go command</h2>
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"errors"
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"regexp"
|
||||
)
|
||||
@@ -99,5 +98,5 @@ func main() {
|
||||
http.HandleFunc("/view/", viewHandler)
|
||||
http.HandleFunc("/edit/", editHandler)
|
||||
http.HandleFunc("/save/", saveHandler)
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ package main
|
||||
import (
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -50,5 +49,5 @@ func viewHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func main() {
|
||||
http.HandleFunc("/view/", viewHandler)
|
||||
http.HandleFunc("/edit/", editHandler)
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ package main
|
||||
import (
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"regexp"
|
||||
)
|
||||
@@ -88,5 +87,5 @@ func main() {
|
||||
http.HandleFunc("/view/", makeHandler(viewHandler))
|
||||
http.HandleFunc("/edit/", makeHandler(editHandler))
|
||||
http.HandleFunc("/save/", makeHandler(saveHandler))
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ package main
|
||||
import (
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -62,5 +61,5 @@ func main() {
|
||||
http.HandleFunc("/view/", viewHandler)
|
||||
http.HandleFunc("/edit/", editHandler)
|
||||
http.HandleFunc("/save/", saveHandler)
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
|
||||
@@ -1,27 +1,36 @@
|
||||
--- final.go 2017-08-31 13:19:00.422925489 -0700
|
||||
+++ final-test.go 2017-08-31 13:23:43.381391659 -0700
|
||||
@@ -8,6 +8,7 @@
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
+ "net"
|
||||
"net/http"
|
||||
"regexp"
|
||||
)
|
||||
@@ -86,5 +87,15 @@
|
||||
http.HandleFunc("/edit/", makeHandler(editHandler))
|
||||
http.HandleFunc("/save/", makeHandler(saveHandler))
|
||||
|
||||
- log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
+ l, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
+ if err != nil {
|
||||
+ log.Fatal(err)
|
||||
+ }
|
||||
+ err = ioutil.WriteFile("final-test-port.txt", []byte(l.Addr().String()), 0644)
|
||||
+ if err != nil {
|
||||
+ log.Fatal(err)
|
||||
+ }
|
||||
+ s := &http.Server{}
|
||||
+ s.Serve(l)
|
||||
+ return
|
||||
}
|
||||
*** final.go 2015-06-14 23:59:22.000000000 +0200
|
||||
--- final-test.go 2015-06-15 00:15:41.000000000 +0200
|
||||
***************
|
||||
*** 7,12 ****
|
||||
--- 7,14 ----
|
||||
import (
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
+ "log"
|
||||
+ "net"
|
||||
"net/http"
|
||||
"regexp"
|
||||
)
|
||||
***************
|
||||
*** 85,89 ****
|
||||
http.HandleFunc("/edit/", makeHandler(editHandler))
|
||||
http.HandleFunc("/save/", makeHandler(saveHandler))
|
||||
|
||||
! http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
--- 87,101 ----
|
||||
http.HandleFunc("/edit/", makeHandler(editHandler))
|
||||
http.HandleFunc("/save/", makeHandler(saveHandler))
|
||||
|
||||
! l, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
! if err != nil {
|
||||
! log.Fatal(err)
|
||||
! }
|
||||
! err = ioutil.WriteFile("final-test-port.txt", []byte(l.Addr().String()), 0644)
|
||||
! if err != nil {
|
||||
! log.Fatal(err)
|
||||
! }
|
||||
! s := &http.Server{}
|
||||
! s.Serve(l)
|
||||
! return
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ package main
|
||||
import (
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"regexp"
|
||||
)
|
||||
@@ -86,5 +85,5 @@ func main() {
|
||||
http.HandleFunc("/edit/", makeHandler(editHandler))
|
||||
http.HandleFunc("/save/", makeHandler(saveHandler))
|
||||
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -12,5 +11,5 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handler)
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ You can compile and run the program like this:
|
||||
<pre>
|
||||
$ go build wiki.go
|
||||
$ ./wiki
|
||||
This is a sample Page.
|
||||
This is a sample page.
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -213,12 +213,6 @@ worry about its second parameter, <code>nil</code>, for now.)
|
||||
This function will block until the program is terminated.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<code>ListenAndServe</code> always returns an error, since it only returns when an
|
||||
unexpected error occurs.
|
||||
In order to log that error we wrap the function call with <code>log.Fatal</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The function <code>handler</code> is of the type <code>http.HandlerFunc</code>.
|
||||
It takes an <code>http.ResponseWriter</code> and an <code>http.Request</code> as
|
||||
|
||||
@@ -7,7 +7,6 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -53,5 +52,5 @@ func editHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func main() {
|
||||
http.HandleFunc("/view/", viewHandler)
|
||||
http.HandleFunc("/edit/", editHandler)
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -38,5 +37,5 @@ func viewHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/view/", viewHandler)
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ package main
|
||||
import (
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -70,5 +69,5 @@ func main() {
|
||||
http.HandleFunc("/view/", viewHandler)
|
||||
http.HandleFunc("/edit/", editHandler)
|
||||
http.HandleFunc("/save/", saveHandler)
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ package main
|
||||
import (
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -54,5 +53,5 @@ func main() {
|
||||
http.HandleFunc("/view/", viewHandler)
|
||||
http.HandleFunc("/edit/", editHandler)
|
||||
//http.HandleFunc("/save/", saveHandler)
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ trap cleanup 0 INT
|
||||
rm -f get.bin final-test.bin a.out
|
||||
|
||||
# If called with -all, check that all code snippets compile.
|
||||
if [ "$1" = "-all" ]; then
|
||||
if [ "$1" == "-all" ]; then
|
||||
for fn in *.go; do
|
||||
go build -o a.out $fn
|
||||
done
|
||||
|
||||
10
doc/asm.html
10
doc/asm.html
@@ -29,7 +29,7 @@ Instead, the compiler operates on a kind of semi-abstract instruction set,
|
||||
and instruction selection occurs partly after code generation.
|
||||
The assembler works on the semi-abstract form, so
|
||||
when you see an instruction like <code>MOV</code>
|
||||
what the toolchain actually generates for that operation might
|
||||
what the tool chain actually generates for that operation might
|
||||
not be a move instruction at all, perhaps a clear or load.
|
||||
Or it might correspond exactly to the machine instruction with that name.
|
||||
In general, machine-specific operations tend to appear as themselves, while more general concepts like
|
||||
@@ -139,7 +139,7 @@ The exact set depends on the architecture.
|
||||
<p>
|
||||
There are four predeclared symbols that refer to pseudo-registers.
|
||||
These are not real registers, but rather virtual registers maintained by
|
||||
the toolchain, such as a frame pointer.
|
||||
the tool chain, such as a frame pointer.
|
||||
The set of pseudo-registers is the same for all architectures:
|
||||
</p>
|
||||
|
||||
@@ -876,12 +876,6 @@ Addressing modes:
|
||||
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
The value of <code>GOMIPS</code> environment variable (<code>hardfloat</code> or
|
||||
<code>softfloat</code>) is made available to assembly code by predefining either
|
||||
<code>GOMIPS_hardfloat</code> or <code>GOMIPS_softfloat</code>.
|
||||
</p>
|
||||
|
||||
<h3 id="unsupported_opcodes">Unsupported opcodes</h3>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -22,8 +22,6 @@ using the go <code>tool</code> subcommand, such as <code>go tool vet</code>.
|
||||
This style of invocation allows, for instance, checking a single source file
|
||||
rather than an entire package: <code>go tool vet myprogram.go</code> as
|
||||
compared to <code>go vet mypackage</code>.
|
||||
Some of the commands, such as <code>pprof</code>, are accessible only through
|
||||
the go <code>tool</code> subcommand.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -62,7 +60,7 @@ details.
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><a href="/cmd/cover/">cover</a></td>
|
||||
<td><a href="//godoc.org/golang.org/x/tools/cmd/cover/">cover</a></td>
|
||||
<td> </td>
|
||||
<td>Cover is a program for creating and analyzing the coverage profiles
|
||||
generated by <code>"go test -coverprofile"</code>.</td>
|
||||
|
||||
@@ -124,12 +124,8 @@ workspace. It defaults to a directory named <code>go</code> inside your home dir
|
||||
so <code>$HOME/go</code> on Unix,
|
||||
<code>$home/go</code> on Plan 9,
|
||||
and <code>%USERPROFILE%\go</code> (usually <code>C:\Users\YourName\go</code>) on Windows.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If you would like to work in a different location, you will need to
|
||||
<a href="https://golang.org/wiki/SettingGOPATH">set <code>GOPATH</code></a>
|
||||
to the path to that directory.
|
||||
If you would like to work in a different location, you will need to set
|
||||
<code>GOPATH</code> to the path to that directory.
|
||||
(Another common setup is to set <code>GOPATH=$HOME</code>.)
|
||||
Note that <code>GOPATH</code> must <b>not</b> be the
|
||||
same path as your Go installation.
|
||||
@@ -270,7 +266,7 @@ This command builds the <code>hello</code> command, producing an executable
|
||||
binary. It then installs that binary to the workspace's <code>bin</code>
|
||||
directory as <code>hello</code> (or, under Windows, <code>hello.exe</code>).
|
||||
In our example, that will be <code>$GOPATH/bin/hello</code>, which is
|
||||
<code>$HOME/go/bin/hello</code>.
|
||||
<code>$HOME/work/bin/hello</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -183,6 +183,7 @@ satisfaction of all parties. They are:
|
||||
<li>Aditya Mukerjee <dev@chimeracoder.net>
|
||||
<li>Andrew Gerrand <adg@golang.org>
|
||||
<li>Peggy Li <peggyli.224@gmail.com>
|
||||
<li>Sarah Adams <sadams.codes@gmail.com>
|
||||
<li>Steve Francia <steve.francia@gmail.com>
|
||||
<li>Verónica López <gveronicalg@gmail.com>
|
||||
</ul>
|
||||
|
||||
@@ -34,8 +34,6 @@ We encourage all Go users to subscribe to
|
||||
<p>A <a href="/doc/devel/release.html">summary</a> of the changes between Go releases. Notes for the major releases:</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="/doc/go1.10">Go 1.10</a> <small>(February 2018)</small></li>
|
||||
<li><a href="/doc/go1.9">Go 1.9</a> <small>(August 2017)</small></li>
|
||||
<li><a href="/doc/go1.8">Go 1.8</a> <small>(February 2017)</small></li>
|
||||
<li><a href="/doc/go1.7">Go 1.7</a> <small>(August 2016)</small></li>
|
||||
<li><a href="/doc/go1.6">Go 1.6</a> <small>(February 2016)</small></li>
|
||||
@@ -118,6 +116,6 @@ guidelines</a> for information on design, testing, and our code review process.
|
||||
<p>
|
||||
Check <a href="//golang.org/issue">the tracker</a> for
|
||||
open issues that interest you. Those labeled
|
||||
<a href="https://github.com/golang/go/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22">help wanted</a>
|
||||
<a href="https://github.com/golang/go/issues?q=is%3Aopen+is%3Aissue+label%3Ahelpwanted">helpwanted</a>
|
||||
are particularly in need of outside help.
|
||||
</p>
|
||||
|
||||
@@ -30,25 +30,6 @@ You must go through the following process <em>prior to contributing</em>.
|
||||
You only need to do this once per Google Account.
|
||||
</p>
|
||||
|
||||
<h2 id="go-contrib-init">Automatically set up & diagnose your development environment</h2>
|
||||
<p>
|
||||
The <code>go-contrib-init</code> tool configures and debugs your Go
|
||||
development environment, automatically performing many of the steps
|
||||
on this page, or telling you what you need to do next. If you wish
|
||||
to use it, run:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ go get -u golang.org/x/tools/cmd/go-contrib-init
|
||||
$ cd /code/to/edit
|
||||
$ go-contrib-init
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The tool will either set things up, tell you that everything is
|
||||
configured, or tell you what steps you need to do manually.
|
||||
</p>
|
||||
|
||||
<h2 id="auth">Configure Git to use Gerrit</h2>
|
||||
<p>
|
||||
You'll need a web browser and a command line terminal.
|
||||
@@ -88,7 +69,7 @@ script as *nix.)
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Your secret authentication token is now in a <code>.gitcookies</code> file
|
||||
Your secret authentication token is now in a <code>.gitcookie</code> file
|
||||
and Git is configured to use this file.
|
||||
</p>
|
||||
|
||||
@@ -137,10 +118,10 @@ it does not need to be completed again.</i>
|
||||
You can see your currently signed agreements and sign new ones through the Gerrit
|
||||
interface.
|
||||
To do this, <a href="https://go-review.googlesource.com/login/">Log into Gerrit</a>,
|
||||
then visit the <a href="https://go-review.googlesource.com/settings/agreements">Agreements</a>
|
||||
page.
|
||||
If you do not have a signed agreement listed there, you can create one
|
||||
by clicking "New Contributor Agreement" and following the steps.
|
||||
click your name in the upper-right, choose "Settings", then select "Agreements"
|
||||
from the topics on the left.
|
||||
If you do not have a signed agreement listed here,
|
||||
you can create one by clicking "New Contributor Agreement" and following the steps.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -158,7 +139,7 @@ completed and update the <code>AUTHORS</code> file.
|
||||
Changes to Go must be reviewed before they are accepted, no matter who makes the change.
|
||||
A custom git command called <code>git-codereview</code>, discussed below,
|
||||
helps manage the code review process through a Google-hosted
|
||||
<a href="https://go-review.googlesource.com/">instance</a> of Gerrit.
|
||||
<a href="https://go-review.googlesource.com/">instance</a> Gerrit.
|
||||
</p>
|
||||
|
||||
<h3 id="git-codereview_install">Install the git-codereview command</h3>
|
||||
@@ -187,7 +168,7 @@ prints help text, not an error.
|
||||
On Windows, when using git-bash you must make sure that
|
||||
<code>git-codereview.exe</code> is in your git exec-path.
|
||||
Run <code>git --exec-path</code> to discover the right location then create a
|
||||
symbolic link or simply copy the executable from $GOPATH/bin to this directory.
|
||||
symbolic link or simply copy the executible from $GOPATH/bin to this directory.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -208,6 +189,12 @@ daily work, install the hooks in a new Git checkout by running
|
||||
<code>git-codereview</code> <code>hooks</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The workflow described below assumes a single change per branch.
|
||||
It is also possible to prepare a sequence of (usually related) changes in a single branch.
|
||||
See the <a href="https://golang.org/x/review/git-codereview">git-codereview documentation</a> for details.
|
||||
</p>
|
||||
|
||||
<h3 id="git-config">Set up git aliases</h3>
|
||||
|
||||
<p>
|
||||
@@ -299,15 +286,6 @@ which only bug fixes and doc updates are accepted. New contributions can be
|
||||
sent during a feature freeze but will not be accepted until the freeze thaws.
|
||||
</p>
|
||||
|
||||
<h3 id="scratch">Not sure what change to make?</h3>
|
||||
|
||||
<p>
|
||||
If you want to become familiar with Gerrit and the contribution process,
|
||||
but aren't sure what you'd like to contribute just yet, you can use the <a
|
||||
href="https://go.googlesource.com/scratch">scratch repository</a> to practice
|
||||
making a change.
|
||||
</p>
|
||||
|
||||
<h2 id="making_a_change">Making a change</h2>
|
||||
|
||||
<h3 id="checkout_go">Getting Go Source</h3>
|
||||
@@ -327,10 +305,10 @@ Go to a directory where you want the source to appear and run the following
|
||||
command in a terminal.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
<pre><code>
|
||||
$ git clone https://go.googlesource.com/go
|
||||
$ cd go
|
||||
</pre>
|
||||
</code></pre>
|
||||
|
||||
<h3 id="master">Contributing to the main Go tree</h3>
|
||||
|
||||
@@ -386,7 +364,7 @@ Instead, your name will appear in the
|
||||
<a href="https://golang.org/change">change log</a> and in the <a
|
||||
href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file and perhaps the <a
|
||||
href="/AUTHORS"><code>AUTHORS</code></a> file.
|
||||
These files are automatically generated from the commit logs periodically.
|
||||
These files are automatically generated from the commit logs perodically.
|
||||
The <a href="/AUTHORS"><code>AUTHORS</code></a> file defines who “The Go
|
||||
Authors”—the copyright holders—are.
|
||||
</p>
|
||||
@@ -394,7 +372,7 @@ Authors”—the copyright holders—are.
|
||||
<p>New files that you contribute should use the standard copyright header:</p>
|
||||
|
||||
<pre>
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
</pre>
|
||||
@@ -418,15 +396,8 @@ and
|
||||
|
||||
<p>
|
||||
Once you have the changes queued up, you will want to commit them.
|
||||
In the Go contribution workflow this is done with a <code>git</code>
|
||||
<code>change</code> command, which creates a local branch and commits the changes
|
||||
directly to that local branch.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The workflow described here assumes a single change per branch.
|
||||
It is also possible to prepare a sequence of (usually related) changes in a single branch.
|
||||
See the <a href="https://golang.org/x/review/git-codereview">git-codereview documentation</a> for details.
|
||||
In the Go contribution workflow this is done with a `git change` command,
|
||||
which creates a local branch and commits the changes directly to that local branch.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
@@ -447,9 +418,9 @@ then <code>git</code> <code>commit</code>.)
|
||||
</p>
|
||||
|
||||
<p>
|
||||
As the <code>git</code> <code>commit</code> is the final step, Git will open an
|
||||
editor to ask for a commit message. (It uses the editor named by
|
||||
the <code>$EDITOR</code> environment variable,
|
||||
As the `git commit` is the final step, Git will open an editor to ask for a
|
||||
commit message.
|
||||
(It uses the editor named by the <code>$EDITOR</code> environment variable,
|
||||
<code>vi</code> by default.)
|
||||
|
||||
The file will look like:
|
||||
@@ -505,7 +476,7 @@ Fixes #159
|
||||
|
||||
<p>
|
||||
The commented section of the file lists all the modified files in your client.
|
||||
It is best to keep unrelated changes in different commits,
|
||||
It is best to keep unrelated changes in different change lists,
|
||||
so if you see a file listed that should not be included, abort
|
||||
the command and move that file to a different branch.
|
||||
</p>
|
||||
@@ -600,7 +571,7 @@ changes to Gerrit using <code>git</code> <code>push</code> <code>origin</code>
|
||||
|
||||
<p>
|
||||
If your change relates to an open issue, please add a comment to the issue
|
||||
announcing your proposed fix, including a link to your change.
|
||||
announcing your proposed fix, including a link to your CL.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -665,7 +636,7 @@ $ git mail
|
||||
|
||||
<p>
|
||||
Unless explicitly told otherwise, such as in the discussion leading
|
||||
up to sending in the change, it's better not to specify a reviewer.
|
||||
up to sending in the change list, it's better not to specify a reviewer.
|
||||
All changes are automatically CC'ed to the
|
||||
<a href="https://groups.google.com/group/golang-codereviews">golang-codereviews@googlegroups.com</a>
|
||||
mailing list. If this is your first ever change, there may be a moderation
|
||||
@@ -690,8 +661,8 @@ reviewers asking them to visit the issue's URL and make comments on the change.
|
||||
When done, the reviewer adds comments through the Gerrit user interface
|
||||
and clicks "Reply" to send comments back.
|
||||
You will receive a mail notification when this happens.
|
||||
You may reply through the web interface or
|
||||
<a href="https://gerrit-review.googlesource.com/Documentation/intro-user.html#reply-by-email">via email</a>.
|
||||
You must reply through the web interface.
|
||||
(Unlike with the old Rietveld review system, replying by mail has no effect.)
|
||||
</p>
|
||||
|
||||
<h3 id="revise">Revise and resend</h3>
|
||||
@@ -705,15 +676,15 @@ all the changes and comments made in the single URL.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You may respond to review comments through the web interface or
|
||||
<a href="https://gerrit-review.googlesource.com/Documentation/intro-user.html#reply-by-email">via email</a>.
|
||||
You must respond to review comments through the web interface.
|
||||
(Unlike with the old Rietveld review system, responding by mail has no effect.)
|
||||
</p>
|
||||
|
||||
<p>
|
||||
When you have revised the code and are ready for another round of review,
|
||||
stage those changes and use <code>git</code> <code>change</code> to update the
|
||||
commit.
|
||||
To send the updated change for another round of review,
|
||||
To send the update change list for another round of review,
|
||||
run <code>git</code> <code>mail</code> again.
|
||||
</p>
|
||||
|
||||
|
||||
@@ -3,76 +3,51 @@
|
||||
"Path": "/doc/gdb"
|
||||
}-->
|
||||
|
||||
<!--
|
||||
NOTE: In this document and others in this directory, the convention is to
|
||||
set fixed-width phrases with non-fixed-width spaces, as in
|
||||
<code>hello</code> <code>world</code>.
|
||||
Do not send CLs removing the interior tags from such phrases.
|
||||
-->
|
||||
|
||||
<i>
|
||||
<p>
|
||||
The following instructions apply to the standard toolchain
|
||||
(the <code>gc</code> Go compiler and tools).
|
||||
Gccgo has native gdb support.
|
||||
</p>
|
||||
<p>
|
||||
Note that
|
||||
<a href="https://github.com/derekparker/delve">Delve</a> is a better
|
||||
alternative to GDB when debugging Go programs built with the standard
|
||||
toolchain. It understands the Go runtime, data structures, and
|
||||
expressions better than GDB. Delve currently supports Linux, OSX,
|
||||
and Windows on <code>amd64</code>.
|
||||
For the most up-to-date list of supported platforms, please see
|
||||
<a href="https://github.com/derekparker/delve/tree/master/Documentation/installation">
|
||||
the Delve documentation</a>.
|
||||
</p>
|
||||
</i>
|
||||
<p><i>
|
||||
This applies to the standard toolchain (the <code>gc</code> Go
|
||||
compiler and tools). Gccgo has native gdb support.
|
||||
Besides this overview you might want to consult the
|
||||
<a href="http://sourceware.org/gdb/current/onlinedocs/gdb/">GDB manual</a>.
|
||||
</i></p>
|
||||
|
||||
<p>
|
||||
GDB does not understand Go programs well.
|
||||
The stack management, threading, and runtime contain aspects that differ
|
||||
enough from the execution model GDB expects that they can confuse
|
||||
the debugger and cause incorrect results even when the program is
|
||||
compiled with gccgo.
|
||||
As a consequence, although GDB can be useful in some situations (e.g.,
|
||||
debugging Cgo code, or debugging the runtime itself), it is not
|
||||
a reliable debugger for Go programs, particularly heavily concurrent
|
||||
ones. Moreover, it is not a priority for the Go project to address
|
||||
these issues, which are difficult.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
the debugger, even when the program is compiled with gccgo.
|
||||
As a consequence, although GDB can be useful in some situations, it is
|
||||
not a reliable debugger for Go programs, particularly heavily concurrent ones.
|
||||
Moreover, it is not a priority for the Go project to address these issues, which
|
||||
are difficult.
|
||||
In short, the instructions below should be taken only as a guide to how
|
||||
to use GDB when it works, not as a guarantee of success.
|
||||
|
||||
Besides this overview you might want to consult the
|
||||
<a href="http://sourceware.org/gdb/current/onlinedocs/gdb/">GDB manual</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
In time, a more Go-centric debugging architecture may be required.
|
||||
</p>
|
||||
|
||||
<h2 id="Introduction">Introduction</h2>
|
||||
|
||||
<p>
|
||||
When you compile and link your Go programs with the <code>gc</code> toolchain
|
||||
on Linux, Mac OS X, FreeBSD or NetBSD, the resulting binaries contain DWARFv4
|
||||
debugging information that recent versions (≥7.5) of the GDB debugger can
|
||||
on Linux, Mac OS X, FreeBSD or NetBSD, the resulting binaries contain DWARFv3
|
||||
debugging information that recent versions (>7.1) of the GDB debugger can
|
||||
use to inspect a live process or a core dump.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Pass the <code>'-w'</code> flag to the linker to omit the debug information
|
||||
(for example, <code>go</code> <code>build</code> <code>-ldflags=-w</code> <code>prog.go</code>).
|
||||
(for example, <code>go build -ldflags "-w" prog.go</code>).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The code generated by the <code>gc</code> compiler includes inlining of
|
||||
function invocations and registerization of variables. These optimizations
|
||||
can sometimes make debugging with <code>gdb</code> harder.
|
||||
If you find that you need to disable these optimizations,
|
||||
build your program using <code>go</code> <code>build</code> <code>-gcflags=all="-N -l"</code>.
|
||||
can sometimes make debugging with <code>gdb</code> harder. To disable them
|
||||
when debugging, pass the flags <code>-gcflags "-N -l"</code> to the
|
||||
<a href="/cmd/go"><code>go</code></a> command used to build the code being
|
||||
debugged.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -119,7 +94,7 @@ Show the name, type and location of global variables:
|
||||
|
||||
<p>
|
||||
A recent extension mechanism to GDB allows it to load extension scripts for a
|
||||
given binary. The toolchain uses this to extend GDB with a handful of
|
||||
given binary. The tool chain uses this to extend GDB with a handful of
|
||||
commands to inspect internals of the runtime code (such as goroutines) and to
|
||||
pretty print the built-in map, slice and channel types.
|
||||
</p>
|
||||
@@ -164,7 +139,7 @@ the DWARF code.
|
||||
|
||||
<p>
|
||||
If you're interested in what the debugging information looks like, run
|
||||
<code>objdump</code> <code>-W</code> <code>a.out</code> and browse through the <code>.debug_*</code>
|
||||
'<code>objdump -W a.out</code>' and browse through the <code>.debug_*</code>
|
||||
sections.
|
||||
</p>
|
||||
|
||||
@@ -187,7 +162,7 @@ the form <code>pkg.(*MyType).Meth</code>.
|
||||
<p>
|
||||
In this tutorial we will inspect the binary of the
|
||||
<a href="/pkg/regexp/">regexp</a> package's unit tests. To build the binary,
|
||||
change to <code>$GOROOT/src/regexp</code> and run <code>go</code> <code>test</code> <code>-c</code>.
|
||||
change to <code>$GOROOT/src/regexp</code> and run <code>go test -c</code>.
|
||||
This should produce an executable file named <code>regexp.test</code>.
|
||||
</p>
|
||||
|
||||
@@ -213,7 +188,7 @@ Loading Go Runtime support.
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The message "Loading Go Runtime support" means that GDB loaded the
|
||||
The message <code>"Loading Go Runtime support"</code> means that GDB loaded the
|
||||
extension from <code>$GOROOT/src/runtime/runtime-gdb.py</code>.
|
||||
</p>
|
||||
|
||||
@@ -378,7 +353,7 @@ Stack level 0, frame at 0x7ffff7f9ff88:
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The command <code>info</code> <code>locals</code> lists all variables local to the function and their values, but is a bit
|
||||
The command <code>info locals</code> lists all variables local to the function and their values, but is a bit
|
||||
dangerous to use, since it will also try to print uninitialized variables. Uninitialized slices may cause gdb to try
|
||||
to print arbitrary large arrays.
|
||||
</p>
|
||||
@@ -411,7 +386,7 @@ $3 = struct hchan<*testing.T>
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
That <code>struct</code> <code>hchan<*testing.T></code> is the
|
||||
That <code>struct hchan<*testing.T></code> is the
|
||||
runtime-internal representation of a channel. It is currently empty,
|
||||
or gdb would have pretty-printed its contents.
|
||||
</p>
|
||||
|
||||
@@ -15,52 +15,19 @@ git checkout <i>release-branch</i>
|
||||
<h2 id="policy">Release Policy</h2>
|
||||
|
||||
<p>
|
||||
Each major Go release is supported until there are two newer major releases.
|
||||
For example, Go 1.8 is supported until Go 1.10 is released,
|
||||
and Go 1.9 is supported until Go 1.11 is released.
|
||||
We fix critical problems, including <a href="/security">critical security problems</a>,
|
||||
in supported releases as needed by issuing minor revisions
|
||||
(for example, Go 1.9.1, Go 1.9.2, and so on).
|
||||
</p>
|
||||
|
||||
<h2 id="go1.9">go1.9 (released 2017/08/24)</h2>
|
||||
|
||||
<p>
|
||||
Go 1.9 is a major release of Go.
|
||||
Read the <a href="/doc/go1.9">Go 1.9 Release Notes</a> for more information.
|
||||
</p>
|
||||
|
||||
<h3 id="go1.9.minor">Minor revisions</h3>
|
||||
|
||||
<p>
|
||||
go1.9.1 (released 2017/10/04) includes two security fixes.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.9.1">Go
|
||||
1.9.1 milestone</a> on our issue tracker for details.
|
||||
Each major Go release obsoletes and ends support for the previous one.
|
||||
For example, if Go 1.5 has been released, then it is the current release
|
||||
and Go 1.4 and earlier are no longer supported.
|
||||
We fix critical problems in the current release as needed by issuing minor revisions
|
||||
(for example, Go 1.5.1, Go 1.5.2, and so on).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.9.2 (released 2017/10/25) includes fixes to the compiler, linker, runtime,
|
||||
documentation, <code>go</code> command,
|
||||
and the <code>crypto/x509</code>, <code>database/sql</code>, <code>log</code>,
|
||||
and <code>net/smtp</code> packages.
|
||||
It includes a fix to a bug introduced in Go 1.9.1 that broke <code>go</code> <code>get</code>
|
||||
of non-Git repositories under certain conditions.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.9.2">Go
|
||||
1.9.2 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.9.3 (released 2018/01/22) includes fixes to the compiler, runtime,
|
||||
and the <code>database/sql</code>, <code>math/big</code>, <code>net/http</code>,
|
||||
and <code>net/url</code> packages.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.9.3">Go
|
||||
1.9.3 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.9.4 (released 2018/02/07) includes a security fix to “go get”.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.9.4">Go
|
||||
1.9.4</a> milestone on our issue tracker for details.
|
||||
As a special case, we issue minor revisions for critical security problems
|
||||
in both the current release and the previous release.
|
||||
For example, if Go 1.5 is the current release then we will issue minor revisions
|
||||
to fix critical security problems in both Go 1.4 and Go 1.5 as they arise.
|
||||
See the <a href="/security">security policy</a> for more details.
|
||||
</p>
|
||||
|
||||
<h2 id="go1.8">go1.8 (released 2017/02/16)</h2>
|
||||
@@ -96,37 +63,6 @@ See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.8.3">Go
|
||||
1.8.3 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.8.4 (released 2017/10/04) includes two security fixes.
|
||||
It contains the same fixes as Go 1.9.1 and was released at the same time.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.8.4">Go
|
||||
1.8.4 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.8.5 (released 2017/10/25) includes fixes to the compiler, linker, runtime,
|
||||
documentation, <code>go</code> command,
|
||||
and the <code>crypto/x509</code> and <code>net/smtp</code> packages.
|
||||
It includes a fix to a bug introduced in Go 1.8.4 that broke <code>go</code> <code>get</code>
|
||||
of non-Git repositories under certain conditions.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.8.5">Go
|
||||
1.8.5 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.8.6 (released 2018/01/22) includes the the same fix in <code>math/big</code>
|
||||
as Go 1.9.3 and was released at the same time.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.8.6">Go
|
||||
1.8.6 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.8.7 (released 2018/02/07) includes a security fix to “go get”.
|
||||
It contains the same fix as Go 1.9.4 and was released at the same time.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.8.7">Go
|
||||
1.8.7</a> milestone on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<h2 id="go1.7">go1.7 (released 2016/08/15)</h2>
|
||||
|
||||
<p>
|
||||
@@ -300,7 +236,7 @@ See the <a href="https://github.com/golang/go/commits/go1.3.2">change history</a
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.3.3 (released 2014/09/30) includes further bug fixes to cgo, the runtime package, and the nacl port.
|
||||
go1.3.3 (released 2014/09/30) includes further bug fixes to cgo, the runtime package, and the nacl port.
|
||||
See the <a href="https://github.com/golang/go/commits/go1.3.3">change history</a> for details.
|
||||
</p>
|
||||
|
||||
@@ -364,7 +300,7 @@ about the future of Go 1.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The go1 release corresponds to
|
||||
The go1 release corresponds to
|
||||
<code><a href="weekly.html#2012-03-27">weekly.2012-03-27</a></code>.
|
||||
</p>
|
||||
|
||||
@@ -380,7 +316,7 @@ It also includes several minor code and documentation fixes.
|
||||
|
||||
<p>
|
||||
go1.0.2 (released 2012/06/13) was issued to fix two bugs in the implementation
|
||||
of maps using struct or array keys:
|
||||
of maps using struct or array keys:
|
||||
<a href="//golang.org/issue/3695">issue 3695</a> and
|
||||
<a href="//golang.org/issue/3573">issue 3573</a>.
|
||||
It also includes many minor code and documentation fixes.
|
||||
|
||||
@@ -1,458 +0,0 @@
|
||||
<!--{
|
||||
"Title": "Diagnostics",
|
||||
"Template": true
|
||||
}-->
|
||||
|
||||
<!--
|
||||
NOTE: In this document and others in this directory, the convention is to
|
||||
set fixed-width phrases with non-fixed-width spaces, as in
|
||||
<code>hello</code> <code>world</code>.
|
||||
Do not send CLs removing the interior tags from such phrases.
|
||||
-->
|
||||
|
||||
<h2 id="introduction">Introduction</h2>
|
||||
|
||||
<p>
|
||||
The Go ecosystem provides a large suite of APIs and tools to
|
||||
diagnose logic and performance problems in Go programs. This page
|
||||
summarizes the available tools and helps Go users pick the right one
|
||||
for their specific problem.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Diagnostics solutions can be categorized into the following groups:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li><strong>Profiling</strong>: Profiling tools analyze the complexity and costs of a
|
||||
Go program such as its memory usage and frequently called
|
||||
functions to identify the expensive sections of a Go program.</li>
|
||||
<li><strong>Tracing</strong>: Tracing is a way to instrument code to analyze latency
|
||||
throughout the lifecycle of a call or user request. Traces provide an
|
||||
overview of how much latency each component contributes to the overall
|
||||
latency in a system. Traces can span multiple Go processes.</li>
|
||||
<li><strong>Debugging</strong>: Debugging allows us to pause a Go program and examine
|
||||
its execution. Program state and flow can be verified with debugging.</li>
|
||||
<li><strong>Runtime statistics and events</strong>: Collection and analysis of runtime stats and events
|
||||
provides a high-level overview of the health of Go programs. Spikes/dips of metrics
|
||||
helps us to identify changes in throughput, utilization, and performance.</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
Note: Some diagnostics tools may interfere with each other. For example, precise
|
||||
memory profiling skews CPU profiles and goroutine blocking profiling affects scheduler
|
||||
trace. Use tools in isolation to get more precise info.
|
||||
</p>
|
||||
|
||||
<h2 id="profiling">Profiling</h2>
|
||||
|
||||
<p>
|
||||
Profiling is useful for identifying expensive or frequently called sections
|
||||
of code. The Go runtime provides <a href="https://golang.org/pkg/runtime/pprof/">
|
||||
profiling data</a> in the format expected by the
|
||||
<a href="https://github.com/google/pprof/blob/master/doc/pprof.md">pprof visualization tool</a>.
|
||||
The profiling data can be collected during testing
|
||||
via <code>go</code> <code>test</code> or endpoints made available from the <a href="/pkg/net/http/pprof/">
|
||||
net/http/pprof</a> package. Users need to collect the profiling data and use pprof tools to filter
|
||||
and visualize the top code paths.
|
||||
</p>
|
||||
|
||||
<p>Predefined profiles provided by the <a href="/pkg/runtime/pprof">runtime/pprof</a> package:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<strong>cpu</strong>: CPU profile determines where a program spends
|
||||
its time while actively consuming CPU cycles (as opposed to while sleeping or waiting for I/O).
|
||||
</li>
|
||||
<li>
|
||||
<strong>heap</strong>: Heap profile reports memory allocation samples;
|
||||
used to monitor current and historical memory usage, and to check for memory leaks.
|
||||
</li>
|
||||
<li>
|
||||
<strong>threadcreate</strong>: Thread creation profile reports the sections
|
||||
of the program that lead the creation of new OS threads.
|
||||
</li>
|
||||
<li>
|
||||
<strong>goroutine</strong>: Goroutine profile reports the stack traces of all current goroutines.
|
||||
</li>
|
||||
<li>
|
||||
<strong>block</strong>: Block profile shows where goroutines block waiting on synchronization
|
||||
primitives (including timer channels). Block profile is not enabled by default;
|
||||
use <code>runtime.SetBlockProfileRate</code> to enable it.
|
||||
</li>
|
||||
<li>
|
||||
<strong>mutex</strong>: Mutex profile reports the lock contentions. When you think your
|
||||
CPU is not fully utilized due to a mutex contention, use this profile. Mutex profile
|
||||
is not enabled by default, see <code>runtime.SetMutexProfileFraction</code> to enable it.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p><strong>What other profilers can I use to profile Go programs?</strong></p>
|
||||
|
||||
<p>
|
||||
On Linux, <a href="https://perf.wiki.kernel.org/index.php/Tutorial">perf tools</a>
|
||||
can be used for profiling Go programs. Perf can profile
|
||||
and unwind cgo/SWIG code and kernel, so it can be useful to get insights into
|
||||
native/kernel performance bottlenecks. On macOS,
|
||||
<a href="https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/">Instruments</a>
|
||||
suite can be used profile Go programs.
|
||||
</p>
|
||||
|
||||
<p><strong>Can I profile my production services?</strong></p>
|
||||
|
||||
<p>Yes. It is safe to profile programs in production, but enabling
|
||||
some profiles (e.g. the CPU profile) adds cost. You should expect to
|
||||
see performance downgrade. The performance penalty can be estimated
|
||||
by measuring the overhead of the profiler before turning it on in
|
||||
production.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You may want to periodically profile your production services.
|
||||
Especially in a system with many replicas of a single process, selecting
|
||||
a random replica periodically is a safe option.
|
||||
Select a production process, profile it for
|
||||
X seconds for every Y seconds and save the results for visualization and
|
||||
analysis; then repeat periodically. Results may be manually and/or automatically
|
||||
reviewed to find problems.
|
||||
Collection of profiles can interfere with each other,
|
||||
so it is recommended to collect only a single profile at a time.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>What are the best ways to visualize the profiling data?</strong>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The Go tools provide text, graph, and <a href="http://valgrind.org/docs/manual/cl-manual.html">callgrind</a>
|
||||
visualization of the profile data using
|
||||
<code><a href="https://github.com/google/pprof/blob/master/doc/pprof.md">go tool pprof</a></code>.
|
||||
Read <a href="https://blog.golang.org/profiling-go-programs">Profiling Go programs</a>
|
||||
to see them in action.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<img width="800" src="https://storage.googleapis.com/golangorg-assets/pprof-text.png">
|
||||
<br>
|
||||
<small>Listing of the most expensive calls as text.</small>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<img width="800" src="https://storage.googleapis.com/golangorg-assets/pprof-dot.png">
|
||||
<br>
|
||||
<small>Visualization of the most expensive calls as a graph.</small>
|
||||
</p>
|
||||
|
||||
<p>Weblist view displays the expensive parts of the source line by line in
|
||||
an HTML page. In the following example, 530ms is spent in the
|
||||
<code>runtime.concatstrings</code> and cost of each line is presented
|
||||
in the listing.</p>
|
||||
|
||||
<p>
|
||||
<img width="800" src="https://storage.googleapis.com/golangorg-assets/pprof-weblist.png">
|
||||
<br>
|
||||
<small>Visualization of the most expensive calls as weblist.</small>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Another way to visualize profile data is a <a href="http://www.brendangregg.com/flamegraphs.html">flame graph</a>.
|
||||
Flame graphs allow you to move in a specific ancestry path, so you can zoom
|
||||
in/out of specific sections of code.
|
||||
The <a href="https://github.com/google/pprof">upstream pprof</a>
|
||||
has support for flame graphs.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<img width="800" src="https://storage.googleapis.com/golangorg-assets/flame.png">
|
||||
<br>
|
||||
<small>Flame graphs offers visualization to spot the most expensive code-paths.</small>
|
||||
</p>
|
||||
|
||||
<p><strong>Am I restricted to the built-in profiles?</strong></p>
|
||||
|
||||
<p>
|
||||
Additionally to what is provided by the runtime, Go users can create
|
||||
their custom profiles via <a href="/pkg/runtime/pprof/#Profile">pprof.Profile</a>
|
||||
and use the existing tools to examine them.
|
||||
</p>
|
||||
|
||||
<p><strong>Can I serve the profiler handlers (/debug/pprof/...) on a different path and port?</strong></p>
|
||||
|
||||
<p>
|
||||
Yes. The <code>net/http/pprof</code> package registers its handlers to the default
|
||||
mux by default, but you can also register them yourself by using the handlers
|
||||
exported from the package.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For example, the following example will serve the pprof.Profile
|
||||
handler on :7777 at /custom_debug_path/profile:
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
)
|
||||
|
||||
func main() {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/custom_debug_path/profile", pprof.Profile)
|
||||
log.Fatal(http.ListenAndServe(":7777", mux))
|
||||
}
|
||||
</pre>
|
||||
</p>
|
||||
|
||||
<h2 id="tracing">Tracing</h2>
|
||||
|
||||
<p>
|
||||
Tracing is a way to instrument code to analyze latency throughout the
|
||||
lifecycle of a chain of calls. Go provides
|
||||
<a href="https://godoc.org/golang.org/x/net/trace">golang.org/x/net/trace</a>
|
||||
package as a minimal tracing backend per Go node and provides a minimal
|
||||
instrumentation library with a simple dashboard. Go also provides
|
||||
an execution tracer to trace the runtime events within an interval.
|
||||
</p>
|
||||
|
||||
<p>Tracing enables us to:</p>
|
||||
|
||||
<ul>
|
||||
<li>Instrument and analyze application latency in a Go process.</li>
|
||||
<li>Measure the cost of specific calls in a long chain of calls.</li>
|
||||
<li>Figure out the utilization and performance improvements.
|
||||
Bottlenecks are not always obvious without tracing data.</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
In monolithic systems, it's relatively easy to collect diagnostic data
|
||||
from the building blocks of a program. All modules live within one
|
||||
process and share common resources to report logs, errors, and other
|
||||
diagnostic information. Once your system grows beyond a single process and
|
||||
starts to become distributed, it becomes harder to follow a call starting
|
||||
from the front-end web server to all of its back-ends until a response is
|
||||
returned back to the user. This is where distributed tracing plays a big
|
||||
role to instrument and analyze your production systems.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Distributed tracing is a way to instrument code to analyze latency throughout
|
||||
the lifecycle of a user request. When a system is distributed and when
|
||||
conventional profiling and debugging tools don’t scale, you might want
|
||||
to use distributed tracing tools to analyze the performance of your user
|
||||
requests and RPCs.
|
||||
</p>
|
||||
|
||||
<p>Distributed tracing enables us to:</p>
|
||||
|
||||
<ul>
|
||||
<li>Instrument and profile application latency in a large system.</li>
|
||||
<li>Track all RPCs within the lifecycle of a user request and see integration issues
|
||||
that are only visible in production.</li>
|
||||
<li>Figure out performance improvements that can be applied to our systems.
|
||||
Many bottlenecks are not obvious before the collection of tracing data.</li>
|
||||
</ul>
|
||||
|
||||
<p>The Go ecosystem provides various distributed tracing libraries per tracing system
|
||||
and backend-agnostic ones.</p>
|
||||
|
||||
|
||||
<p><strong>Is there a way to automatically intercept each function call and create traces?</strong></p>
|
||||
|
||||
<p>
|
||||
Go doesn’t provide a way to automatically intercept every function call and create
|
||||
trace spans. You need to manually instrument your code to create, end, and annotate spans.
|
||||
</p>
|
||||
|
||||
<p><strong>How should I propagate trace headers in Go libraries?</strong></p>
|
||||
|
||||
<p>
|
||||
You can propagate trace identifiers and tags in the
|
||||
<a href="/pkg/context#Context"><code>context.Context</code></a>.
|
||||
There is no canonical trace key or common representation of trace headers
|
||||
in the industry yet. Each tracing provider is responsible for providing propagation
|
||||
utilities in their Go libraries.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>What other low-level events from the standard library or
|
||||
runtime can be included in a trace?</strong>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The standard library and runtime are trying to expose several additional APIs
|
||||
to notify on low level internal events. For example,
|
||||
<a href="/pkg/net/http/httptrace#ClientTrace"><code>httptrace.ClientTrace</code></a>
|
||||
provides APIs to follow low-level events in the life cycle of an outgoing request.
|
||||
There is an ongoing effort to retrieve low-level runtime events from
|
||||
the runtime execution tracer and allow users to define and record their user events.
|
||||
</p>
|
||||
|
||||
<h2 id="debugging">Debugging</h2>
|
||||
|
||||
<p>
|
||||
Debugging is the process of identifying why a program misbehaves.
|
||||
Debuggers allow us to understand a program’s execution flow and current state.
|
||||
There are several styles of debugging; this section will only focus on attaching
|
||||
a debugger to a program and core dump debugging.
|
||||
</p>
|
||||
|
||||
<p>Go users mostly use the following debuggers:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://github.com/derekparker/delve">Delve</a>:
|
||||
Delve is a debugger for the Go programming language. It has
|
||||
support for Go’s runtime concepts and built-in types. Delve is
|
||||
trying to be a fully featured reliable debugger for Go programs.
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://golang.org/doc/gdb">GDB</a>:
|
||||
Go provides GDB support via the standard Go compiler and Gccgo.
|
||||
The stack management, threading, and runtime contain aspects that differ
|
||||
enough from the execution model GDB expects that they can confuse the
|
||||
debugger, even when the program is compiled with gccgo. Even though
|
||||
GDB can be used to debug Go programs, it is not ideal and may
|
||||
create confusion.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p><strong>How well do debuggers work with Go programs?</strong></p>
|
||||
|
||||
<p>
|
||||
The <code>gc</code> compiler performs optimizations such as
|
||||
function inlining and variable registerization. These optimizations
|
||||
sometimes make debugging with debuggers harder. There is an ongoing
|
||||
effort to improve the quality of the DWARF information generated for
|
||||
optimized binaries. Until those improvements are available, we recommend
|
||||
disabling optimizations when building the code being debugged. The following
|
||||
command builds a package with no compiler optimizations:
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
$ go build -gcflags=all="-N -l"
|
||||
</pre>
|
||||
</p>
|
||||
|
||||
As part of the improvement effort, Go 1.10 introduced a new compiler
|
||||
flag <code>-dwarflocationlists</code>. The flag causes the compiler to
|
||||
add location lists that helps debuggers work with optimized binaries.
|
||||
The following command builds a package with optimizations but with
|
||||
the DWARF location lists:
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
$ go build -gcflags="-dwarflocationlists=true"
|
||||
</pre>
|
||||
</p>
|
||||
|
||||
<p><strong>What’s the recommended debugger user interface?</strong></p>
|
||||
|
||||
<p>
|
||||
Even though both delve and gdb provides CLIs, most editor integrations
|
||||
and IDEs provides debugging-specific user interfaces.
|
||||
</p>
|
||||
|
||||
<p><strong>Is it possible to do postmortem debugging with Go programs?</strong></p>
|
||||
|
||||
<p>
|
||||
A core dump file is a file that contains the memory dump of a running
|
||||
process and its process status. It is primarily used for post-mortem
|
||||
debugging of a program and to understand its state
|
||||
while it is still running. These two cases make debugging of core
|
||||
dumps a good diagnostic aid to postmortem and analyze production
|
||||
services. It is possible to obtain core files from Go programs and
|
||||
use delve or gdb to debug, see the
|
||||
<a href="https://golang.org/wiki/CoreDumpDebugging">core dump debugging</a>
|
||||
page for a step-by-step guide.
|
||||
</p>
|
||||
|
||||
<h2 id="runtime">Runtime statistics and events</h2>
|
||||
|
||||
<p>
|
||||
The runtime provides stats and reporting of internal events for
|
||||
users to diagnose performance and utilization problems at the
|
||||
runtime level.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Users can monitor these stats to better understand the overall
|
||||
health and performance of Go programs.
|
||||
Some frequently monitored stats and states:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li><code><a href="/pkg/runtime/#ReadMemStats">runtime.ReadMemStats</a></code>
|
||||
reports the metrics related to heap
|
||||
allocation and garbage collection. Memory stats are useful for
|
||||
monitoring how much memory resources a process is consuming,
|
||||
whether the process can utilize memory well, and to catch
|
||||
memory leaks.</li>
|
||||
<li><code><a href="/pkg/runtime/debug/#ReadGCStats">debug.ReadGCStats</a></code>
|
||||
reads statistics about garbage collection.
|
||||
It is useful to see how much of the resources are spent on GC pauses.
|
||||
It also reports a timeline of garbage collector pauses and pause time percentiles.</li>
|
||||
<li><code><a href="/pkg/runtime/debug/#Stack">debug.Stack</a></code>
|
||||
returns the current stack trace. Stack trace
|
||||
is useful to see how many goroutines are currently running,
|
||||
what they are doing, and whether they are blocked or not.</li>
|
||||
<li><code><a href="/pkg/runtime/debug/#WriteHeapDump">debug.WriteHeapDump</a></code>
|
||||
suspends the execution of all goroutines
|
||||
and allows you to dump the heap to a file. A heap dump is a
|
||||
snapshot of a Go process' memory at a given time. It contains all
|
||||
allocated objects as well as goroutines, finalizers, and more.</li>
|
||||
<li><code><a href="/pkg/runtime#NumGoroutine">runtime.NumGoroutine</a></code>
|
||||
returns the number of current goroutines.
|
||||
The value can be monitored to see whether enough goroutines are
|
||||
utilized, or to detect goroutine leaks.</li>
|
||||
</ul>
|
||||
|
||||
<h3 id="execution-tracer">Execution tracer</h3>
|
||||
|
||||
<p>Go comes with a runtime execution tracer to capture a wide range
|
||||
of runtime events. Scheduling, syscall, garbage collections,
|
||||
heap size, and other events are collected by runtime and available
|
||||
for visualization by the go tool trace. Execution tracer is a tool
|
||||
to detect latency and utilization problems. You can examine how well
|
||||
the CPU is utilized, and when networking or syscalls are a cause of
|
||||
preemption for the goroutines.</p>
|
||||
|
||||
<p>Tracer is useful to:</p>
|
||||
<ul>
|
||||
<li>Understand how your goroutines execute.</li>
|
||||
<li>Understand some of the core runtime events such as GC runs.</li>
|
||||
<li>Identify poorly parallelized execution.</li>
|
||||
</ul>
|
||||
|
||||
<p>However, it is not great for identifying hot spots such as
|
||||
analyzing the cause of excessive memory or CPU usage.
|
||||
Use profiling tools instead first to address them.</p>
|
||||
|
||||
<p>
|
||||
<img width="800" src="https://storage.googleapis.com/golangorg-assets/tracer-lock.png">
|
||||
</p>
|
||||
|
||||
<p>Above, the go tool trace visualization shows the execution started
|
||||
fine, and then it became serialized. It suggests that there might
|
||||
be lock contention for a shared resource that creates a bottleneck.</p>
|
||||
|
||||
<p>See <a href="https://golang.org/cmd/trace/"><code>go</code> <code>tool</code> <code>trace</code></a>
|
||||
to collect and analyze runtime traces.
|
||||
</p>
|
||||
|
||||
<h3 id="godebug">GODEBUG</h3>
|
||||
|
||||
<p>Runtime also emits events and information if
|
||||
<a href="https://golang.org/pkg/runtime/#hdr-Environment_Variables">GODEBUG</a>
|
||||
environmental variable is set accordingly.</p>
|
||||
|
||||
<ul>
|
||||
<li>GODEBUG=gctrace=1 prints garbage collector events at
|
||||
each collection, summarizing the amount of memory collected
|
||||
and the length of the pause.</li>
|
||||
<li>GODEBUG=schedtrace=X prints scheduling events every X milliseconds.</li>
|
||||
</ul>
|
||||
@@ -1,7 +1,6 @@
|
||||
<!--{
|
||||
"Title": "Documentation",
|
||||
"Path": "/doc/",
|
||||
"Template": true
|
||||
"Path": "/doc/"
|
||||
}-->
|
||||
|
||||
<p>
|
||||
@@ -34,43 +33,28 @@ libraries.
|
||||
|
||||
<img class="gopher" src="/doc/gopher/doc.png"/>
|
||||
|
||||
<h3 id="go_tour">
|
||||
{{if $.GoogleCN}}
|
||||
A Tour of Go
|
||||
{{else}}
|
||||
<a href="//tour.golang.org/">A Tour of Go</a>
|
||||
{{end}}
|
||||
</h3>
|
||||
<h3 id="go_tour"><a href="//tour.golang.org/">A Tour of Go</a></h3>
|
||||
<p>
|
||||
An interactive introduction to Go in three sections.
|
||||
The first section covers basic syntax and data structures; the second discusses
|
||||
methods and interfaces; and the third introduces Go's concurrency primitives.
|
||||
Each section concludes with a few exercises so you can practice what you've
|
||||
learned. You can {{if not $.GoogleCN}}<a href="//tour.golang.org/">take the tour
|
||||
online</a> or{{end}} install it locally with:
|
||||
learned. You can <a href="//tour.golang.org/">take the tour online</a> or
|
||||
install it locally with:
|
||||
</p>
|
||||
<p>
|
||||
<pre>
|
||||
$ go get golang.org/x/tour/gotour
|
||||
</pre>
|
||||
<p>
|
||||
This will place the <code>gotour</code> binary in your workspace's <code>bin</code> directory.
|
||||
</p>
|
||||
|
||||
<h3 id="code"><a href="code.html">How to write Go code</a></h3>
|
||||
<p>
|
||||
{{if not $.GoogleCN}}
|
||||
Also available as a <a href="//www.youtube.com/watch?v=XCsL89YtqCs">screencast</a>, this
|
||||
{{else}}
|
||||
This
|
||||
{{end}}
|
||||
doc explains how to use the <a href="/cmd/go/">go command</a>
|
||||
to fetch, build, and install packages, commands, and run tests.
|
||||
</p>
|
||||
|
||||
<h3 id="editors"><a href="editors.html">Editor plugins and IDEs</a></h3>
|
||||
<p>
|
||||
A document that summarizes commonly used editor plugins and IDEs with
|
||||
Go support.
|
||||
Also available as a
|
||||
<a href="//www.youtube.com/watch?v=XCsL89YtqCs">screencast</a>, this doc
|
||||
explains how to use the <a href="/cmd/go/">go command</a> to fetch, build, and
|
||||
install packages, commands, and run tests.
|
||||
</p>
|
||||
|
||||
<h3 id="effective_go"><a href="effective_go.html">Effective Go</a></h3>
|
||||
@@ -80,11 +64,6 @@ A must read for any new Go programmer. It augments the tour and
|
||||
the language specification, both of which should be read first.
|
||||
</p>
|
||||
|
||||
<h3 id="diagnostics"><a href="/doc/diagnostics.html">Diagnostics</a></h3>
|
||||
<p>
|
||||
Summarizes tools and methodologies to diagnose problems in Go programs.
|
||||
</p>
|
||||
|
||||
<h3 id="faq"><a href="/doc/faq">Frequently Asked Questions (FAQ)</a></h3>
|
||||
<p>
|
||||
Answers to common questions about Go.
|
||||
@@ -130,11 +109,9 @@ same variable in a different goroutine.
|
||||
|
||||
<h2 id="articles">Articles</h2>
|
||||
|
||||
{{if not $.GoogleCN}}
|
||||
<h3 id="blog"><a href="//blog.golang.org/">The Go Blog</a></h3>
|
||||
<p>The official blog of the Go project, featuring news and in-depth articles by
|
||||
the Go team and guests.</p>
|
||||
{{end}}
|
||||
|
||||
<h4>Codewalks</h4>
|
||||
<p>
|
||||
@@ -147,7 +124,6 @@ Guided tours of Go programs.
|
||||
<li><a href="/doc/articles/wiki/">Writing Web Applications</a> - building a simple web application.</li>
|
||||
</ul>
|
||||
|
||||
{{if not $.GoogleCN}}
|
||||
<h4>Language</h4>
|
||||
<ul>
|
||||
<li><a href="/blog/json-rpc-tale-of-interfaces">JSON-RPC: a tale of interfaces</a></li>
|
||||
@@ -168,20 +144,17 @@ Guided tours of Go programs.
|
||||
<li><a href="/blog/go-image-package">The Go image package</a> - the fundamentals of the <a href="/pkg/image/">image</a> package.</li>
|
||||
<li><a href="/blog/go-imagedraw-package">The Go image/draw package</a> - the fundamentals of the <a href="/pkg/image/draw/">image/draw</a> package.</li>
|
||||
</ul>
|
||||
{{end}}
|
||||
|
||||
<h4>Tools</h4>
|
||||
<ul>
|
||||
<li><a href="/doc/articles/go_command.html">About the Go command</a> - why we wrote it, what it is, what it's not, and how to use it.</li>
|
||||
<li><a href="/doc/gdb">Debugging Go Code with GDB</a></li>
|
||||
<li><a href="/doc/articles/race_detector.html">Data Race Detector</a> - a manual for the data race detector.</li>
|
||||
<li><a href="/doc/asm">A Quick Guide to Go's Assembler</a> - an introduction to the assembler used by Go.</li>
|
||||
{{if not $.GoogleCN}}
|
||||
<li><a href="/blog/c-go-cgo">C? Go? Cgo!</a> - linking against C code with <a href="/cmd/cgo/">cgo</a>.</li>
|
||||
<li><a href="/doc/gdb">Debugging Go Code with GDB</a></li>
|
||||
<li><a href="/blog/godoc-documenting-go-code">Godoc: documenting Go code</a> - writing good documentation for <a href="/cmd/godoc/">godoc</a>.</li>
|
||||
<li><a href="/blog/profiling-go-programs">Profiling Go Programs</a></li>
|
||||
<li><a href="/doc/articles/race_detector.html">Data Race Detector</a> - a manual for the data race detector.</li>
|
||||
<li><a href="/blog/race-detector">Introducing the Go Race Detector</a> - an introduction to the race detector.</li>
|
||||
{{end}}
|
||||
<li><a href="/doc/asm">A Quick Guide to Go's Assembler</a> - an introduction to the assembler used by Go.</li>
|
||||
</ul>
|
||||
|
||||
<h4 id="articles_more">More</h4>
|
||||
@@ -190,7 +163,7 @@ See the <a href="/wiki/Articles">Articles page</a> at the
|
||||
<a href="/wiki">Wiki</a> for more Go articles.
|
||||
</p>
|
||||
|
||||
{{if not $.GoogleCN}}
|
||||
|
||||
<h2 id="talks">Talks</h2>
|
||||
|
||||
<img class="gopher" src="/doc/gopher/talks.png"/>
|
||||
@@ -221,7 +194,7 @@ This talk expands on the <i>Go Concurrency Patterns</i> talk to dive deeper into
|
||||
<p>
|
||||
See the <a href="/talks">Go Talks site</a> and <a href="/wiki/GoTalks">wiki page</a> for more Go talks.
|
||||
</p>
|
||||
{{end}}
|
||||
|
||||
|
||||
<h2 id="nonenglish">Non-English Documentation</h2>
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<!--{
|
||||
"Title": "Editor plugins and IDEs",
|
||||
"Template": true
|
||||
}-->
|
||||
|
||||
<h2 id="introduction">Introduction</h2>
|
||||
|
||||
<p>
|
||||
This document lists commonly used editor plugins and IDEs from the Go ecosystem
|
||||
that make Go development more productive and seamless.
|
||||
A comprehensive list of editor support and IDEs for Go development is available at
|
||||
<a href="http://golang.org/wiki/IDEsAndTextEditorPlugins">the wiki</a>.
|
||||
</p>
|
||||
|
||||
<h2 id="options">Options</h2>
|
||||
<p>
|
||||
The Go ecosystem provides a variety of editor plugins and IDEs to enhance your day-to-day
|
||||
editing, navigation, testing, and debugging experience.
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="https://github.com/fatih/vim-go">vim</a>: vim-go plugin provides Go programming language support</li>
|
||||
<li><a href="https://marketplace.visualstudio.com/items?itemName=lukehoban.Go">Visual Studio Code</a>:
|
||||
Go extension provides support for the Go programming language</li>
|
||||
<li><a href="https://www.jetbrains.com/go">GoLand</a>: GoLand is distributed either as a standalone IDE
|
||||
or as a plugin for IntelliJ IDEA Ultimate</li>
|
||||
<li><a href="https://atom.io/packages/go-plus">Atom</a>: Go-Plus is an Atom package that provides enhanced Go support</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
Note that these are only a few top solutions; a more comphensive
|
||||
community-maintained list of
|
||||
<a href="https://github.com/golang/go/wiki/IDEsAndTextEditorPlugins">IDEs and text editor plugins</a>
|
||||
is available at the Wiki.
|
||||
</p>
|
||||
@@ -1431,7 +1431,9 @@ func Append(slice, data []byte) []byte {
|
||||
slice = newSlice
|
||||
}
|
||||
slice = slice[0:l+len(data)]
|
||||
copy(slice[l:], data)
|
||||
for i, c := range data {
|
||||
slice[l+i] = c
|
||||
}
|
||||
return slice
|
||||
}
|
||||
</pre>
|
||||
@@ -1519,7 +1521,7 @@ for i := range picture {
|
||||
<p>
|
||||
Maps are a convenient and powerful built-in data structure that associate
|
||||
values of one type (the <em>key</em>) with values of another type
|
||||
(the <em>element</em> or <em>value</em>).
|
||||
(the <em>element</em> or <em>value</em>)
|
||||
The key can be of any type for which the equality operator is defined,
|
||||
such as integers,
|
||||
floating point and complex numbers,
|
||||
@@ -1578,7 +1580,7 @@ if attended[person] { // will be false if person is not in the map
|
||||
<p>
|
||||
Sometimes you need to distinguish a missing entry from
|
||||
a zero value. Is there an entry for <code>"UTC"</code>
|
||||
or is that 0 because it's not in the map at all?
|
||||
or is that the empty string because it's not in the map at all?
|
||||
You can discriminate with a form of multiple assignment.
|
||||
</p>
|
||||
<pre>
|
||||
@@ -1831,7 +1833,7 @@ for a min function that chooses the least of a list of integers:
|
||||
</p>
|
||||
<pre>
|
||||
func Min(a ...int) int {
|
||||
min := int(^uint(0) >> 1) // largest int
|
||||
min := int(^uint(0) >> 1) // largest int
|
||||
for _, i := range a {
|
||||
if i < min {
|
||||
min = i
|
||||
@@ -2790,7 +2792,7 @@ job := &Job{command, log.New(os.Stderr, "Job: ", log.Ldate)}
|
||||
<p>
|
||||
If we need to refer to an embedded field directly, the type name of the field,
|
||||
ignoring the package qualifier, serves as a field name, as it did
|
||||
in the <code>Read</code> method of our <code>ReadWriter</code> struct.
|
||||
in the <code>Read</code> method of our <code>ReaderWriter</code> struct.
|
||||
Here, if we needed to access the
|
||||
<code>*log.Logger</code> of a <code>Job</code> variable <code>job</code>,
|
||||
we would write <code>job.Logger</code>,
|
||||
|
||||
@@ -59,17 +59,10 @@ should not be visible to Go programs.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The GCC 7 releases include a complete implementation of the Go 1.8.1
|
||||
user libraries. As with earlier releases, the Go 1.8 runtime is not
|
||||
fully merged, but that should not be visible to Go programs.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The GCC 8 releases are expected to include a complete implementation
|
||||
of the Go 1.10 release, depending on release timing. The Go 1.10
|
||||
runtime has now been fully merged into the GCC development sources,
|
||||
and concurrent garbage collection is expected to be fully supported in
|
||||
GCC 8.
|
||||
The GCC 7 releases are expected to include a complete implementation
|
||||
of the Go 1.8 user libraries. As with earlier releases, the Go 1.8
|
||||
runtime is not fully merged, but that should not be visible to Go
|
||||
programs.
|
||||
</p>
|
||||
|
||||
<h2 id="Source_code">Source code</h2>
|
||||
|
||||
@@ -166,7 +166,7 @@ providing a complete Go 1.1 implementation.
|
||||
<h3 id="gc_flag">Command-line flag parsing</h3>
|
||||
|
||||
<p>
|
||||
In the gc toolchain, the compilers and linkers now use the
|
||||
In the gc tool chain, the compilers and linkers now use the
|
||||
same command-line flag parsing rules as the Go flag package, a departure
|
||||
from the traditional Unix flag parsing. This may affect scripts that invoke
|
||||
the tool directly.
|
||||
@@ -305,7 +305,7 @@ The race detector is documented in <a href="/doc/articles/race_detector.html">a
|
||||
<p>
|
||||
Due to the change of the <a href="#int"><code>int</code></a> to 64 bits and
|
||||
a new internal <a href="//golang.org/s/go11func">representation of functions</a>,
|
||||
the arrangement of function arguments on the stack has changed in the gc toolchain.
|
||||
the arrangement of function arguments on the stack has changed in the gc tool chain.
|
||||
Functions written in assembly will need to be revised at least
|
||||
to adjust frame pointer offsets.
|
||||
</p>
|
||||
@@ -395,7 +395,7 @@ Run <code>go help test</code> for more information.
|
||||
The <a href="/cmd/fix/"><code>fix</code></a> command, usually run as
|
||||
<code>go fix</code>, no longer applies fixes to update code from
|
||||
before Go 1 to use Go 1 APIs.
|
||||
To update pre-Go 1 code to Go 1.1, use a Go 1.0 toolchain
|
||||
To update pre-Go 1 code to Go 1.1, use a Go 1.0 tool chain
|
||||
to convert the code to Go 1.0 first.
|
||||
</p>
|
||||
|
||||
@@ -427,7 +427,7 @@ To build a file only with Go 1.0.x, use the converse constraint:
|
||||
<h3 id="platforms">Additional platforms</h3>
|
||||
|
||||
<p>
|
||||
The Go 1.1 toolchain adds experimental support for <code>freebsd/arm</code>,
|
||||
The Go 1.1 tool chain adds experimental support for <code>freebsd/arm</code>,
|
||||
<code>netbsd/386</code>, <code>netbsd/amd64</code>, <code>netbsd/arm</code>,
|
||||
<code>openbsd/386</code> and <code>openbsd/amd64</code> platforms.
|
||||
</p>
|
||||
|
||||
1448
doc/go1.10.html
1448
doc/go1.10.html
File diff suppressed because it is too large
Load Diff
@@ -266,7 +266,7 @@ is now an error.
|
||||
<p>
|
||||
On the ARM, the toolchain supports "external linking", which
|
||||
is a step towards being able to build shared libraries with the gc
|
||||
toolchain and to provide dynamic linking support for environments
|
||||
tool chain and to provide dynamic linking support for environments
|
||||
in which that is necessary.
|
||||
</p>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ The latest Go release, version 1.3, arrives six months after 1.2,
|
||||
and contains no language changes.
|
||||
It focuses primarily on implementation work, providing
|
||||
precise garbage collection,
|
||||
a major refactoring of the compiler toolchain that results in
|
||||
a major refactoring of the compiler tool chain that results in
|
||||
faster builds, especially for large projects,
|
||||
significant performance improvements across the board,
|
||||
and support for DragonFly BSD, Solaris, Plan 9 and Google's Native Client architecture (NaCl).
|
||||
@@ -285,7 +285,7 @@ building and linking with a shared library.
|
||||
<h3 id="gc_flag">Command-line flag parsing</h3>
|
||||
|
||||
<p>
|
||||
In the gc toolchain, the assemblers now use the
|
||||
In the gc tool chain, the assemblers now use the
|
||||
same command-line flag parsing rules as the Go flag package, a departure
|
||||
from the traditional Unix flag parsing.
|
||||
This may affect scripts that invoke the tool directly.
|
||||
|
||||
55
doc/go1.8.txt
Normal file
55
doc/go1.8.txt
Normal file
@@ -0,0 +1,55 @@
|
||||
This file lists things yet to be moved into go1.8.html or deemed too
|
||||
minor to mention. Either way, delete from here when done.
|
||||
|
||||
Tools:
|
||||
|
||||
go: -buildmode=c-archive now builds PIC on ELF (CL 24180)
|
||||
go: mobile pkg dir change, recommend using go list in scripts (CL 24930, CL 27929)
|
||||
go, dist: can set default pkg-config tool using PKG_CONFIG env var (CL 29991)
|
||||
go: can set secure/insecure GIT schemes using GIT_ALLOW_PROTOCOL env var (CL 30135)
|
||||
|
||||
API additions and behavior changes:
|
||||
|
||||
cmd/compile, runtime, etc: get rid of constant FP registers (CL 28095)
|
||||
cmd/compile, runtime: add go:yeswritebarrierrec pragma (CL 30938)
|
||||
cmd/compile/internal/gc: enable new parser by default (CL 27203)
|
||||
cmd/compile/internal/syntax: fast Go syntax trees, initial commit (CL 27195)
|
||||
cmd/compile: add compiler phase timing (CL 24462)
|
||||
cmd/compile: add inline explainer (CL 22782)
|
||||
cmd/compile: enable flag-specified dump of specific phase+function (CL 23044)
|
||||
|
||||
cmd/internal/obj, cmd/link: darwin dynlink support (CL 29393)
|
||||
cmd/internal/objfile: add ppc64/ppc64le disassembler support (CL 9682)
|
||||
cmd/link, cmd/go: delay linking of mingwex and mingw32 until very end (CL 26670)
|
||||
cmd/link: R_ADDR dynamic relocs for internal PIE (CL 29118)
|
||||
cmd/link: add trampolines for too far calls in ppc64x (CL 30850)
|
||||
cmd/link: allow internal PIE linking (CL 28543)
|
||||
cmd/link: fix -X importpath.name=value when import path needs escaping (CL 31970)
|
||||
cmd/link: fix -buildmode=pie / -linkshared combination (CL 28996)
|
||||
cmd/link: for -buildmode=exe pass -no-pie to external linker (CL 33106)
|
||||
cmd/link: insert trampolines for too-far jumps on ARM (CL 29397)
|
||||
cmd/link: non-executable stack support for Solaris (CL 24142)
|
||||
cmd/link: put text at address 0x1000000 on darwin/amd64 (CL 32185)
|
||||
cmd/link: remove the -shared flag (CL 28852)
|
||||
cmd/link: split large elf text sections on ppc64x (CL 27790)
|
||||
cmd/link: trampoline support for external linking on ARM (CL 31143)
|
||||
cmd/objdump: implement objdump of .o files (CL 24818)
|
||||
|
||||
go/build: allow % in ${SRCDIR} expansion for Jenkins (CL 31611)
|
||||
go/build: do not record go:binary-only-package if build tags not satisfied (CL 31577)
|
||||
go/build: implement default GOPATH (CL 32019)
|
||||
|
||||
runtime/race: update race runtime (CL 32160)
|
||||
runtime: assume 64kB physical pages on ARM (CL 25021)
|
||||
runtime: disable stack rescanning by default (CL 31766)
|
||||
runtime: don't call cgocallback from signal handler (CL 30218)
|
||||
runtime: fix check for vacuous page boundary rounding (CL 27230)
|
||||
runtime: fix map iterator concurrent map check (CL 24749)
|
||||
runtime: fix newextram PC passed to race detector (CL 29712)
|
||||
runtime: implement unconditional hybrid barrier (CL 31765)
|
||||
runtime: include pre-panic/throw logs in core dumps (CL 32013)
|
||||
runtime: limit the number of map overflow buckets (CL 25049)
|
||||
runtime: pass windows float syscall args via XMM (CL 32173)
|
||||
runtime: print sigcode on signal crash (CL 32183)
|
||||
runtime: record current PC for SIGPROF on non-Go thread (CL 30252)
|
||||
runtime: sleep on CLOCK_MONOTONIC in futexsleep1 on freebsd (CL 30154)
|
||||
1024
doc/go1.9.html
1024
doc/go1.9.html
File diff suppressed because it is too large
Load Diff
@@ -775,7 +775,7 @@ to turn a string into an error. It replaces the old <code>os.NewError</code>.
|
||||
</p>
|
||||
|
||||
{{code "/doc/progs/go1.go" `/ErrSyntax/`}}
|
||||
|
||||
|
||||
<p>
|
||||
<em>Updating</em>:
|
||||
Running <code>go</code> <code>fix</code> will update almost all code affected by the change.
|
||||
@@ -1827,7 +1827,7 @@ for full details.
|
||||
<tr><td>Uitob(x, b)</td> <td>FormatUint(uint64(x), b)</td></tr>
|
||||
<tr><td>Uitob64(x, b)</td> <td>FormatUint(x, b)</td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
<p>
|
||||
<em>Updating</em>:
|
||||
Running <code>go</code> <code>fix</code> will update almost all code affected by the change.
|
||||
@@ -1841,7 +1841,7 @@ a cast that must be added by hand; the <code>go</code> <code>fix</code> tool wil
|
||||
<h3 id="templates">The template packages</h3>
|
||||
|
||||
<p>
|
||||
The <code>template</code> and <code>exp/template/html</code> packages have moved to
|
||||
The <code>template</code> and <code>exp/template/html</code> packages have moved to
|
||||
<a href="/pkg/text/template/"><code>text/template</code></a> and
|
||||
<a href="/pkg/html/template/"><code>html/template</code></a>.
|
||||
More significant, the interface to these packages has been simplified.
|
||||
@@ -2035,4 +2035,4 @@ They are available for many combinations of architecture and operating system
|
||||
Installation details are described on the
|
||||
<a href="/doc/install">Getting Started</a> page, while
|
||||
the distributions themselves are listed on the
|
||||
<a href="/dl/">downloads page</a>.
|
||||
<a href="https://golang.org/dl/">downloads page</a>.
|
||||
|
||||
@@ -190,8 +190,8 @@ For details and background, see
|
||||
<h2 id="tools">Tools</h2>
|
||||
|
||||
<p>
|
||||
Finally, the Go toolchain (compilers, linkers, build tools, and so
|
||||
on) is under active development and may change behavior. This
|
||||
Finally, the Go tool chain (compilers, linkers, build tools, and so
|
||||
on) are under active development and may change behavior. This
|
||||
means, for instance, that scripts that depend on the location and
|
||||
properties of the tools may be broken by a point release.
|
||||
</p>
|
||||
|
||||
@@ -479,15 +479,6 @@ as when hosting an untrusted program, the implementation could interlock
|
||||
map access.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Map access is unsafe only when updates are occurring.
|
||||
As long as all goroutines are only reading—looking up elements in the map,
|
||||
including iterating through it using a
|
||||
<code>for</code> <code>range</code> loop—and not changing the map
|
||||
by assigning to elements or doing deletions,
|
||||
it is safe for them to access the map concurrently without synchronization.
|
||||
</p>
|
||||
|
||||
<h3 id="language_changes">
|
||||
Will you accept my language change?</h3>
|
||||
|
||||
@@ -1149,7 +1140,7 @@ program is one tool to help automate this process.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The Go 1.5 release added a facility to the
|
||||
The Go 1.5 release includes an experimental facility to the
|
||||
<a href="https://golang.org/cmd/go">go</a> command
|
||||
that makes it easier to manage external dependencies by "vendoring"
|
||||
them into a special directory near the package that depends upon them.
|
||||
@@ -1157,13 +1148,6 @@ See the <a href="https://golang.org/s/go15vendor">design
|
||||
document</a> for details.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Work is underway on an experimental package management tool,
|
||||
<a href="https://github.com/golang/dep"><code>dep</code></a>, to learn
|
||||
more about how tooling can help package management. More information can be found in
|
||||
<a href="https://github.com/golang/dep/blob/master/docs/FAQ.md">the <code>dep</code> FAQ</a>.
|
||||
</p>
|
||||
|
||||
<h2 id="Pointers">Pointers and Allocation</h2>
|
||||
|
||||
<h3 id="pass_by_value">
|
||||
@@ -1485,53 +1469,6 @@ For more detail on this topic see the talk entitled,
|
||||
<a href="//blog.golang.org/2013/01/concurrency-is-not-parallelism.html">Concurrency
|
||||
is not Parallelism</a>.
|
||||
|
||||
<h3 id="no_goroutine_id">
|
||||
Why is there no goroutine ID?</h3>
|
||||
|
||||
<p>
|
||||
Goroutines do not have names; they are just anonymous workers.
|
||||
They expose no unique identifier, name, or data structure to the programmer.
|
||||
Some people are surprised by this, expecting the <code>go</code>
|
||||
statement to return some item that can be used to access and control
|
||||
the goroutine later.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The fundamental reason goroutines are anonymous is so that
|
||||
the full Go language is available when programming concurrent code.
|
||||
By contrast, the usage patterns that develop when threads and goroutines are
|
||||
named can restrict what a library using them can do.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Here is an illustration of the difficulties.
|
||||
Once one names a goroutine and constructs a model around
|
||||
it, it becomes special, and one is tempted to associate all computation
|
||||
with that goroutine, ignoring the possibility
|
||||
of using multiple, possibly shared goroutines for the processing.
|
||||
If the <code>net/http</code> package associated per-request
|
||||
state with a goroutine,
|
||||
clients would be unable to use more goroutines
|
||||
when serving a request.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Moreover, experience with libraries such as those for graphics systems
|
||||
that require all processing to occur on the "main thread"
|
||||
has shown how awkward and limiting the approach can be when
|
||||
deployed in a concurrent language.
|
||||
The very existence of a special thread or goroutine forces
|
||||
the programmer to distort the program to avoid crashes
|
||||
and other problems caused by inadvertently operating
|
||||
on the wrong thread.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For those cases where a particular goroutine is truly special,
|
||||
the language provides features such as channels that can be
|
||||
used in flexible ways to interact with it.
|
||||
</p>
|
||||
|
||||
<h2 id="Functions_methods">Functions and Methods</h2>
|
||||
|
||||
<h3 id="different_method_sets">
|
||||
@@ -1851,7 +1788,7 @@ supported by recent modifications to the gold linker.
|
||||
Why is my trivial program such a large binary?</h3>
|
||||
|
||||
<p>
|
||||
The linker in the <code>gc</code> toolchain
|
||||
The linker in the <code>gc</code> tool chain
|
||||
creates statically-linked binaries by default. All Go binaries therefore include the Go
|
||||
run-time, along with the run-time type information necessary to support dynamic
|
||||
type checks, reflection, and even panic-time stack traces.
|
||||
|
||||
520
doc/go_spec.html
520
doc/go_spec.html
@@ -1,6 +1,6 @@
|
||||
<!--{
|
||||
"Title": "The Go Programming Language Specification",
|
||||
"Subtitle": "Version of February 1, 2018",
|
||||
"Subtitle": "Version of January 31, 2017",
|
||||
"Path": "/ref/spec"
|
||||
}-->
|
||||
|
||||
@@ -16,7 +16,8 @@ Go is a general-purpose language designed with systems programming
|
||||
in mind. It is strongly typed and garbage-collected and has explicit
|
||||
support for concurrent programming. Programs are constructed from
|
||||
<i>packages</i>, whose properties allow efficient management of
|
||||
dependencies.
|
||||
dependencies. The existing implementations use a traditional
|
||||
compile/link model to generate executable binaries.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -153,7 +154,7 @@ Any other comment acts like a newline.
|
||||
<p>
|
||||
Tokens form the vocabulary of the Go language.
|
||||
There are four classes: <i>identifiers</i>, <i>keywords</i>, <i>operators
|
||||
and punctuation</i>, and <i>literals</i>. <i>White space</i>, formed from
|
||||
and delimiters</i>, and <i>literals</i>. <i>White space</i>, formed from
|
||||
spaces (U+0020), horizontal tabs (U+0009),
|
||||
carriage returns (U+000D), and newlines (U+000A),
|
||||
is ignored except as it separates tokens
|
||||
@@ -196,7 +197,7 @@ into the token stream immediately after a line's final token if that token is
|
||||
<code>return</code>
|
||||
</li>
|
||||
|
||||
<li>one of the <a href="#Operators_and_punctuation">operators and punctuation</a>
|
||||
<li>one of the <a href="#Operators_and_Delimiters">operators and delimiters</a>
|
||||
<code>++</code>,
|
||||
<code>--</code>,
|
||||
<code>)</code>,
|
||||
@@ -253,11 +254,10 @@ const fallthrough if range type
|
||||
continue for import return var
|
||||
</pre>
|
||||
|
||||
<h3 id="Operators_and_punctuation">Operators and punctuation</h3>
|
||||
<h3 id="Operators_and_Delimiters">Operators and Delimiters</h3>
|
||||
|
||||
<p>
|
||||
The following character sequences represent <a href="#Operators">operators</a>
|
||||
(including <a href="#assign_op">assignment operators</a>) and punctuation:
|
||||
The following character sequences represent <a href="#Operators">operators</a>, delimiters, and other special tokens:
|
||||
</p>
|
||||
<pre class="grammar">
|
||||
+ & += &= && == != ( )
|
||||
@@ -576,7 +576,11 @@ or <a href="#Conversions">conversion</a>, or implicitly when used in a
|
||||
<a href="#Assignments">assignment</a> or as an
|
||||
operand in an <a href="#Expressions">expression</a>.
|
||||
It is an error if the constant value
|
||||
cannot be <a href="#Representability">represented</a> as a value of the respective type.
|
||||
cannot be represented as a value of the respective type.
|
||||
For instance, <code>3.0</code> can be given any integer or any
|
||||
floating-point type, while <code>2147483648.0</code> (equal to <code>1<<31</code>)
|
||||
can be given the types <code>float32</code>, <code>float64</code>, or <code>uint32</code> but
|
||||
not <code>int32</code> or <code>string</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -681,9 +685,11 @@ If a variable has not yet been assigned a value, its value is the
|
||||
<h2 id="Types">Types</h2>
|
||||
|
||||
<p>
|
||||
A type determines a set of values together with operations and methods specific
|
||||
to those values. A type may be denoted by a <i>type name</i>, if it has one,
|
||||
or specified using a <i>type literal</i>, which composes a type from existing types.
|
||||
A type determines the set of values and operations specific to values of that
|
||||
type. Types may be <i>named</i> or <i>unnamed</i>. Named types are specified
|
||||
by a (possibly <a href="#Qualified_identifiers">qualified</a>)
|
||||
<a href="#Type_declarations"><i>type name</i></a>; unnamed types are specified
|
||||
using a <i>type literal</i>, which composes a new type from existing types.
|
||||
</p>
|
||||
|
||||
<pre class="ebnf">
|
||||
@@ -694,8 +700,8 @@ TypeLit = ArrayType | StructType | PointerType | FunctionType | InterfaceType
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The language <a href="#Predeclared_identifiers">predeclares</a> certain type names.
|
||||
Others are introduced with <a href="#Type_declarations">type declarations</a>.
|
||||
Named instances of the boolean, numeric, and string types are
|
||||
<a href="#Predeclared_identifiers">predeclared</a>.
|
||||
<i>Composite types</i>—array, struct, pointer, function,
|
||||
interface, slice, map, and channel types—may be constructed using
|
||||
type literals.
|
||||
@@ -711,23 +717,16 @@ is the underlying type of the type to which <code>T</code> refers in its
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
type (
|
||||
A1 = string
|
||||
A2 = A1
|
||||
)
|
||||
|
||||
type (
|
||||
B1 string
|
||||
B2 B1
|
||||
B3 []B1
|
||||
B4 B3
|
||||
)
|
||||
type T1 string
|
||||
type T2 T1
|
||||
type T3 []T1
|
||||
type T4 T3
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The underlying type of <code>string</code>, <code>A1</code>, <code>A2</code>, <code>B1</code>,
|
||||
and <code>B2</code> is <code>string</code>.
|
||||
The underlying type of <code>[]B1</code>, <code>B3</code>, and <code>B4</code> is <code>[]B1</code>.
|
||||
The underlying type of <code>string</code>, <code>T1</code>, and <code>T2</code>
|
||||
is <code>string</code>. The underlying type of <code>[]T1</code>, <code>T3</code>,
|
||||
and <code>T4</code> is <code>[]T1</code>.
|
||||
</p>
|
||||
|
||||
<h3 id="Method_sets">Method sets</h3>
|
||||
@@ -759,8 +758,7 @@ using a receiver of that type.
|
||||
<p>
|
||||
A <i>boolean type</i> represents the set of Boolean truth values
|
||||
denoted by the predeclared constants <code>true</code>
|
||||
and <code>false</code>. The predeclared boolean type is <code>bool</code>;
|
||||
it is a <a href="#Type_definitions">defined type</a>.
|
||||
and <code>false</code>. The predeclared boolean type is <code>bool</code>.
|
||||
</p>
|
||||
|
||||
<h3 id="Numeric_types">Numeric types</h3>
|
||||
@@ -807,9 +805,8 @@ uintptr an unsigned integer large enough to store the uninterpreted bits of a p
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
To avoid portability issues all numeric types are <a href="#Type_definitions">defined
|
||||
types</a> and thus distinct except
|
||||
<code>byte</code>, which is an <a href="#Alias_declarations">alias</a> for <code>uint8</code>, and
|
||||
To avoid portability issues all numeric types are distinct except
|
||||
<code>byte</code>, which is an alias for <code>uint8</code>, and
|
||||
<code>rune</code>, which is an alias for <code>int32</code>.
|
||||
Conversions
|
||||
are required when different numeric types are mixed in an expression
|
||||
@@ -825,8 +822,7 @@ A <i>string type</i> represents the set of string values.
|
||||
A string value is a (possibly empty) sequence of bytes.
|
||||
Strings are immutable: once created,
|
||||
it is impossible to change the contents of a string.
|
||||
The predeclared string type is <code>string</code>;
|
||||
it is a <a href="#Type_definitions">defined type</a>.
|
||||
The predeclared string type is <code>string</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -858,8 +854,7 @@ ElementType = Type .
|
||||
|
||||
<p>
|
||||
The length is part of the array's type; it must evaluate to a
|
||||
non-negative <a href="#Constants">constant</a>
|
||||
<a href="#Representability">representable</a> by a value
|
||||
non-negative <a href="#Constants">constant</a> representable by a value
|
||||
of type <code>int</code>.
|
||||
The length of array <code>a</code> can be discovered
|
||||
using the built-in function <a href="#Length_and_capacity"><code>len</code></a>.
|
||||
@@ -1024,8 +1019,8 @@ of a struct except that they cannot be used as field names in
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Given a struct type <code>S</code> and a <a href="#Type_definitions">defined type</a>
|
||||
<code>T</code>, promoted methods are included in the method set of the struct as follows:
|
||||
Given a struct type <code>S</code> and a type named <code>T</code>,
|
||||
promoted methods are included in the method set of the struct as follows:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
@@ -1422,10 +1417,11 @@ Two types are either <i>identical</i> or <i>different</i>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
A <a href="#Type_definitions">defined type</a> is always different from any other type.
|
||||
Otherwise, two types are identical if their <a href="#Types">underlying</a> type literals are
|
||||
structurally equivalent; that is, they have the same literal structure and corresponding
|
||||
components have identical types. In detail:
|
||||
Two <a href="#Types">named types</a> are identical if their type names originate in the same
|
||||
<a href="#Type_declarations">TypeSpec</a>.
|
||||
A named and an <a href="#Types">unnamed type</a> are always different. Two unnamed types are identical
|
||||
if the corresponding type literals are identical, that is, if they have the same
|
||||
literal structure and corresponding components have identical types. In detail:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
@@ -1452,9 +1448,9 @@ components have identical types. In detail:
|
||||
<a href="#Exported_identifiers">Non-exported</a> method names from different
|
||||
packages are always different. The order of the methods is irrelevant.</li>
|
||||
|
||||
<li>Two map types are identical if they have identical key and element types.</li>
|
||||
<li>Two map types are identical if they have identical key and value types.</li>
|
||||
|
||||
<li>Two channel types are identical if they have identical element types and
|
||||
<li>Two channel types are identical if they have identical value types and
|
||||
the same direction.</li>
|
||||
</ul>
|
||||
|
||||
@@ -1464,24 +1460,13 @@ Given the declarations
|
||||
|
||||
<pre>
|
||||
type (
|
||||
A0 = []string
|
||||
A1 = A0
|
||||
A2 = struct{ a, b int }
|
||||
A3 = int
|
||||
A4 = func(A3, float64) *A0
|
||||
A5 = func(x int, _ float64) *[]string
|
||||
T0 []string
|
||||
T1 []string
|
||||
T2 struct{ a, b int }
|
||||
T3 struct{ a, c int }
|
||||
T4 func(int, float64) *T0
|
||||
T5 func(x int, y float64) *[]string
|
||||
)
|
||||
|
||||
type (
|
||||
B0 A0
|
||||
B1 []string
|
||||
B2 struct{ a, b int }
|
||||
B3 struct{ a, c int }
|
||||
B4 func(int, float64) *B0
|
||||
B5 func(x int, y float64) *A1
|
||||
)
|
||||
|
||||
type C0 = B0
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -1489,22 +1474,17 @@ these types are identical:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
A0, A1, and []string
|
||||
A2 and struct{ a, b int }
|
||||
A3 and int
|
||||
A4, func(int, float64) *[]string, and A5
|
||||
|
||||
B0 and C0
|
||||
T0 and T0
|
||||
[]int and []int
|
||||
struct{ a, b *T5 } and struct{ a, b *T5 }
|
||||
func(x int, y float64) *[]string, func(int, float64) (result *[]string), and A5
|
||||
func(x int, y float64) *[]string and func(int, float64) (result *[]string)
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
<code>B0</code> and <code>B1</code> are different because they are new types
|
||||
created by distinct <a href="#Type_definitions">type definitions</a>;
|
||||
<code>func(int, float64) *B0</code> and <code>func(x int, y float64) *[]string</code>
|
||||
are different because <code>B0</code> is different from <code>[]string</code>.
|
||||
<code>T0</code> and <code>T1</code> are different because they are named types
|
||||
with distinct declarations; <code>func(int, float64) *T0</code> and
|
||||
<code>func(x int, y float64) *[]string</code> are different because <code>T0</code>
|
||||
is different from <code>[]string</code>.
|
||||
</p>
|
||||
|
||||
|
||||
@@ -1512,7 +1492,7 @@ are different because <code>B0</code> is different from <code>[]string</code>.
|
||||
|
||||
<p>
|
||||
A value <code>x</code> is <i>assignable</i> to a <a href="#Variables">variable</a> of type <code>T</code>
|
||||
("<code>x</code> is assignable to <code>T</code>") if one of the following conditions applies:
|
||||
("<code>x</code> is assignable to <code>T</code>") in any of these cases:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
@@ -1522,7 +1502,7 @@ A value <code>x</code> is <i>assignable</i> to a <a href="#Variables">variable</
|
||||
<li>
|
||||
<code>x</code>'s type <code>V</code> and <code>T</code> have identical
|
||||
<a href="#Types">underlying types</a> and at least one of <code>V</code>
|
||||
or <code>T</code> is not a <a href="#Type_definitions">defined</a> type.
|
||||
or <code>T</code> is not a <a href="#Types">named type</a>.
|
||||
</li>
|
||||
<li>
|
||||
<code>T</code> is an interface type and
|
||||
@@ -1531,75 +1511,19 @@ or <code>T</code> is not a <a href="#Type_definitions">defined</a> type.
|
||||
<li>
|
||||
<code>x</code> is a bidirectional channel value, <code>T</code> is a channel type,
|
||||
<code>x</code>'s type <code>V</code> and <code>T</code> have identical element types,
|
||||
and at least one of <code>V</code> or <code>T</code> is not a defined type.
|
||||
and at least one of <code>V</code> or <code>T</code> is not a named type.
|
||||
</li>
|
||||
<li>
|
||||
<code>x</code> is the predeclared identifier <code>nil</code> and <code>T</code>
|
||||
is a pointer, function, slice, map, channel, or interface type.
|
||||
</li>
|
||||
<li>
|
||||
<code>x</code> is an untyped <a href="#Constants">constant</a>
|
||||
<a href="#Representability">representable</a>
|
||||
<code>x</code> is an untyped <a href="#Constants">constant</a> representable
|
||||
by a value of type <code>T</code>.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3 id="Representability">Representability</h3>
|
||||
|
||||
<p>
|
||||
A <a href="#Constants">constant</a> <code>x</code> is <i>representable</i>
|
||||
by a value of type <code>T</code> if one of the following conditions applies:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<code>x</code> is in the set of values <a href="#Types">determined</a> by <code>T</code>.
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<code>T</code> is a floating-point type and <code>x</code> can be rounded to <code>T</code>'s
|
||||
precision without overflow. Rounding uses IEEE 754 round-to-even rules but with an IEEE
|
||||
negative zero further simplified to an unsigned zero. Note that constant values never result
|
||||
in an IEEE negative zero, NaN, or infinity.
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<code>T</code> is a complex type, and <code>x</code>'s
|
||||
<a href="#Complex_numbers">components</a> <code>real(x)</code> and <code>imag(x)</code>
|
||||
are representable by values of <code>T</code>'s component type (<code>float32</code> or
|
||||
<code>float64</code>).
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<pre>
|
||||
x T x is representable by a value of T because
|
||||
|
||||
'a' byte 97 is in the set of byte values
|
||||
97 rune rune is an alias for int32, and 97 is in the set of 32-bit integers
|
||||
"foo" string "foo" is in the set of string values
|
||||
1024 int16 1024 is in the set of 16-bit integers
|
||||
42.0 byte 42 is in the set of unsigned 8-bit integers
|
||||
1e10 uint64 10000000000 is in the set of unsigned 64-bit integers
|
||||
2.718281828459045 float32 2.718281828459045 rounds to 2.7182817 which is in the set of float32 values
|
||||
-1e-1000 float64 -1e-1000 rounds to IEEE -0.0 which is further simplified to 0.0
|
||||
0i int 0 is an integer value
|
||||
(42 + 0i) float32 42.0 (with zero imaginary part) is in the set of float32 values
|
||||
</pre>
|
||||
|
||||
<pre>
|
||||
x T x is not representable by a value of T because
|
||||
|
||||
0 bool 0 is not in the set of boolean values
|
||||
'a' string 'a' is a rune, it is not in the set of string values
|
||||
1024 byte 1024 is not in the set of unsigned 8-bit integers
|
||||
-1 uint16 -1 is not in the set of unsigned 16-bit integers
|
||||
1.1 int 1.1 is not an integer value
|
||||
42i float32 (0 + 42i) is not in the set of float32 values
|
||||
1e1000 float64 1e1000 overflows to IEEE +Inf after rounding
|
||||
</pre>
|
||||
|
||||
|
||||
<h2 id="Blocks">Blocks</h2>
|
||||
|
||||
<p>
|
||||
@@ -1835,7 +1759,7 @@ const u, v float32 = 0, 3 // u = 0.0, v = 3.0
|
||||
|
||||
<p>
|
||||
Within a parenthesized <code>const</code> declaration list the
|
||||
expression list may be omitted from any but the first ConstSpec.
|
||||
expression list may be omitted from any but the first declaration.
|
||||
Such an empty list is equivalent to the textual substitution of the
|
||||
first preceding non-empty expression list and its type if any.
|
||||
Omitting the list of expressions is therefore equivalent to
|
||||
@@ -1864,111 +1788,75 @@ const (
|
||||
<p>
|
||||
Within a <a href="#Constant_declarations">constant declaration</a>, the predeclared identifier
|
||||
<code>iota</code> represents successive untyped integer <a href="#Constants">
|
||||
constants</a>. Its value is the index of the respective <a href="#ConstSpec">ConstSpec</a>
|
||||
in that constant declaration, starting at zero.
|
||||
constants</a>. It is reset to 0 whenever the reserved word <code>const</code>
|
||||
appears in the source and increments after each <a href="#ConstSpec">ConstSpec</a>.
|
||||
It can be used to construct a set of related constants:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
const (
|
||||
const ( // iota is reset to 0
|
||||
c0 = iota // c0 == 0
|
||||
c1 = iota // c1 == 1
|
||||
c2 = iota // c2 == 2
|
||||
)
|
||||
|
||||
const (
|
||||
a = 1 << iota // a == 1 (iota == 0)
|
||||
b = 1 << iota // b == 2 (iota == 1)
|
||||
c = 3 // c == 3 (iota == 2, unused)
|
||||
d = 1 << iota // d == 8 (iota == 3)
|
||||
const ( // iota is reset to 0
|
||||
a = 1 << iota // a == 1
|
||||
b = 1 << iota // b == 2
|
||||
c = 3 // c == 3 (iota is not used but still incremented)
|
||||
d = 1 << iota // d == 8
|
||||
)
|
||||
|
||||
const (
|
||||
const ( // iota is reset to 0
|
||||
u = iota * 42 // u == 0 (untyped integer constant)
|
||||
v float64 = iota * 42 // v == 42.0 (float64 constant)
|
||||
w = iota * 42 // w == 84 (untyped integer constant)
|
||||
)
|
||||
|
||||
const x = iota // x == 0
|
||||
const y = iota // y == 0
|
||||
const x = iota // x == 0 (iota has been reset)
|
||||
const y = iota // y == 0 (iota has been reset)
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
By definition, multiple uses of <code>iota</code> in the same ConstSpec all have the same value:
|
||||
Within an ExpressionList, the value of each <code>iota</code> is the same because
|
||||
it is only incremented after each ConstSpec:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
const (
|
||||
bit0, mask0 = 1 << iota, 1<<iota - 1 // bit0 == 1, mask0 == 0 (iota == 0)
|
||||
bit1, mask1 // bit1 == 2, mask1 == 1 (iota == 1)
|
||||
_, _ // (iota == 2, unused)
|
||||
bit3, mask3 // bit3 == 8, mask3 == 7 (iota == 3)
|
||||
bit0, mask0 = 1 << iota, 1<<iota - 1 // bit0 == 1, mask0 == 0
|
||||
bit1, mask1 // bit1 == 2, mask1 == 1
|
||||
_, _ // skips iota == 2
|
||||
bit3, mask3 // bit3 == 8, mask3 == 7
|
||||
)
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
This last example exploits the <a href="#Constant_declarations">implicit repetition</a>
|
||||
of the last non-empty expression list.
|
||||
This last example exploits the implicit repetition of the
|
||||
last non-empty expression list.
|
||||
</p>
|
||||
|
||||
|
||||
<h3 id="Type_declarations">Type declarations</h3>
|
||||
|
||||
<p>
|
||||
A type declaration binds an identifier, the <i>type name</i>, to a <a href="#Types">type</a>.
|
||||
Type declarations come in two forms: alias declarations and type definitions.
|
||||
<p>
|
||||
|
||||
<pre class="ebnf">
|
||||
TypeDecl = "type" ( TypeSpec | "(" { TypeSpec ";" } ")" ) .
|
||||
TypeSpec = AliasDecl | TypeDef .
|
||||
</pre>
|
||||
|
||||
<h4 id="Alias_declarations">Alias declarations</h4>
|
||||
|
||||
<p>
|
||||
An alias declaration binds an identifier to the given type.
|
||||
A type declaration binds an identifier, the <i>type name</i>, to a new type
|
||||
that has the same <a href="#Types">underlying type</a> as an existing type,
|
||||
and operations defined for the existing type are also defined for the new type.
|
||||
The new type is <a href="#Type_identity">different</a> from the existing type.
|
||||
</p>
|
||||
|
||||
<pre class="ebnf">
|
||||
AliasDecl = identifier "=" Type .
|
||||
TypeDecl = "type" ( TypeSpec | "(" { TypeSpec ";" } ")" ) .
|
||||
TypeSpec = identifier Type .
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Within the <a href="#Declarations_and_scope">scope</a> of
|
||||
the identifier, it serves as an <i>alias</i> for the type.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
type IntArray [16]int
|
||||
|
||||
type (
|
||||
nodeList = []*Node // nodeList and []*Node are identical types
|
||||
Polar = polar // Polar and polar denote identical types
|
||||
)
|
||||
</pre>
|
||||
|
||||
|
||||
<h4 id="Type_definitions">Type definitions</h4>
|
||||
|
||||
<p>
|
||||
A type definition creates a new, distinct type with the same
|
||||
<a href="#Types">underlying type</a> and operations as the given type,
|
||||
and binds an identifier to it.
|
||||
</p>
|
||||
|
||||
<pre class="ebnf">
|
||||
TypeDef = identifier Type .
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The new type is called a <i>defined type</i>.
|
||||
It is <a href="#Type_identity">different</a> from any other type,
|
||||
including the type it is created from.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
type (
|
||||
Point struct{ x, y float64 } // Point and struct{ x, y float64 } are different types
|
||||
polar Point // polar and Point denote different types
|
||||
Point struct{ x, y float64 }
|
||||
Polar Point
|
||||
)
|
||||
|
||||
type TreeNode struct {
|
||||
@@ -1984,9 +1872,8 @@ type Block interface {
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
A defined type may have <a href="#Method_declarations">methods</a> associated with it.
|
||||
It does not inherit any methods bound to the given type,
|
||||
but the <a href="#Method_sets">method set</a>
|
||||
The declared type does not inherit any <a href="#Method_declarations">methods</a>
|
||||
bound to the existing type, but the <a href="#Method_sets">method set</a>
|
||||
of an interface type or of elements of a composite type remains unchanged:
|
||||
</p>
|
||||
|
||||
@@ -1999,7 +1886,7 @@ func (m *Mutex) Unlock() { /* Unlock implementation */ }
|
||||
// NewMutex has the same composition as Mutex but its method set is empty.
|
||||
type NewMutex Mutex
|
||||
|
||||
// The method set of PtrMutex's underlying type *Mutex remains unchanged,
|
||||
// The method set of the <a href="#Pointer_types">base type</a> of PtrMutex remains unchanged,
|
||||
// but the method set of PtrMutex is empty.
|
||||
type PtrMutex *Mutex
|
||||
|
||||
@@ -2014,8 +1901,8 @@ type MyBlock Block
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Type definitions may be used to define different boolean, numeric,
|
||||
or string types and associate methods with them:
|
||||
A type declaration may be used to define a different boolean, numeric, or string
|
||||
type and attach methods to it:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
@@ -2037,8 +1924,8 @@ func (tz TimeZone) String() string {
|
||||
<h3 id="Variable_declarations">Variable declarations</h3>
|
||||
|
||||
<p>
|
||||
A variable declaration creates one or more <a href="#Variables">variables</a>,
|
||||
binds corresponding identifiers to them, and gives each a type and an initial value.
|
||||
A variable declaration creates one or more variables, binds corresponding
|
||||
identifiers to them, and gives each a type and an initial value.
|
||||
</p>
|
||||
|
||||
<pre class="ebnf">
|
||||
@@ -2148,8 +2035,9 @@ to a function.
|
||||
</p>
|
||||
|
||||
<pre class="ebnf">
|
||||
FunctionDecl = "func" FunctionName Signature [ FunctionBody ] .
|
||||
FunctionDecl = "func" FunctionName ( Function | Signature ) .
|
||||
FunctionName = identifier .
|
||||
Function = Signature FunctionBody .
|
||||
FunctionBody = Block .
|
||||
</pre>
|
||||
|
||||
@@ -2195,8 +2083,8 @@ and associates the method with the receiver's <i>base type</i>.
|
||||
</p>
|
||||
|
||||
<pre class="ebnf">
|
||||
MethodDecl = "func" Receiver MethodName Signature [ FunctionBody ] .
|
||||
Receiver = Parameters .
|
||||
MethodDecl = "func" Receiver MethodName ( Function | Signature ) .
|
||||
Receiver = Parameters .
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -2205,7 +2093,7 @@ name. That parameter section must declare a single non-variadic parameter, the r
|
||||
Its type must be of the form <code>T</code> or <code>*T</code> (possibly using
|
||||
parentheses) where <code>T</code> is a type name. The type denoted by <code>T</code> is called
|
||||
the receiver <i>base type</i>; it must not be a pointer or interface type and
|
||||
it must be <a href="#Type_definitions">defined</a> in the same package as the method.
|
||||
it must be declared in the same package as the method.
|
||||
The method is said to be <i>bound</i> to the base type and the method name
|
||||
is visible only within <a href="#Selectors">selectors</a> for type <code>T</code>
|
||||
or <code>*T</code>.
|
||||
@@ -2276,6 +2164,7 @@ non-<a href="#Blank_identifier">blank</a> identifier denoting a
|
||||
<a href="#Constant_declarations">constant</a>,
|
||||
<a href="#Variable_declarations">variable</a>, or
|
||||
<a href="#Function_declarations">function</a>,
|
||||
a <a href="#Method_expressions">method expression</a> yielding a function,
|
||||
or a parenthesized expression.
|
||||
</p>
|
||||
|
||||
@@ -2285,7 +2174,7 @@ operand only on the left-hand side of an <a href="#Assignments">assignment</a>.
|
||||
</p>
|
||||
|
||||
<pre class="ebnf">
|
||||
Operand = Literal | OperandName | "(" Expression ")" .
|
||||
Operand = Literal | OperandName | MethodExpr | "(" Expression ")" .
|
||||
Literal = BasicLit | CompositeLit | FunctionLit .
|
||||
BasicLit = int_lit | float_lit | imaginary_lit | rune_lit | string_lit .
|
||||
OperandName = identifier | QualifiedIdent.
|
||||
@@ -2346,8 +2235,7 @@ The key is interpreted as a field name for struct literals,
|
||||
an index for array and slice literals, and a key for map literals.
|
||||
For map literals, all elements must have a key. It is an error
|
||||
to specify multiple elements with the same field name or
|
||||
constant key value. For non-constant map keys, see the section on
|
||||
<a href="#Order_of_evaluation">evaluation order</a>.
|
||||
constant key value.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -2399,8 +2287,7 @@ For array and slice literals the following rules apply:
|
||||
its position in the array.
|
||||
</li>
|
||||
<li>An element with a key uses the key as its index. The
|
||||
key must be a non-negative constant
|
||||
<a href="#Representability">representable</a> by
|
||||
key must be a non-negative constant representable by
|
||||
a value of type <code>int</code>; and if it is typed
|
||||
it must be of integer type.
|
||||
</li>
|
||||
@@ -2517,7 +2404,7 @@ A function literal represents an anonymous <a href="#Function_declarations">func
|
||||
</p>
|
||||
|
||||
<pre class="ebnf">
|
||||
FunctionLit = "func" Signature FunctionBody .
|
||||
FunctionLit = "func" Function .
|
||||
</pre>
|
||||
|
||||
<pre>
|
||||
@@ -2551,7 +2438,6 @@ Primary expressions are the operands for unary and binary expressions.
|
||||
PrimaryExpr =
|
||||
Operand |
|
||||
Conversion |
|
||||
MethodExpr |
|
||||
PrimaryExpr Selector |
|
||||
PrimaryExpr Index |
|
||||
PrimaryExpr Slice |
|
||||
@@ -2641,8 +2527,8 @@ expression is illegal.
|
||||
</li>
|
||||
|
||||
<li>
|
||||
As an exception, if the type of <code>x</code> is a <a href="#Type_definitions">defined</a>
|
||||
pointer type and <code>(*x).f</code> is a valid selector expression denoting a field
|
||||
As an exception, if the type of <code>x</code> is a named pointer type
|
||||
and <code>(*x).f</code> is a valid selector expression denoting a field
|
||||
(but not a method), <code>x.f</code> is shorthand for <code>(*x).f</code>.
|
||||
</li>
|
||||
|
||||
@@ -2738,7 +2624,7 @@ argument that is the receiver of the method.
|
||||
|
||||
<pre class="ebnf">
|
||||
MethodExpr = ReceiverType "." MethodName .
|
||||
ReceiverType = Type .
|
||||
ReceiverType = TypeName | "(" "*" TypeName ")" | "(" ReceiverType ")" .
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -2974,12 +2860,11 @@ The following rules apply:
|
||||
If <code>a</code> is not a map:
|
||||
</p>
|
||||
<ul>
|
||||
<li>the index <code>x</code> must be of integer type or an untyped constant</li>
|
||||
<li>a constant index must be non-negative and
|
||||
<a href="#Representability">representable</a> by a value of type <code>int</code></li>
|
||||
<li>a constant index that is untyped is given type <code>int</code></li>
|
||||
<li>the index <code>x</code> is <i>in range</i> if <code>0 <= x < len(a)</code>,
|
||||
<li>the index <code>x</code> must be of integer type or untyped;
|
||||
it is <i>in range</i> if <code>0 <= x < len(a)</code>,
|
||||
otherwise it is <i>out of range</i></li>
|
||||
<li>a <a href="#Constants">constant</a> index must be non-negative
|
||||
and representable by a value of type <code>int</code>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
@@ -3031,11 +2916,11 @@ For <code>a</code> of <a href="#Map_types">map type</a> <code>M</code>:
|
||||
<a href="#Assignability">assignable</a>
|
||||
to the key type of <code>M</code></li>
|
||||
<li>if the map contains an entry with key <code>x</code>,
|
||||
<code>a[x]</code> is the map element with key <code>x</code>
|
||||
and the type of <code>a[x]</code> is the element type of <code>M</code></li>
|
||||
<code>a[x]</code> is the map value with key <code>x</code>
|
||||
and the type of <code>a[x]</code> is the value type of <code>M</code></li>
|
||||
<li>if the map is <code>nil</code> or does not contain such an entry,
|
||||
<code>a[x]</code> is the <a href="#The_zero_value">zero value</a>
|
||||
for the element type of <code>M</code></li>
|
||||
for the value type of <code>M</code></li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
@@ -3129,8 +3014,7 @@ For arrays or strings, the indices are <i>in range</i> if
|
||||
<code>0</code> <= <code>low</code> <= <code>high</code> <= <code>len(a)</code>,
|
||||
otherwise they are <i>out of range</i>.
|
||||
For slices, the upper index bound is the slice capacity <code>cap(a)</code> rather than the length.
|
||||
A <a href="#Constants">constant</a> index must be non-negative and
|
||||
<a href="#Representability">representable</a> by a value of type
|
||||
A <a href="#Constants">constant</a> index must be non-negative and representable by a value of type
|
||||
<code>int</code>; for arrays or constant strings, constant indices must also be in range.
|
||||
If both indices are constant, they must satisfy <code>low <= high</code>.
|
||||
If the indices are out of range at run time, a <a href="#Run_time_panics">run-time panic</a> occurs.
|
||||
@@ -3146,8 +3030,8 @@ and the result of the slice operation is a slice with the same element type as t
|
||||
|
||||
<p>
|
||||
If the sliced operand of a valid slice expression is a <code>nil</code> slice, the result
|
||||
is a <code>nil</code> slice. Otherwise, if the result is a slice, it shares its underlying
|
||||
array with the operand.
|
||||
is a <code>nil</code> slice. Otherwise, the result shares its underlying array with the
|
||||
operand.
|
||||
</p>
|
||||
|
||||
<h4>Full slice expressions</h4>
|
||||
@@ -3190,8 +3074,7 @@ If the sliced operand is an array, it must be <a href="#Address_operators">addre
|
||||
<p>
|
||||
The indices are <i>in range</i> if <code>0 <= low <= high <= max <= cap(a)</code>,
|
||||
otherwise they are <i>out of range</i>.
|
||||
A <a href="#Constants">constant</a> index must be non-negative and
|
||||
<a href="#Representability">representable</a> by a value of type
|
||||
A <a href="#Constants">constant</a> index must be non-negative and representable by a value of type
|
||||
<code>int</code>; for arrays, constant indices must also be in range.
|
||||
If multiple indices are constant, the constants that are present must be in range relative to each
|
||||
other.
|
||||
@@ -3440,8 +3323,7 @@ to the type of the other operand.
|
||||
|
||||
<p>
|
||||
The right operand in a shift expression must have unsigned integer type
|
||||
or be an untyped constant <a href="#Representability">representable</a> by a
|
||||
value of type <code>uint</code>.
|
||||
or be an untyped constant that can be converted to unsigned integer type.
|
||||
If the left operand of a non-constant shift expression is an untyped constant,
|
||||
it is first converted to the type it would assume if the shift expression were
|
||||
replaced by its left operand alone.
|
||||
@@ -3449,20 +3331,18 @@ replaced by its left operand alone.
|
||||
|
||||
<pre>
|
||||
var s uint = 33
|
||||
var i = 1<<s // 1 has type int
|
||||
var j int32 = 1<<s // 1 has type int32; j == 0
|
||||
var k = uint64(1<<s) // 1 has type uint64; k == 1<<33
|
||||
var m int = 1.0<<s // 1.0 has type int; m == 0 if ints are 32bits in size
|
||||
var n = 1.0<<s == j // 1.0 has type int32; n == true
|
||||
var o = 1<<s == 2<<s // 1 and 2 have type int; o == true if ints are 32bits in size
|
||||
var p = 1<<s == 1<<33 // illegal if ints are 32bits in size: 1 has type int, but 1<<33 overflows int
|
||||
var u = 1.0<<s // illegal: 1.0 has type float64, cannot shift
|
||||
var u1 = 1.0<<s != 0 // illegal: 1.0 has type float64, cannot shift
|
||||
var u2 = 1<<s != 1.0 // illegal: 1 has type float64, cannot shift
|
||||
var v float32 = 1<<s // illegal: 1 has type float32, cannot shift
|
||||
var w int64 = 1.0<<33 // 1.0<<33 is a constant shift expression
|
||||
var x = a[1.0<<s] // 1.0 has type int; x == a[0] if ints are 32bits in size
|
||||
var a = make([]byte, 1.0<<s) // 1.0 has type int; len(a) == 0 if ints are 32bits in size
|
||||
var i = 1<<s // 1 has type int
|
||||
var j int32 = 1<<s // 1 has type int32; j == 0
|
||||
var k = uint64(1<<s) // 1 has type uint64; k == 1<<33
|
||||
var m int = 1.0<<s // 1.0 has type int; m == 0 if ints are 32bits in size
|
||||
var n = 1.0<<s == j // 1.0 has type int32; n == true
|
||||
var o = 1<<s == 2<<s // 1 and 2 have type int; o == true if ints are 32bits in size
|
||||
var p = 1<<s == 1<<33 // illegal if ints are 32bits in size: 1 has type int, but 1<<33 overflows int
|
||||
var u = 1.0<<s // illegal: 1.0 has type float64, cannot shift
|
||||
var u1 = 1.0<<s != 0 // illegal: 1.0 has type float64, cannot shift
|
||||
var u2 = 1<<s != 1.0 // illegal: 1 has type float64, cannot shift
|
||||
var v float32 = 1<<s // illegal: 1 has type float32, cannot shift
|
||||
var w int64 = 1.0<<33 // 1.0<<33 is a constant shift expression
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -3556,10 +3436,9 @@ with <code>x / y</code> truncated towards zero
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The one exception to this rule is that if the dividend <code>x</code> is
|
||||
the most negative value for the int type of <code>x</code>, the quotient
|
||||
<code>q = x / -1</code> is equal to <code>x</code> (and <code>r = 0</code>)
|
||||
due to two's-complement <a href="#Integer_overflow">integer overflow</a>:
|
||||
As an exception to this rule, if the dividend <code>x</code> is the most
|
||||
negative value for the int type of <code>x</code>, the quotient
|
||||
<code>q = x / -1</code> is equal to <code>x</code> (and <code>r = 0</code>).
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
@@ -3618,15 +3497,15 @@ For unsigned integer values, the operations <code>+</code>,
|
||||
computed modulo 2<sup><i>n</i></sup>, where <i>n</i> is the bit width of
|
||||
the <a href="#Numeric_types">unsigned integer</a>'s type.
|
||||
Loosely speaking, these unsigned integer operations
|
||||
discard high bits upon overflow, and programs may rely on "wrap around".
|
||||
discard high bits upon overflow, and programs may rely on ``wrap around''.
|
||||
</p>
|
||||
<p>
|
||||
For signed integers, the operations <code>+</code>,
|
||||
<code>-</code>, <code>*</code>, <code>/</code>, and <code><<</code> may legally
|
||||
<code>-</code>, <code>*</code>, and <code><<</code> may legally
|
||||
overflow and the resulting value exists and is deterministically defined
|
||||
by the signed integer representation, the operation, and its operands.
|
||||
No exception is raised as a result of overflow.
|
||||
A compiler may not optimize code under the assumption that overflow does
|
||||
No exception is raised as a result of overflow. A
|
||||
compiler may not optimize code under the assumption that overflow does
|
||||
not occur. For instance, it may not assume that <code>x < x + 1</code> is always true.
|
||||
</p>
|
||||
|
||||
@@ -3642,33 +3521,6 @@ IEEE-754 standard; whether a <a href="#Run_time_panics">run-time panic</a>
|
||||
occurs is implementation-specific.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
An implementation may combine multiple floating-point operations into a single
|
||||
fused operation, possibly across statements, and produce a result that differs
|
||||
from the value obtained by executing and rounding the instructions individually.
|
||||
A floating-point type <a href="#Conversions">conversion</a> explicitly rounds to
|
||||
the precision of the target type, preventing fusion that would discard that rounding.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For instance, some architectures provide a "fused multiply and add" (FMA) instruction
|
||||
that computes <code>x*y + z</code> without rounding the intermediate result <code>x*y</code>.
|
||||
These examples show when a Go implementation can use that instruction:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
// FMA allowed for computing r, because x*y is not explicitly rounded:
|
||||
r = x*y + z
|
||||
r = z; r += x*y
|
||||
t = x*y; r = t + z
|
||||
*p = x*y; r = *p + z
|
||||
r = x*y + float64(z)
|
||||
|
||||
// FMA disallowed for computing r, because it would omit rounding of x*y:
|
||||
r = float64(x*y) + z
|
||||
r = z; r += float64(x*y)
|
||||
t = float64(x*y); r = t + z
|
||||
</pre>
|
||||
|
||||
<h4 id="String_concatenation">String concatenation</h4>
|
||||
|
||||
@@ -3727,7 +3579,7 @@ These terms and the result of the comparisons are defined as follows:
|
||||
</li>
|
||||
|
||||
<li>
|
||||
Floating-point values are comparable and ordered,
|
||||
Floating point values are comparable and ordered,
|
||||
as defined by the IEEE-754 standard.
|
||||
</li>
|
||||
|
||||
@@ -3937,14 +3789,30 @@ func() int(x) // x is converted to func() int (unambiguous)
|
||||
|
||||
<p>
|
||||
A <a href="#Constants">constant</a> value <code>x</code> can be converted to
|
||||
type <code>T</code> if <code>x</code> is <a href="#Representability">representable</a>
|
||||
by a value of <code>T</code>.
|
||||
As a special case, an integer constant <code>x</code> can be converted to a
|
||||
<a href="#String_types">string type</a> using the
|
||||
<a href="#Conversions_to_and_from_a_string_type">same rule</a>
|
||||
as for non-constant <code>x</code>.
|
||||
type <code>T</code> in any of these cases:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<code>x</code> is representable by a value of type <code>T</code>.
|
||||
</li>
|
||||
<li>
|
||||
<code>x</code> is a floating-point constant,
|
||||
<code>T</code> is a floating-point type,
|
||||
and <code>x</code> is representable by a value
|
||||
of type <code>T</code> after rounding using
|
||||
IEEE 754 round-to-even rules, but with an IEEE <code>-0.0</code>
|
||||
further rounded to an unsigned <code>0.0</code>.
|
||||
The constant <code>T(x)</code> is the rounded value.
|
||||
</li>
|
||||
<li>
|
||||
<code>x</code> is an integer constant and <code>T</code> is a
|
||||
<a href="#String_types">string type</a>.
|
||||
The <a href="#Conversions_to_and_from_a_string_type">same rule</a>
|
||||
as for non-constant <code>x</code> applies in this case.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
Converting a constant yields a typed constant as result.
|
||||
</p>
|
||||
@@ -3981,8 +3849,7 @@ in any of these cases:
|
||||
</li>
|
||||
<li>
|
||||
ignoring struct tags (see below),
|
||||
<code>x</code>'s type and <code>T</code> are pointer types
|
||||
that are not <a href="#Type_definitions">defined types</a>,
|
||||
<code>x</code>'s type and <code>T</code> are unnamed pointer types
|
||||
and their pointer base types have identical underlying types.
|
||||
</li>
|
||||
<li>
|
||||
@@ -4231,8 +4098,7 @@ The divisor of a constant division or remainder operation must not be zero:
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The values of <i>typed</i> constants must always be accurately
|
||||
<a href="#Representability">representable</a> by values
|
||||
The values of <i>typed</i> constants must always be accurately representable as values
|
||||
of the constant type. The following constant expressions are illegal:
|
||||
</p>
|
||||
|
||||
@@ -4355,9 +4221,7 @@ SimpleStmt = EmptyStmt | ExpressionStmt | SendStmt | IncDecStmt | Assignment | S
|
||||
<h3 id="Terminating_statements">Terminating statements</h3>
|
||||
|
||||
<p>
|
||||
A <i>terminating statement</i> prevents execution of all statements that lexically
|
||||
appear after it in the same <a href="#Blocks">block</a>. The following statements
|
||||
are terminating:
|
||||
A terminating statement is one of the following:
|
||||
</p>
|
||||
|
||||
<ol>
|
||||
@@ -4570,8 +4434,8 @@ a[i] = 23
|
||||
|
||||
<p>
|
||||
An <i>assignment operation</i> <code>x</code> <i>op</i><code>=</code>
|
||||
<code>y</code> where <i>op</i> is a binary <a href="#Arithmetic_operators">arithmetic operator</a>
|
||||
is equivalent to <code>x</code> <code>=</code> <code>x</code> <i>op</i>
|
||||
<code>y</code> where <i>op</i> is a binary arithmetic operation is equivalent
|
||||
to <code>x</code> <code>=</code> <code>x</code> <i>op</i>
|
||||
<code>(y)</code> but evaluates <code>x</code>
|
||||
only once. The <i>op</i><code>=</code> construct is a single token.
|
||||
In assignment operations, both the left- and right-hand expression lists
|
||||
@@ -4867,9 +4731,8 @@ in the TypeSwitchGuard.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Instead of a type, a case may use the predeclared identifier
|
||||
<a href="#Predeclared_identifiers"><code>nil</code></a>;
|
||||
that case is selected when the expression in the TypeSwitchGuard
|
||||
The type in a case may be <a href="#Predeclared_identifiers"><code>nil</code></a>;
|
||||
that case is used when the expression in the TypeSwitchGuard
|
||||
is a <code>nil</code> interface value.
|
||||
There may be at most one <code>nil</code> case.
|
||||
</p>
|
||||
@@ -5027,10 +4890,12 @@ the range clause is equivalent to the same clause without that identifier.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The range expression <code>x</code> is evaluated once before beginning the loop,
|
||||
with one exception: if at most one iteration variable is present and
|
||||
<code>len(x)</code> is <a href="#Length_and_capacity">constant</a>,
|
||||
the range expression is not evaluated.
|
||||
The range expression is evaluated once before beginning the loop,
|
||||
with one exception: if the range expression is an array or a pointer to an array
|
||||
and at most one iteration variable is present, only the range expression's
|
||||
length is evaluated; if that length is constant,
|
||||
<a href="#Length_and_capacity">by definition</a>
|
||||
the range expression itself will not be evaluated.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -5071,8 +4936,8 @@ a single byte in the string.
|
||||
<li>
|
||||
The iteration order over maps is not specified
|
||||
and is not guaranteed to be the same from one iteration to the next.
|
||||
If a map entry that has not yet been reached is removed during iteration,
|
||||
the corresponding iteration value will not be produced. If a map entry is
|
||||
If map entries that have not yet been reached are removed during iteration,
|
||||
the corresponding iteration values will not be produced. If map entries are
|
||||
created during iteration, that entry may be produced during the iteration or
|
||||
may be skipped. The choice may vary for each entry created and from one
|
||||
iteration to the next.
|
||||
@@ -5121,7 +4986,7 @@ for i, s := range a {
|
||||
}
|
||||
|
||||
var key string
|
||||
var val interface {} // element type of m is assignable to val
|
||||
var val interface {} // value type of m is assignable to val
|
||||
m := map[string]int{"mon":0, "tue":1, "wed":2, "thu":3, "fri":4, "sat":5, "sun":6}
|
||||
for key, val = range m {
|
||||
h(key, val)
|
||||
@@ -5172,7 +5037,7 @@ function completes.
|
||||
|
||||
<pre>
|
||||
go Server()
|
||||
go func(ch chan<- bool) { for { sleep(10); ch <- true }} (c)
|
||||
go func(ch chan<- bool) { for { sleep(10); ch <- true; }} (c)
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -5718,7 +5583,7 @@ make(T, n) slice slice of type T with length n and capacity n
|
||||
make(T, n, m) slice slice of type T with length n and capacity m
|
||||
|
||||
make(T) map map of type T
|
||||
make(T, n) map map of type T with initial space for approximately n elements
|
||||
make(T, n) map map of type T with initial space for n elements
|
||||
|
||||
make(T) channel unbuffered channel of type T
|
||||
make(T, n) channel buffered channel of type T, buffer size n
|
||||
@@ -5726,10 +5591,9 @@ make(T, n) channel buffered channel of type T, buffer size n
|
||||
|
||||
|
||||
<p>
|
||||
Each of the size arguments <code>n</code> and <code>m</code> must be of integer type
|
||||
or an untyped <a href="#Constants">constant</a>.
|
||||
A constant size argument must be non-negative and <a href="#Representability">representable</a>
|
||||
by a value of type <code>int</code>; if it is an untyped constant it is given type <code>int</code>.
|
||||
The size arguments <code>n</code> and <code>m</code> must be of integer type or untyped.
|
||||
A <a href="#Constants">constant</a> size argument must be non-negative and
|
||||
representable by a value of type <code>int</code>.
|
||||
If both <code>n</code> and <code>m</code> are provided and are constant, then
|
||||
<code>n</code> must be no larger than <code>m</code>.
|
||||
If <code>n</code> is negative or larger than <code>m</code> at run time,
|
||||
@@ -5742,15 +5606,9 @@ s := make([]int, 1e3) // slice with len(s) == cap(s) == 1000
|
||||
s := make([]int, 1<<63) // illegal: len(s) is not representable by a value of type int
|
||||
s := make([]int, 10, 0) // illegal: len(s) > cap(s)
|
||||
c := make(chan int, 10) // channel with a buffer size of 10
|
||||
m := make(map[string]int, 100) // map with initial space for approximately 100 elements
|
||||
m := make(map[string]int, 100) // map with initial space for 100 elements
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Calling <code>make</code> with a map type and size hint <code>n</code> will
|
||||
create a map with initial space to hold <code>n</code> map elements.
|
||||
The precise behavior is implementation-dependent.
|
||||
</p>
|
||||
|
||||
|
||||
<h3 id="Appending_and_copying_slices">Appending to and copying slices</h3>
|
||||
|
||||
@@ -6012,11 +5870,6 @@ print prints all arguments; formatting of arguments is implementation-speci
|
||||
println like print but prints spaces between arguments and a newline at the end
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Implementation restriction: <code>print</code> and <code>println</code> need not
|
||||
accept arbitrary argument types, but printing of boolean, numeric, and string
|
||||
<a href="#Types">types</a> must be supported.
|
||||
</p>
|
||||
|
||||
<h2 id="Packages">Packages</h2>
|
||||
|
||||
@@ -6204,7 +6057,7 @@ of <code>make</code>,
|
||||
and no explicit initialization is provided, the variable or value is
|
||||
given a default value. Each element of such a variable or value is
|
||||
set to the <i>zero value</i> for its type: <code>false</code> for booleans,
|
||||
<code>0</code> for numeric types, <code>""</code>
|
||||
<code>0</code> for integers, <code>0.0</code> for floats, <code>""</code>
|
||||
for strings, and <code>nil</code> for pointers, functions, interfaces, slices, channels, and maps.
|
||||
This initialization is done recursively, so for instance each element of an
|
||||
array of structs will have its fields zeroed if no value is specified.
|
||||
@@ -6456,8 +6309,7 @@ type Error interface {
|
||||
<h3 id="Package_unsafe">Package <code>unsafe</code></h3>
|
||||
|
||||
<p>
|
||||
The built-in package <code>unsafe</code>, known to the compiler
|
||||
and accessible through the <a href="#Import_declarations">import path</a> <code>"unsafe"</code>,
|
||||
The built-in package <code>unsafe</code>, known to the compiler,
|
||||
provides facilities for low-level programming including operations
|
||||
that violate the type system. A package using <code>unsafe</code>
|
||||
must be vetted manually for type safety and may not be portable.
|
||||
@@ -6479,7 +6331,7 @@ func Sizeof(variable ArbitraryType) uintptr
|
||||
A <code>Pointer</code> is a <a href="#Pointer_types">pointer type</a> but a <code>Pointer</code>
|
||||
value may not be <a href="#Address_operators">dereferenced</a>.
|
||||
Any pointer or value of <a href="#Types">underlying type</a> <code>uintptr</code> can be converted to
|
||||
a type of underlying type <code>Pointer</code> and vice versa.
|
||||
a <code>Pointer</code> type and vice versa.
|
||||
The effect of converting between <code>Pointer</code> and <code>uintptr</code> is implementation-defined.
|
||||
</p>
|
||||
|
||||
@@ -6557,7 +6409,7 @@ The following minimal alignment properties are guaranteed:
|
||||
</li>
|
||||
|
||||
<li>For a variable <code>x</code> of array type: <code>unsafe.Alignof(x)</code> is the same as
|
||||
the alignment of a variable of the array's element type.
|
||||
<code>unsafe.Alignof(x[0])</code>, but at least 1.
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<!--{
|
||||
"Title": "Help",
|
||||
"Path": "/help/",
|
||||
"Template": true
|
||||
"Path": "/help/"
|
||||
}-->
|
||||
|
||||
<div id="manual-nav"></div>
|
||||
@@ -10,7 +9,6 @@
|
||||
|
||||
<img class="gopher" src="/doc/gopher/help.png"/>
|
||||
|
||||
{{if not $.GoogleCN}}
|
||||
<h3 id="mailinglist"><a href="https://groups.google.com/group/golang-nuts">Go Nuts Mailing List</a></h3>
|
||||
<p>
|
||||
Get help from Go users, and share your work on the official mailing list.
|
||||
@@ -33,12 +31,10 @@ forum for Go programmers.
|
||||
<h3 id="irc"><a href="irc:irc.freenode.net/go-nuts">Go IRC Channel</a></h3>
|
||||
<p>Get live support at <b>#go-nuts</b> on <b>irc.freenode.net</b>, the official
|
||||
Go IRC channel.</p>
|
||||
{{end}}
|
||||
|
||||
<h3 id="faq"><a href="/doc/faq">Frequently Asked Questions (FAQ)</a></h3>
|
||||
<p>Answers to common questions about Go.</p>
|
||||
|
||||
{{if not $.GoogleCN}}
|
||||
<h2 id="inform">Stay informed</h2>
|
||||
|
||||
<h3 id="announce"><a href="https://groups.google.com/group/golang-announce">Go Announcements Mailing List</a></h3>
|
||||
@@ -63,13 +59,6 @@ The <a href="https://reddit.com/r/golang">golang sub-Reddit</a> is a place
|
||||
for Go news and discussion.
|
||||
</p>
|
||||
|
||||
<h3 id="gotime"><a href="https://changelog.com/gotime">Go Time Podcast</a></h3>
|
||||
<p>
|
||||
The <a href="https://changelog.com/gotime">Go Time podcast</a> is a panel of Go experts and special guests
|
||||
discussing the Go programming language, the community, and everything in between.
|
||||
</p>
|
||||
{{end}}
|
||||
|
||||
<h2 id="community">Community resources</h2>
|
||||
|
||||
<h3 id="go_user_groups"><a href="/wiki/GoUserGroups">Go User Groups</a></h3>
|
||||
@@ -78,13 +67,11 @@ Each month in places around the world, groups of Go programmers ("gophers")
|
||||
meet to talk about Go. Find a chapter near you.
|
||||
</p>
|
||||
|
||||
{{if not $.GoogleCN}}
|
||||
<h3 id="playground"><a href="/play">Go Playground</a></h3>
|
||||
<p>A place to write, run, and share Go code.</p>
|
||||
|
||||
<h3 id="wiki"><a href="/wiki">Go Wiki</a></h3>
|
||||
<p>A wiki maintained by the Go community.</p>
|
||||
{{end}}
|
||||
|
||||
<h3 id="conduct"><a href="/conduct">Code of Conduct</a></h3>
|
||||
<p>
|
||||
|
||||
@@ -24,7 +24,7 @@ packages, though, read on.
|
||||
<div class="detail">
|
||||
|
||||
<p>
|
||||
There are two official Go compiler toolchains.
|
||||
There are two official Go compiler tool chains.
|
||||
This document focuses on the <code>gc</code> Go
|
||||
compiler and tools.
|
||||
For information on how to work on <code>gccgo</code>, a more traditional
|
||||
@@ -119,7 +119,7 @@ Go does not support CentOS 6 on these systems.
|
||||
<h2 id="go14">Install Go compiler binaries</h2>
|
||||
|
||||
<p>
|
||||
The Go toolchain is written in Go. To build it, you need a Go compiler installed.
|
||||
The Go tool chain is written in Go. To build it, you need a Go compiler installed.
|
||||
The scripts that do the initial build of the tools look for an existing Go tool
|
||||
chain in <code>$GOROOT_BOOTSTRAP</code>.
|
||||
If unset, the default value of <code>GOROOT_BOOTSTRAP</code>
|
||||
@@ -127,34 +127,33 @@ is <code>$HOME/go1.4</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
There are many options for the bootstrap toolchain.
|
||||
There are many options for the bootstrap tool chain.
|
||||
After obtaining one, set <code>GOROOT_BOOTSTRAP</code> to the
|
||||
directory containing the unpacked tree.
|
||||
For example, <code>$GOROOT_BOOTSTRAP/bin/go</code> should be
|
||||
the <code>go</code> command binary for the bootstrap toolchain.
|
||||
the <code>go</code> command binary for the bootstrap tool chain.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To use a binary release as a bootstrap toolchain, see
|
||||
To use a binary release as a bootstrap tool chain, see
|
||||
<a href="/dl/">the downloads page</a> or use any other
|
||||
packaged Go distribution.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To build a bootstrap toolchain from source, use
|
||||
To build a bootstrap tool chain from source, use
|
||||
either the git branch <code>release-branch.go1.4</code> or
|
||||
<a href="https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz">go1.4-bootstrap-20171003.tar.gz</a>,
|
||||
<a href="https://storage.googleapis.com/golang/go1.4-bootstrap-20161024.tar.gz">go1.4-bootstrap-20161024.tar.gz</a>,
|
||||
which contains the Go 1.4 source code plus accumulated fixes
|
||||
to keep the tools running on newer operating systems.
|
||||
(Go 1.4 was the last distribution in which the toolchain was written in C.)
|
||||
(Go 1.4 was the last distribution in which the tool chain was written in C.)
|
||||
After unpacking the Go 1.4 source, <code>cd</code> to
|
||||
the <code>src</code> subdirectory, set <code>CGO_ENABLED=0</code> in
|
||||
the environment, and run <code>make.bash</code> (or,
|
||||
the <code>src</code> subdirectory and run <code>make.bash</code> (or,
|
||||
on Windows, <code>make.bat</code>).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To cross-compile a bootstrap toolchain from source, which is
|
||||
To cross-compile a bootstrap tool chain from source, which is
|
||||
necessary on systems Go 1.4 did not target (for
|
||||
example, <code>linux/ppc64le</code>), install Go on a different system
|
||||
and run <a href="/src/bootstrap.bash">bootstrap.bash</a>.
|
||||
@@ -222,7 +221,7 @@ To build without <code>cgo</code>, set the environment variable
|
||||
Change to the directory that will be its parent
|
||||
and make sure the <code>go</code> directory does not exist.
|
||||
Then clone the repository and check out the latest release tag
|
||||
(<code class="versionTag">go1.9</code>, for example):</p>
|
||||
(<code class="versionTag">go1.8.1</code>, for example):</p>
|
||||
|
||||
<pre>
|
||||
$ git clone https://go.googlesource.com/go
|
||||
@@ -410,7 +409,7 @@ New releases are announced on the
|
||||
<a href="//groups.google.com/group/golang-announce">golang-announce</a>
|
||||
mailing list.
|
||||
Each announcement mentions the latest release tag, for instance,
|
||||
<code class="versionTag">go1.9</code>.
|
||||
<code class="versionTag">go1.8.1</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -446,7 +445,6 @@ defaults to the parent of the directory where <code>all.bash</code> was run.
|
||||
There is no need to set this unless you want to switch between multiple
|
||||
local copies of the repository.
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><code>$GOROOT_FINAL</code>
|
||||
<p>
|
||||
@@ -457,14 +455,12 @@ If you want to build the Go tree in one location
|
||||
but move it elsewhere after the build, set
|
||||
<code>$GOROOT_FINAL</code> to the eventual location.
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><code>$GOOS</code> and <code>$GOARCH</code>
|
||||
<p>
|
||||
The name of the target operating system and compilation architecture.
|
||||
These default to the values of <code>$GOHOSTOS</code> and
|
||||
<code>$GOHOSTARCH</code> respectively (described below).
|
||||
</li>
|
||||
|
||||
<p>
|
||||
Choices for <code>$GOOS</code> are
|
||||
@@ -475,9 +471,8 @@ Choices for <code>$GOARCH</code> are
|
||||
<code>amd64</code> (64-bit x86, the most mature port),
|
||||
<code>386</code> (32-bit x86), <code>arm</code> (32-bit ARM), <code>arm64</code> (64-bit ARM),
|
||||
<code>ppc64le</code> (PowerPC 64-bit, little-endian), <code>ppc64</code> (PowerPC 64-bit, big-endian),
|
||||
<code>mips64le</code> (MIPS 64-bit, little-endian), <code>mips64</code> (MIPS 64-bit, big-endian),
|
||||
<code>mipsle</code> (MIPS 32-bit, little-endian), <code>mips</code> (MIPS 32-bit, big-endian), and
|
||||
<code>s390x</code> (IBM System z 64-bit, big-endian).
|
||||
<code>mips64le</code> (MIPS 64-bit, little-endian), and <code>mips64</code> (MIPS 64-bit, big-endian).
|
||||
<code>mipsle</code> (MIPS 32-bit, little-endian), and <code>mips</code> (MIPS 32-bit, big-endian).
|
||||
The valid combinations of <code>$GOOS</code> and <code>$GOARCH</code> are:
|
||||
<table cellpadding="0">
|
||||
<tr>
|
||||
@@ -541,9 +536,6 @@ The valid combinations of <code>$GOOS</code> and <code>$GOARCH</code> are:
|
||||
<td></td><td><code>linux</code></td> <td><code>mips64le</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td><td><code>linux</code></td> <td><code>s390x</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td><td><code>netbsd</code></td> <td><code>386</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -585,7 +577,6 @@ The name of the host operating system and compilation architecture.
|
||||
These default to the local system's operating system and
|
||||
architecture.
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<p>
|
||||
Valid choices are the same as for <code>$GOOS</code> and
|
||||
@@ -604,7 +595,6 @@ directory to your <code>$PATH</code>, so you can use the tools.
|
||||
If <code>$GOBIN</code> is set, the <a href="/cmd/go">go command</a>
|
||||
installs all commands there.
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><code>$GO386</code> (for <code>386</code> only, default is auto-detected
|
||||
if built on either <code>386</code> or <code>amd64</code>, <code>387</code> otherwise)
|
||||
@@ -614,10 +604,9 @@ This controls the code generated by gc to use either the 387 floating-point unit
|
||||
floating point computations.
|
||||
</p>
|
||||
<ul>
|
||||
<li><code>GO386=387</code>: use x87 for floating point operations; should support all x86 chips (Pentium MMX or later).</li>
|
||||
<li><code>GO386=sse2</code>: use SSE2 for floating point operations; has better performance than 387, but only available on Pentium 4/Opteron/Athlon 64 or later.</li>
|
||||
<li><code>GO386=387</code>: use x87 for floating point operations; should support all x86 chips (Pentium MMX or later).
|
||||
<li><code>GO386=sse2</code>: use SSE2 for floating point operations; has better performance than 387, but only available on Pentium 4/Opteron/Athlon 64 or later.
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li><code>$GOARM</code> (for <code>arm</code> only; default is auto-detected if building
|
||||
on the target processor, 6 if not)
|
||||
@@ -626,9 +615,9 @@ This sets the ARM floating point co-processor architecture version the run-time
|
||||
should target. If you are compiling on the target system, its value will be auto-detected.
|
||||
</p>
|
||||
<ul>
|
||||
<li><code>GOARM=5</code>: use software floating point; when CPU doesn't have VFP co-processor</li>
|
||||
<li><code>GOARM=6</code>: use VFPv1 only; default if cross compiling; usually ARM11 or better cores (VFPv2 or better is also supported)</li>
|
||||
<li><code>GOARM=7</code>: use VFPv3; usually Cortex-A cores</li>
|
||||
<li><code>GOARM=5</code>: use software floating point; when CPU doesn't have VFP co-processor
|
||||
<li><code>GOARM=6</code>: use VFPv1 only; default if cross compiling; usually ARM11 or better cores (VFPv2 or better is also supported)
|
||||
<li><code>GOARM=7</code>: use VFPv3; usually Cortex-A cores
|
||||
</ul>
|
||||
<p>
|
||||
If in doubt, leave this variable unset, and adjust it if required
|
||||
@@ -637,17 +626,6 @@ The <a href="//golang.org/wiki/GoArm">GoARM</a> page
|
||||
on the <a href="//golang.org/wiki">Go community wiki</a>
|
||||
contains further details regarding Go's ARM support.
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><code>$GOMIPS</code> (for <code>mips</code> and <code>mipsle</code> only)
|
||||
<p>
|
||||
This sets whether to use floating point instructions.
|
||||
</p>
|
||||
<ul>
|
||||
<li><code>GOMIPS=hardfloat</code>: use floating point instructions (the default)</li>
|
||||
<li><code>GOMIPS=softfloat</code>: use soft floating point</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
<h2 id="download">Download the Go distribution</h2>
|
||||
|
||||
<p>
|
||||
<a href="/dl/" id="start" class="download">
|
||||
<a href="https://golang.org/dl/" id="start" class="download">
|
||||
<span class="big">Download Go</span>
|
||||
<span class="desc">Click here to visit the downloads page</span>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="/dl/" target="_blank">Official binary
|
||||
distributions</a> are available for the FreeBSD (release 10-STABLE and above),
|
||||
<a href="https://golang.org/dl/" target="_blank">Official binary
|
||||
distributions</a> are available for the FreeBSD (release 8-STABLE and above),
|
||||
Linux, Mac OS X (10.8 and above), and Windows operating systems and
|
||||
the 32-bit (<code>386</code>) and 64-bit (<code>amd64</code>) x86 processor
|
||||
architectures.
|
||||
@@ -33,7 +33,7 @@ system and architecture, try
|
||||
<h2 id="requirements">System requirements</h2>
|
||||
|
||||
<p>
|
||||
Go <a href="/dl/">binary distributions</a> are available for these supported operating systems and architectures.
|
||||
Go binary distributions are available for these supported operating systems and architectures.
|
||||
Please ensure your system meets these requirements before proceeding.
|
||||
If your OS or architecture is not on the list, you may be able to
|
||||
<a href="/doc/install/source">install from source</a> or
|
||||
@@ -47,10 +47,10 @@ If your OS or architecture is not on the list, you may be able to
|
||||
<th align="center">Notes</th>
|
||||
</tr>
|
||||
<tr><td colspan="3"><hr></td></tr>
|
||||
<tr><td>FreeBSD 10.3 or later</td> <td>amd64, 386</td> <td>Debian GNU/kFreeBSD not supported</td></tr>
|
||||
<tr valign='top'><td>Linux 2.6.23 or later with glibc</td> <td>amd64, 386, arm, arm64,<br>s390x, ppc64le</td> <td>CentOS/RHEL 5.x not supported.<br>Install from source for other libc.</td></tr>
|
||||
<tr><td>macOS 10.8 or later</td> <td>amd64</td> <td>use the clang or gcc<sup>†</sup> that comes with Xcode<sup>‡</sup> for <code>cgo</code> support</td></tr>
|
||||
<tr><td>Windows XP SP2 or later</td> <td>amd64, 386</td> <td>use MinGW gcc<sup>†</sup>. No need for cygwin or msys.</td></tr>
|
||||
<tr><td>FreeBSD 8-STABLE or later</td> <td>amd64, 386</td> <td>Debian GNU/kFreeBSD not supported</td></tr>
|
||||
<tr><td>Linux 2.6.23 or later with glibc</td> <td>amd64, 386, arm, s390x, ppc64le</td> <td>CentOS/RHEL 5.x not supported</td></tr>
|
||||
<tr><td>Mac OS X 10.8 or later</td> <td>amd64</td> <td>use the clang or gcc<sup>†</sup> that comes with Xcode<sup>‡</sup> for <code>cgo</code> support</td></tr>
|
||||
<tr><td>Windows XP or later</td> <td>amd64, 386</td> <td>use MinGW gcc<sup>†</sup>. No need for cygwin or msys.</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
@@ -77,7 +77,7 @@ first <a href="#uninstall">remove the existing version</a>.
|
||||
<h3 id="tarball">Linux, Mac OS X, and FreeBSD tarballs</h3>
|
||||
|
||||
<p>
|
||||
<a href="/dl/">Download the archive</a>
|
||||
<a href="https://golang.org/dl/">Download the archive</a>
|
||||
and extract it into <code>/usr/local</code>, creating a Go tree in
|
||||
<code>/usr/local/go</code>. For example:
|
||||
</p>
|
||||
@@ -138,7 +138,7 @@ location.
|
||||
<h3 id="osx">Mac OS X package installer</h3>
|
||||
|
||||
<p>
|
||||
<a href="/dl/">Download the package file</a>,
|
||||
<a href="https://golang.org/dl/">Download the package file</a>,
|
||||
open it, and follow the prompts to install the Go tools.
|
||||
The package installs the Go distribution to <code>/usr/local/go</code>.
|
||||
</p>
|
||||
@@ -167,7 +167,7 @@ MSI installer that configures your installation automatically.
|
||||
<h4 id="windows_msi">MSI installer</h4>
|
||||
|
||||
<p>
|
||||
Open the <a href="/dl/">MSI file</a>
|
||||
Open the <a href="https://golang.org/dl/">MSI file</a>
|
||||
and follow the prompts to install the Go tools.
|
||||
By default, the installer puts the Go distribution in <code>c:\Go</code>.
|
||||
</p>
|
||||
@@ -185,7 +185,7 @@ command prompts for the change to take effect.
|
||||
<h4 id="windows_zip">Zip archive</h4>
|
||||
|
||||
<p>
|
||||
<a href="/dl/">Download the zip file</a> and extract it into the directory of your choice (we suggest <code>c:\Go</code>).
|
||||
<a href="https://golang.org/dl/">Download the zip file</a> and extract it into the directory of your choice (we suggest <code>c:\Go</code>).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -222,7 +222,8 @@ and building a simple program, as follows.
|
||||
Create your <a href="code.html#Workspaces">workspace</a> directory,
|
||||
<code class="testUnix">$HOME/go</code><code class="testWindows">%USERPROFILE%\go</code>.
|
||||
(If you'd like to use a different directory,
|
||||
you will need to <a href="https://golang.org/wiki/SettingGOPATH">set the <code>GOPATH</code> environment variable</a>.)
|
||||
you will need to set the <code>GOPATH</code> environment variable;
|
||||
see <a href="code.html#Workspaces">How to Write Go Code</a> for details.)
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -219,5 +219,12 @@ func fixcgo() {
|
||||
// cgo1 and cgo2 don't run on netbsd, srandom has a different signature
|
||||
skipTest("cgo1")
|
||||
skipTest("cgo2")
|
||||
// cgo3 and cgo4 don't run on netbsd, since cgo cannot handle stdout correctly, see issue #10715.
|
||||
skipTest("cgo3")
|
||||
skipTest("cgo4")
|
||||
case "openbsd", "solaris":
|
||||
// cgo3 and cgo4 don't run on openbsd and solaris, since cgo cannot handle stdout correctly, see issue #10715.
|
||||
skipTest("cgo3")
|
||||
skipTest("cgo4")
|
||||
}
|
||||
}
|
||||
|
||||
146
doc/root.html
146
doc/root.html
@@ -6,9 +6,7 @@
|
||||
<div class="left">
|
||||
|
||||
<div id="learn">
|
||||
{{if not $.GoogleCN}}
|
||||
<a class="popout share">Pop-out</a>
|
||||
{{end}}
|
||||
<div class="rootHeading">Try Go</div>
|
||||
<div class="input">
|
||||
<textarea spellcheck="false" class="code">// You can edit this code!
|
||||
@@ -28,10 +26,10 @@ Hello, 世界
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<a class="run" href="#" title="Run this code [shift-enter]">Run</a>
|
||||
{{if not $.GoogleCN}}
|
||||
{{if $.Share}}
|
||||
<a class="share" href="#" title="Share this code">Share</a>
|
||||
<a class="tour" href="//tour.golang.org/" title="Learn Go from your browser">Tour</a>
|
||||
{{end}}
|
||||
<a class="tour" href="//tour.golang.org/" title="Learn Go from your browser">Tour</a>
|
||||
</div>
|
||||
<div class="toys">
|
||||
<select>
|
||||
@@ -58,7 +56,7 @@ simple, reliable, and efficient software.
|
||||
|
||||
<div id="gopher"></div>
|
||||
|
||||
<a href="/dl/" id="start">
|
||||
<a href="https://golang.org/dl/" id="start">
|
||||
<span class="big">Download Go</span>
|
||||
<span class="desc">
|
||||
Binary distributions available for<br>
|
||||
@@ -70,91 +68,85 @@ Linux, Mac OS X, Windows, and more.
|
||||
|
||||
<div style="clear: both"></div>
|
||||
|
||||
{{if not $.GoogleCN}}
|
||||
<div class="left">
|
||||
<div id="video">
|
||||
<div class="rootHeading">Featured video</div>
|
||||
<iframe width="415" height="241" src="//www.youtube.com/embed/ytEkHepK08c" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
|
||||
<div id="video">
|
||||
<div class="rootHeading">Featured video</div>
|
||||
<iframe width="415" height="241" src="//www.youtube.com/embed/ytEkHepK08c" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="right">
|
||||
<div id="blog">
|
||||
<div class="rootHeading">Featured articles</div>
|
||||
<div class="read"><a href="//blog.golang.org/">Read more</a></div>
|
||||
</div>
|
||||
|
||||
<div id="blog">
|
||||
<div class="rootHeading">Featured articles</div>
|
||||
<div class="read"><a href="//blog.golang.org/">Read more</a></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<div style="clear: both;"></div>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
'use strict';
|
||||
<script type="text/javascript">
|
||||
|
||||
window.initFuncs.push(function() {
|
||||
// Set up playground if enabled.
|
||||
if (window.playground) {
|
||||
window.playground({
|
||||
"codeEl": "#learn .code",
|
||||
"outputEl": "#learn .output",
|
||||
"runEl": "#learn .run",
|
||||
"shareEl": "#learn .share",
|
||||
"shareRedirect": "//play.golang.org/p/",
|
||||
"toysEl": "#learn .toys select"
|
||||
});
|
||||
} else {
|
||||
$('#learn').hide()
|
||||
}
|
||||
});
|
||||
function readableTime(t) {
|
||||
var m = ["January", "February", "March", "April", "May", "June", "July",
|
||||
"August", "September", "October", "November", "December"];
|
||||
var p = t.substring(0, t.indexOf("T")).split("-");
|
||||
var d = new Date(p[0], p[1]-1, p[2]);
|
||||
return d.getDate() + " " + m[d.getMonth()] + " " + d.getFullYear();
|
||||
}
|
||||
|
||||
{{if not $.GoogleCN}}
|
||||
function feedLoaded(result) {
|
||||
var blog = document.getElementById("blog");
|
||||
var read = blog.getElementsByClassName("read")[0];
|
||||
for (var i = 0; i < result.length && i < 2; i++) {
|
||||
var entry = result[i];
|
||||
var title = document.createElement("a");
|
||||
title.className = "title";
|
||||
title.href = entry.Link;
|
||||
title.innerHTML = entry.Title;
|
||||
blog.insertBefore(title, read);
|
||||
var extract = document.createElement("div");
|
||||
extract.className = "extract";
|
||||
extract.innerHTML = entry.Summary;
|
||||
blog.insertBefore(extract, read);
|
||||
var when = document.createElement("div");
|
||||
when.className = "when";
|
||||
when.innerHTML = "Published " + readableTime(entry.Time);
|
||||
blog.insertBefore(when, read);
|
||||
}
|
||||
}
|
||||
|
||||
function readableTime(t) {
|
||||
var m = ["January", "February", "March", "April", "May", "June", "July",
|
||||
"August", "September", "October", "November", "December"];
|
||||
var p = t.substring(0, t.indexOf("T")).split("-");
|
||||
var d = new Date(p[0], p[1]-1, p[2]);
|
||||
return d.getDate() + " " + m[d.getMonth()] + " " + d.getFullYear();
|
||||
window.initFuncs.push(function() {
|
||||
// Set up playground if enabled.
|
||||
if (window.playground) {
|
||||
window.playground({
|
||||
"codeEl": "#learn .code",
|
||||
"outputEl": "#learn .output",
|
||||
"runEl": "#learn .run",
|
||||
"shareEl": "#learn .share",
|
||||
"shareRedirect": "//play.golang.org/p/",
|
||||
"toysEl": "#learn .toys select"
|
||||
});
|
||||
} else {
|
||||
$('#learn').hide()
|
||||
}
|
||||
|
||||
window.feedLoaded = function(result) {
|
||||
var blog = document.getElementById("blog");
|
||||
var read = blog.getElementsByClassName("read")[0];
|
||||
for (var i = 0; i < result.length && i < 2; i++) {
|
||||
var entry = result[i];
|
||||
var title = document.createElement("a");
|
||||
title.className = "title";
|
||||
title.href = entry.Link;
|
||||
title.innerHTML = entry.Title;
|
||||
blog.insertBefore(title, read);
|
||||
var extract = document.createElement("div");
|
||||
extract.className = "extract";
|
||||
extract.innerHTML = entry.Summary;
|
||||
blog.insertBefore(extract, read);
|
||||
var when = document.createElement("div");
|
||||
when.className = "when";
|
||||
when.innerHTML = "Published " + readableTime(entry.Time);
|
||||
blog.insertBefore(when, read);
|
||||
}
|
||||
}
|
||||
// Load blog feed.
|
||||
$('<script/>').attr('text', 'text/javascript')
|
||||
.attr('src', '//blog.golang.org/.json?jsonp=feedLoaded')
|
||||
.appendTo('body');
|
||||
|
||||
window.initFuncs.push(function() {
|
||||
// Load blog feed.
|
||||
$('<script/>').attr('text', 'text/javascript')
|
||||
.attr('src', '//blog.golang.org/.json?jsonp=feedLoaded')
|
||||
.appendTo('body');
|
||||
// Set the video at random.
|
||||
var videos = [
|
||||
{h: 241, s: "//www.youtube.com/embed/ytEkHepK08c"}, // Tour of Go
|
||||
{h: 241, s: "//www.youtube.com/embed/f6kdp27TYZs"}, // Concurrency Patterns
|
||||
{h: 233, s: "//player.vimeo.com/video/69237265"} // Simple environment
|
||||
];
|
||||
var v = videos[Math.floor(Math.random()*videos.length)];
|
||||
$('#video iframe').attr('height', v.h).attr('src', v.s);
|
||||
});
|
||||
|
||||
// Set the video at random.
|
||||
var videos = [
|
||||
{h: 241, s: "//www.youtube.com/embed/ytEkHepK08c"}, // Tour of Go
|
||||
{h: 241, s: "//www.youtube.com/embed/f6kdp27TYZs"}, // Concurrency Patterns
|
||||
{h: 233, s: "//player.vimeo.com/video/69237265"} // Simple environment
|
||||
];
|
||||
var v = videos[Math.floor(Math.random()*videos.length)];
|
||||
$('#video iframe').attr('height', v.h).attr('src', v.s);
|
||||
});
|
||||
|
||||
{{end}}
|
||||
})();
|
||||
</script>
|
||||
|
||||
@@ -20,7 +20,7 @@ This mail is delivered to a small security team.
|
||||
Your email will be acknowledged within 24 hours, and you'll receive a more
|
||||
detailed response to your email within 72 hours indicating the next steps in
|
||||
handling your report.
|
||||
For critical problems, you can encrypt your report using our PGP key (listed below).
|
||||
If you would like, you can encrypt your report using our PGP key (listed below).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -118,12 +118,6 @@ If you have any suggestions to improve this policy, please send an email to
|
||||
|
||||
<h3>PGP Key for <a href="mailto:security@golang.org">security@golang.org</a></h3>
|
||||
|
||||
<p>
|
||||
We accept PGP-encrypted email, but the majority of the security team
|
||||
are not regular PGP users so it's somewhat inconvenient. Please only
|
||||
use PGP for critical security reports.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Comment: GPGTools - https://gpgtools.org
|
||||
|
||||
@@ -8,16 +8,16 @@
|
||||
# Consult http://www.iana.org/time-zones for the latest versions.
|
||||
|
||||
# Versions to use.
|
||||
CODE=2017c
|
||||
DATA=2017c
|
||||
CODE=2016j
|
||||
DATA=2016j
|
||||
|
||||
set -e
|
||||
rm -rf work
|
||||
mkdir work
|
||||
cd work
|
||||
mkdir zoneinfo
|
||||
curl -L -O http://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz
|
||||
curl -L -O http://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz
|
||||
curl -O http://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz
|
||||
curl -O http://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz
|
||||
tar xzf tzcode$CODE.tar.gz
|
||||
tar xzf tzdata$DATA.tar.gz
|
||||
|
||||
@@ -42,7 +42,7 @@ zip -0 -r ../../zoneinfo.zip *
|
||||
cd ../..
|
||||
|
||||
echo
|
||||
if [ "$1" = "-work" ]; then
|
||||
if [ "$1" == "-work" ]; then
|
||||
echo Left workspace behind in work/.
|
||||
else
|
||||
rm -rf work
|
||||
|
||||
Binary file not shown.
@@ -21,22 +21,10 @@ import (
|
||||
)
|
||||
|
||||
func run(args ...string) string {
|
||||
if flags := os.Getenv("GOANDROID_ADB_FLAGS"); flags != "" {
|
||||
args = append(strings.Split(flags, " "), args...)
|
||||
}
|
||||
buf := new(bytes.Buffer)
|
||||
cmd := exec.Command("adb", args...)
|
||||
cmd.Stdout = io.MultiWriter(os.Stdout, buf)
|
||||
// If the adb subprocess somehow hangs, go test will kill this wrapper
|
||||
// and wait for our os.Stderr (and os.Stdout) to close as a result.
|
||||
// However, if the os.Stderr (or os.Stdout) file descriptors are
|
||||
// passed on, the hanging adb subprocess will hold them open and
|
||||
// go test will hang forever.
|
||||
//
|
||||
// Avoid that by wrapping stderr, breaking the short circuit and
|
||||
// forcing cmd.Run to use another pipe and goroutine to pass
|
||||
// along stderr from adb.
|
||||
cmd.Stderr = struct{ io.Writer }{os.Stderr}
|
||||
cmd.Stderr = os.Stderr
|
||||
log.Printf("adb %s", strings.Join(args, " "))
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L/nonexist
|
||||
#cgo LDFLAGS: -c
|
||||
|
||||
void test() {
|
||||
xxx; // ERROR HERE
|
||||
@@ -1,161 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package errorstest
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func path(file string) string {
|
||||
return filepath.Join("src", file)
|
||||
}
|
||||
|
||||
func check(t *testing.T, file string) {
|
||||
t.Run(file, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
contents, err := ioutil.ReadFile(path(file))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var errors []*regexp.Regexp
|
||||
for i, line := range bytes.Split(contents, []byte("\n")) {
|
||||
if bytes.HasSuffix(line, []byte("ERROR HERE")) {
|
||||
re := regexp.MustCompile(regexp.QuoteMeta(fmt.Sprintf("%s:%d:", file, i+1)))
|
||||
errors = append(errors, re)
|
||||
continue
|
||||
}
|
||||
|
||||
frags := bytes.SplitAfterN(line, []byte("ERROR HERE: "), 2)
|
||||
if len(frags) == 1 {
|
||||
continue
|
||||
}
|
||||
re, err := regexp.Compile(string(frags[1]))
|
||||
if err != nil {
|
||||
t.Errorf("Invalid regexp after `ERROR HERE: `: %#q", frags[1])
|
||||
continue
|
||||
}
|
||||
errors = append(errors, re)
|
||||
}
|
||||
if len(errors) == 0 {
|
||||
t.Fatalf("cannot find ERROR HERE")
|
||||
}
|
||||
expect(t, file, errors)
|
||||
})
|
||||
}
|
||||
|
||||
func expect(t *testing.T, file string, errors []*regexp.Regexp) {
|
||||
dir, err := ioutil.TempDir("", filepath.Base(t.Name()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
dst := filepath.Join(dir, strings.TrimSuffix(file, ".go"))
|
||||
cmd := exec.Command("go", "build", "-gcflags=-L", "-o="+dst, path(file)) // TODO(gri) no need for -gcflags=-L if go tool is adjusted
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err == nil {
|
||||
t.Errorf("expected cgo to fail but it succeeded")
|
||||
}
|
||||
|
||||
lines := bytes.Split(out, []byte("\n"))
|
||||
for _, re := range errors {
|
||||
found := false
|
||||
for _, line := range lines {
|
||||
if re.Match(line) {
|
||||
t.Logf("found match for %#q: %q", re, line)
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("expected error output to contain %#q", re)
|
||||
}
|
||||
}
|
||||
|
||||
if t.Failed() {
|
||||
t.Logf("actual output:\n%s", out)
|
||||
}
|
||||
}
|
||||
|
||||
func sizeofLongDouble(t *testing.T) int {
|
||||
cmd := exec.Command("go", "run", path("long_double_size.go"))
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("%#q: %v:\n%s", strings.Join(cmd.Args, " "), err, out)
|
||||
}
|
||||
|
||||
i, err := strconv.Atoi(strings.TrimSpace(string(out)))
|
||||
if err != nil {
|
||||
t.Fatalf("long_double_size.go printed invalid size: %s", out)
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
||||
func TestReportsTypeErrors(t *testing.T) {
|
||||
for _, file := range []string{
|
||||
"err1.go",
|
||||
"err2.go",
|
||||
"err3.go",
|
||||
"issue7757.go",
|
||||
"issue8442.go",
|
||||
"issue11097a.go",
|
||||
"issue11097b.go",
|
||||
"issue13129.go",
|
||||
"issue13423.go",
|
||||
"issue13467.go",
|
||||
"issue13635.go",
|
||||
"issue13830.go",
|
||||
"issue16116.go",
|
||||
"issue16591.go",
|
||||
"issue18452.go",
|
||||
"issue18889.go",
|
||||
} {
|
||||
check(t, file)
|
||||
}
|
||||
|
||||
if sizeofLongDouble(t) > 8 {
|
||||
check(t, "err4.go")
|
||||
}
|
||||
}
|
||||
|
||||
func TestToleratesOptimizationFlag(t *testing.T) {
|
||||
for _, cflags := range []string{
|
||||
"",
|
||||
"-O",
|
||||
} {
|
||||
cflags := cflags
|
||||
t.Run(cflags, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cmd := exec.Command("go", "build", path("issue14669.go"))
|
||||
cmd.Env = append(os.Environ(), "CGO_CFLAGS="+cflags)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Errorf("%#q: %v:\n%s", strings.Join(cmd.Args, " "), err, out)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMallocCrashesOnNil(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cmd := exec.Command("go", "run", path("malloc.go"))
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err == nil {
|
||||
t.Logf("%#q:\n%s", strings.Join(cmd.Args, " "), out)
|
||||
t.Fatalf("succeeded unexpectedly")
|
||||
}
|
||||
}
|
||||
@@ -10,5 +10,5 @@ import "C"
|
||||
|
||||
func main() {
|
||||
var x C.ushort
|
||||
x = int(0) // ERROR HERE: C\.ushort
|
||||
x = int(0) // ERROR HERE
|
||||
}
|
||||
24
misc/cgo/errors/issue13635.go
Normal file
24
misc/cgo/errors/issue13635.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright 2015 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// issue 13635: used to output error about C.unsignedchar.
|
||||
// This test tests all such types.
|
||||
|
||||
package pkg
|
||||
|
||||
import "C"
|
||||
|
||||
func main() {
|
||||
var (
|
||||
_ C.uchar = "uc" // ERROR HERE
|
||||
_ C.schar = "sc" // ERROR HERE
|
||||
_ C.ushort = "us" // ERROR HERE
|
||||
_ C.uint = "ui" // ERROR HERE
|
||||
_ C.ulong = "ul" // ERROR HERE
|
||||
_ C.longlong = "ll" // ERROR HERE
|
||||
_ C.ulonglong = "ull" // ERROR HERE
|
||||
_ C.complexfloat = "cf" // ERROR HERE
|
||||
_ C.complexdouble = "cd" // ERROR HERE
|
||||
)
|
||||
}
|
||||
@@ -4,18 +4,20 @@
|
||||
|
||||
// Tests that cgo detects invalid pointer passing at runtime.
|
||||
|
||||
package errorstest
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// ptrTest is the tests without the boilerplate.
|
||||
@@ -341,163 +343,221 @@ var ptrTests = []ptrTest{
|
||||
body: `var b C.char; p := &b; C.f((*C.u)(unsafe.Pointer(&p)))`,
|
||||
fail: false,
|
||||
},
|
||||
{
|
||||
// Test preemption while entering a cgo call. Issue #21306.
|
||||
name: "preempt-during-call",
|
||||
c: `void f() {}`,
|
||||
imports: []string{"runtime", "sync"},
|
||||
body: `var wg sync.WaitGroup; wg.Add(100); for i := 0; i < 100; i++ { go func(i int) { for j := 0; j < 100; j++ { C.f(); runtime.GOMAXPROCS(i) }; wg.Done() }(i) }; wg.Wait()`,
|
||||
fail: false,
|
||||
},
|
||||
{
|
||||
// Test poller deadline with cgocheck=2. Issue #23435.
|
||||
name: "deadline",
|
||||
c: `#define US 10`,
|
||||
imports: []string{"os", "time"},
|
||||
body: `r, _, _ := os.Pipe(); r.SetDeadline(time.Now().Add(C.US * time.Microsecond))`,
|
||||
fail: false,
|
||||
},
|
||||
}
|
||||
|
||||
func TestPointerChecks(t *testing.T) {
|
||||
for _, pt := range ptrTests {
|
||||
pt := pt
|
||||
t.Run(pt.name, func(t *testing.T) {
|
||||
testOne(t, pt)
|
||||
})
|
||||
}
|
||||
func main() {
|
||||
os.Exit(doTests())
|
||||
}
|
||||
|
||||
func testOne(t *testing.T, pt ptrTest) {
|
||||
t.Parallel()
|
||||
|
||||
gopath, err := ioutil.TempDir("", filepath.Base(t.Name()))
|
||||
func doTests() int {
|
||||
gopath, err := ioutil.TempDir("", "cgoerrors")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
return 2
|
||||
}
|
||||
defer os.RemoveAll(gopath)
|
||||
|
||||
src := filepath.Join(gopath, "src")
|
||||
if err := os.Mkdir(src, 0777); err != nil {
|
||||
t.Fatal(err)
|
||||
if err := os.MkdirAll(filepath.Join(gopath, "src"), 0777); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
return 2
|
||||
}
|
||||
|
||||
name := filepath.Join(src, fmt.Sprintf("%s.go", filepath.Base(t.Name())))
|
||||
workers := runtime.NumCPU() + 1
|
||||
|
||||
var wg sync.WaitGroup
|
||||
c := make(chan int)
|
||||
errs := make(chan int)
|
||||
for i := 0; i < workers; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
worker(gopath, c, errs)
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
|
||||
for i := range ptrTests {
|
||||
c <- i
|
||||
}
|
||||
close(c)
|
||||
|
||||
go func() {
|
||||
wg.Wait()
|
||||
close(errs)
|
||||
}()
|
||||
|
||||
tot := 0
|
||||
for e := range errs {
|
||||
tot += e
|
||||
}
|
||||
return tot
|
||||
}
|
||||
|
||||
func worker(gopath string, c, errs chan int) {
|
||||
e := 0
|
||||
for i := range c {
|
||||
if !doOne(gopath, i) {
|
||||
e++
|
||||
}
|
||||
}
|
||||
if e > 0 {
|
||||
errs <- e
|
||||
}
|
||||
}
|
||||
|
||||
func doOne(gopath string, i int) bool {
|
||||
t := &ptrTests[i]
|
||||
|
||||
dir := filepath.Join(gopath, "src", fmt.Sprintf("dir%d", i))
|
||||
if err := os.Mkdir(dir, 0777); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
return false
|
||||
}
|
||||
|
||||
name := filepath.Join(dir, fmt.Sprintf("t%d.go", i))
|
||||
f, err := os.Create(name)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
return false
|
||||
}
|
||||
|
||||
b := bufio.NewWriter(f)
|
||||
fmt.Fprintln(b, `package main`)
|
||||
fmt.Fprintln(b)
|
||||
fmt.Fprintln(b, `/*`)
|
||||
fmt.Fprintln(b, pt.c)
|
||||
fmt.Fprintln(b, t.c)
|
||||
fmt.Fprintln(b, `*/`)
|
||||
fmt.Fprintln(b, `import "C"`)
|
||||
fmt.Fprintln(b)
|
||||
for _, imp := range pt.imports {
|
||||
for _, imp := range t.imports {
|
||||
fmt.Fprintln(b, `import "`+imp+`"`)
|
||||
}
|
||||
if len(pt.imports) > 0 {
|
||||
if len(t.imports) > 0 {
|
||||
fmt.Fprintln(b)
|
||||
}
|
||||
if len(pt.support) > 0 {
|
||||
fmt.Fprintln(b, pt.support)
|
||||
if len(t.support) > 0 {
|
||||
fmt.Fprintln(b, t.support)
|
||||
fmt.Fprintln(b)
|
||||
}
|
||||
fmt.Fprintln(b, `func main() {`)
|
||||
fmt.Fprintln(b, pt.body)
|
||||
fmt.Fprintln(b, t.body)
|
||||
fmt.Fprintln(b, `}`)
|
||||
|
||||
if err := b.Flush(); err != nil {
|
||||
t.Fatalf("flushing %s: %v", name, err)
|
||||
fmt.Fprintf(os.Stderr, "flushing %s: %v\n", name, err)
|
||||
return false
|
||||
}
|
||||
if err := f.Close(); err != nil {
|
||||
t.Fatalf("closing %s: %v", name, err)
|
||||
fmt.Fprintf(os.Stderr, "closing %s: %v\n", name, err)
|
||||
return false
|
||||
}
|
||||
|
||||
for _, e := range pt.extra {
|
||||
if err := ioutil.WriteFile(filepath.Join(src, e.name), []byte(e.contents), 0644); err != nil {
|
||||
t.Fatalf("writing %s: %v", e.name, err)
|
||||
for _, e := range t.extra {
|
||||
if err := ioutil.WriteFile(filepath.Join(dir, e.name), []byte(e.contents), 0644); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "writing %s: %v\n", e.name, err)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
args := func(cmd *exec.Cmd) string {
|
||||
return strings.Join(cmd.Args, " ")
|
||||
}
|
||||
ok := true
|
||||
|
||||
cmd := exec.Command("go", "build")
|
||||
cmd.Dir = src
|
||||
cmd.Dir = dir
|
||||
cmd.Env = addEnv("GOPATH", gopath)
|
||||
buf, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Logf("%#q:\n%s", args(cmd), buf)
|
||||
t.Fatalf("failed to build: %v", err)
|
||||
fmt.Fprintf(os.Stderr, "test %s failed to build: %v\n%s", t.name, err, buf)
|
||||
return false
|
||||
}
|
||||
|
||||
exe := filepath.Join(src, filepath.Base(src))
|
||||
exe := filepath.Join(dir, filepath.Base(dir))
|
||||
cmd = exec.Command(exe)
|
||||
cmd.Dir = src
|
||||
cmd.Dir = dir
|
||||
|
||||
if pt.expensive {
|
||||
if t.expensive {
|
||||
cmd.Env = cgocheckEnv("1")
|
||||
buf, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Logf("%#q:\n%s", args(cmd), buf)
|
||||
if pt.fail {
|
||||
t.Fatalf("test marked expensive, but failed when not expensive: %v", err)
|
||||
var errbuf bytes.Buffer
|
||||
if t.fail {
|
||||
fmt.Fprintf(&errbuf, "test %s marked expensive but failed when not expensive: %v\n", t.name, err)
|
||||
} else {
|
||||
t.Errorf("failed unexpectedly with GODEBUG=cgocheck=1: %v", err)
|
||||
fmt.Fprintf(&errbuf, "test %s failed unexpectedly with GODEBUG=cgocheck=1: %v\n", t.name, err)
|
||||
}
|
||||
reportTestOutput(&errbuf, t.name, buf)
|
||||
os.Stderr.Write(errbuf.Bytes())
|
||||
ok = false
|
||||
}
|
||||
|
||||
cmd = exec.Command(exe)
|
||||
cmd.Dir = src
|
||||
cmd.Dir = dir
|
||||
}
|
||||
|
||||
if pt.expensive {
|
||||
if t.expensive {
|
||||
cmd.Env = cgocheckEnv("2")
|
||||
}
|
||||
|
||||
buf, err = cmd.CombinedOutput()
|
||||
if pt.fail {
|
||||
|
||||
if t.fail {
|
||||
if err == nil {
|
||||
t.Logf("%#q:\n%s", args(cmd), buf)
|
||||
t.Fatalf("did not fail as expected")
|
||||
var errbuf bytes.Buffer
|
||||
fmt.Fprintf(&errbuf, "test %s did not fail as expected\n", t.name)
|
||||
reportTestOutput(&errbuf, t.name, buf)
|
||||
os.Stderr.Write(errbuf.Bytes())
|
||||
ok = false
|
||||
} else if !bytes.Contains(buf, []byte("Go pointer")) {
|
||||
t.Logf("%#q:\n%s", args(cmd), buf)
|
||||
t.Fatalf("did not print expected error (failed with %v)", err)
|
||||
var errbuf bytes.Buffer
|
||||
fmt.Fprintf(&errbuf, "test %s output does not contain expected error (failed with %v)\n", t.name, err)
|
||||
reportTestOutput(&errbuf, t.name, buf)
|
||||
os.Stderr.Write(errbuf.Bytes())
|
||||
ok = false
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
t.Logf("%#q:\n%s", args(cmd), buf)
|
||||
t.Fatalf("failed unexpectedly: %v", err)
|
||||
var errbuf bytes.Buffer
|
||||
fmt.Fprintf(&errbuf, "test %s failed unexpectedly: %v\n", t.name, err)
|
||||
reportTestOutput(&errbuf, t.name, buf)
|
||||
os.Stderr.Write(errbuf.Bytes())
|
||||
ok = false
|
||||
}
|
||||
|
||||
if !pt.expensive {
|
||||
if !t.expensive && ok {
|
||||
// Make sure it passes with the expensive checks.
|
||||
cmd := exec.Command(exe)
|
||||
cmd.Dir = src
|
||||
cmd.Dir = dir
|
||||
cmd.Env = cgocheckEnv("2")
|
||||
buf, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Logf("%#q:\n%s", args(cmd), buf)
|
||||
t.Fatalf("failed unexpectedly with expensive checks: %v", err)
|
||||
var errbuf bytes.Buffer
|
||||
fmt.Fprintf(&errbuf, "test %s failed unexpectedly with expensive checks: %v\n", t.name, err)
|
||||
reportTestOutput(&errbuf, t.name, buf)
|
||||
os.Stderr.Write(errbuf.Bytes())
|
||||
ok = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if pt.fail {
|
||||
if t.fail && ok {
|
||||
cmd = exec.Command(exe)
|
||||
cmd.Dir = src
|
||||
cmd.Dir = dir
|
||||
cmd.Env = cgocheckEnv("0")
|
||||
buf, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Logf("%#q:\n%s", args(cmd), buf)
|
||||
t.Fatalf("failed unexpectedly with GODEBUG=cgocheck=0: %v", err)
|
||||
var errbuf bytes.Buffer
|
||||
fmt.Fprintf(&errbuf, "test %s failed unexpectedly with GODEBUG=cgocheck=0: %v\n", t.name, err)
|
||||
reportTestOutput(&errbuf, t.name, buf)
|
||||
os.Stderr.Write(errbuf.Bytes())
|
||||
ok = false
|
||||
}
|
||||
}
|
||||
|
||||
return ok
|
||||
}
|
||||
|
||||
func reportTestOutput(w io.Writer, name string, buf []byte) {
|
||||
fmt.Fprintf(w, "=== test %s output ===\n", name)
|
||||
fmt.Fprintf(w, "%s", buf)
|
||||
fmt.Fprintf(w, "=== end of test %s output ===\n", name)
|
||||
}
|
||||
|
||||
func cgocheckEnv(val string) []string {
|
||||
@@ -1,15 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
/*
|
||||
long double x = 0;
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func main() {
|
||||
_ = C.x // ERROR HERE
|
||||
_ = C.x
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package p
|
||||
|
||||
/*
|
||||
static int transform(int x) { return x; }
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func F() {
|
||||
var x rune = '✈'
|
||||
var _ rune = C.transform(x) // ERROR HERE: C\.int
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// Copyright 2015 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// issue 13635: used to output error about C.unsignedchar.
|
||||
// This test tests all such types.
|
||||
|
||||
package pkg
|
||||
|
||||
import "C"
|
||||
|
||||
func main() {
|
||||
var (
|
||||
_ C.uchar = "uc" // ERROR HERE: C\.uchar
|
||||
_ C.schar = "sc" // ERROR HERE: C\.schar
|
||||
_ C.ushort = "us" // ERROR HERE: C\.ushort
|
||||
_ C.uint = "ui" // ERROR HERE: C\.uint
|
||||
_ C.ulong = "ul" // ERROR HERE: C\.ulong
|
||||
_ C.longlong = "ll" // ERROR HERE: C\.longlong
|
||||
_ C.ulonglong = "ull" // ERROR HERE: C\.ulonglong
|
||||
_ C.complexfloat = "cf" // ERROR HERE: C\.complexfloat
|
||||
_ C.complexdouble = "cd" // ERROR HERE: C\.complexdouble
|
||||
)
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Issue 18452: show pos info in undefined name errors
|
||||
|
||||
package p
|
||||
|
||||
import (
|
||||
"C"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func a() {
|
||||
fmt.Println("Hello, world!")
|
||||
C.function_that_does_not_exist() // ERROR HERE
|
||||
C.pi // ERROR HERE
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package main
|
||||
|
||||
import "C"
|
||||
|
||||
func main() {
|
||||
_ = C.malloc // ERROR HERE
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
/*
|
||||
const int sizeofLongDouble = sizeof(long double);
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println(C.sizeofLongDouble)
|
||||
}
|
||||
73
misc/cgo/errors/test.bash
Executable file
73
misc/cgo/errors/test.bash
Executable file
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2013 The Go Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
check() {
|
||||
file=$1
|
||||
line=$(grep -n 'ERROR HERE' $file | sed 's/:.*//')
|
||||
if [ "$line" = "" ]; then
|
||||
echo 1>&2 misc/cgo/errors/test.bash: BUG: cannot find ERROR HERE in $file
|
||||
exit 1
|
||||
fi
|
||||
expect $file $file:$line:
|
||||
}
|
||||
|
||||
expect() {
|
||||
file=$1
|
||||
shift
|
||||
if go build $file >errs 2>&1; then
|
||||
echo 1>&2 misc/cgo/errors/test.bash: BUG: expected cgo to fail on $file but it succeeded
|
||||
exit 1
|
||||
fi
|
||||
if ! test -s errs; then
|
||||
echo 1>&2 misc/cgo/errors/test.bash: BUG: expected error output for $file but saw none
|
||||
exit 1
|
||||
fi
|
||||
for error; do
|
||||
if ! fgrep $error errs >/dev/null 2>&1; then
|
||||
echo 1>&2 misc/cgo/errors/test.bash: BUG: expected error output for $file to contain \"$error\" but saw:
|
||||
cat 1>&2 errs
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
check err1.go
|
||||
check err2.go
|
||||
check err3.go
|
||||
check issue7757.go
|
||||
check issue8442.go
|
||||
check issue11097a.go
|
||||
check issue11097b.go
|
||||
expect issue13129.go C.ushort
|
||||
check issue13423.go
|
||||
expect issue13635.go C.uchar C.schar C.ushort C.uint C.ulong C.longlong C.ulonglong C.complexfloat C.complexdouble
|
||||
check issue13830.go
|
||||
check issue16116.go
|
||||
check issue16591.go
|
||||
|
||||
if ! go build issue14669.go; then
|
||||
exit 1
|
||||
fi
|
||||
if ! CGO_CFLAGS="-O" go build issue14669.go; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! go run ptr.go; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# The malloc.go test should crash.
|
||||
rm -f malloc.out
|
||||
if go run malloc.go >malloc.out 2>&1; then
|
||||
echo '`go run malloc.go` succeeded unexpectedly'
|
||||
cat malloc.out
|
||||
rm -f malloc.out
|
||||
exit 1
|
||||
fi
|
||||
rm -f malloc.out
|
||||
|
||||
rm -rf errs _obj
|
||||
exit 0
|
||||
@@ -12,7 +12,7 @@ FC=$1
|
||||
goos=$(go env GOOS)
|
||||
|
||||
libext="so"
|
||||
if [ "$goos" = "darwin" ]; then
|
||||
if [ "$goos" == "darwin" ]; then
|
||||
libext="dylib"
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// cmpout -tags=use_go_run
|
||||
// cmpout
|
||||
|
||||
// Copyright 2010 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
@@ -11,10 +11,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"."
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"."
|
||||
)
|
||||
|
||||
const MAXDIM = 100
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// cmpout -tags=use_go_run
|
||||
// cmpout
|
||||
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// cmpout -tags=use_go_run
|
||||
// cmpout
|
||||
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// cmpout -tags=use_go_run
|
||||
// cmpout
|
||||
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
|
||||
@@ -27,7 +27,6 @@ func testBuildID(t *testing.T) {
|
||||
defer f.Close()
|
||||
|
||||
c := 0
|
||||
sections:
|
||||
for i, s := range f.Sections {
|
||||
if s.Type != elf.SHT_NOTE {
|
||||
continue
|
||||
@@ -48,7 +47,7 @@ sections:
|
||||
|
||||
if len(d) < 12 {
|
||||
t.Logf("note section %d too short (%d < 12)", i, len(d))
|
||||
continue sections
|
||||
continue
|
||||
}
|
||||
|
||||
namesz := f.ByteOrder.Uint32(d)
|
||||
@@ -60,7 +59,7 @@ sections:
|
||||
|
||||
if int(12+an+ad) > len(d) {
|
||||
t.Logf("note section %d too short for header (%d < 12 + align(%d,4) + align(%d,4))", i, len(d), namesz, descsz)
|
||||
continue sections
|
||||
continue
|
||||
}
|
||||
|
||||
// 3 == NT_GNU_BUILD_ID
|
||||
|
||||
@@ -76,16 +76,5 @@ func TestThreadLock(t *testing.T) { testThreadLockFunc(t) }
|
||||
func TestCheckConst(t *testing.T) { testCheckConst(t) }
|
||||
func Test17537(t *testing.T) { test17537(t) }
|
||||
func Test18126(t *testing.T) { test18126(t) }
|
||||
func Test20369(t *testing.T) { test20369(t) }
|
||||
func Test18720(t *testing.T) { test18720(t) }
|
||||
func Test20266(t *testing.T) { test20266(t) }
|
||||
func Test20129(t *testing.T) { test20129(t) }
|
||||
func Test20910(t *testing.T) { test20910(t) }
|
||||
func Test21708(t *testing.T) { test21708(t) }
|
||||
func Test21809(t *testing.T) { test21809(t) }
|
||||
func Test6907(t *testing.T) { test6907(t) }
|
||||
func Test6907Go(t *testing.T) { test6907Go(t) }
|
||||
func Test21897(t *testing.T) { test21897(t) }
|
||||
func Test22906(t *testing.T) { test22906(t) }
|
||||
|
||||
func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cgotest
|
||||
|
||||
/*
|
||||
#define HELLO "hello"
|
||||
#define WORLD "world"
|
||||
#define HELLO_WORLD HELLO "\000" WORLD
|
||||
|
||||
struct foo { char c; };
|
||||
#define SIZE_OF(x) sizeof(x)
|
||||
#define SIZE_OF_FOO SIZE_OF(struct foo)
|
||||
#define VAR1 VAR
|
||||
#define VAR var
|
||||
int var = 5;
|
||||
|
||||
#define ADDR &var
|
||||
|
||||
#define CALL fn()
|
||||
int fn(void) {
|
||||
return ++var;
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
import "testing"
|
||||
|
||||
func test18720(t *testing.T) {
|
||||
if got, want := C.HELLO_WORLD, "hello\000world"; got != want {
|
||||
t.Errorf("C.HELLO_WORLD == %q, expected %q", got, want)
|
||||
}
|
||||
|
||||
if got, want := C.VAR1, C.int(5); got != want {
|
||||
t.Errorf("C.VAR1 == %v, expected %v", got, want)
|
||||
}
|
||||
|
||||
if got, want := *C.ADDR, C.int(5); got != want {
|
||||
t.Errorf("*C.ADDR == %v, expected %v", got, want)
|
||||
}
|
||||
|
||||
if got, want := C.CALL, C.int(6); got != want {
|
||||
t.Errorf("C.CALL == %v, expected %v", got, want)
|
||||
}
|
||||
|
||||
if got, want := C.CALL, C.int(7); got != want {
|
||||
t.Errorf("C.CALL == %v, expected %v", got, want)
|
||||
}
|
||||
|
||||
// Issue 20125.
|
||||
if got, want := C.SIZE_OF_FOO, 1; got != want {
|
||||
t.Errorf("C.SIZE_OF_FOO == %v, expected %v", got, want)
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cgotest
|
||||
|
||||
/*
|
||||
int issue20129 = 0;
|
||||
typedef void issue20129Void;
|
||||
issue20129Void issue20129Foo() {
|
||||
issue20129 = 1;
|
||||
}
|
||||
typedef issue20129Void issue20129Void2;
|
||||
issue20129Void2 issue20129Bar() {
|
||||
issue20129 = 2;
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
import "testing"
|
||||
|
||||
func test20129(t *testing.T) {
|
||||
if C.issue20129 != 0 {
|
||||
t.Fatal("test is broken")
|
||||
}
|
||||
C.issue20129Foo()
|
||||
if C.issue20129 != 1 {
|
||||
t.Errorf("got %v but expected %v", C.issue20129, 1)
|
||||
}
|
||||
C.issue20129Bar()
|
||||
if C.issue20129 != 2 {
|
||||
t.Errorf("got %v but expected %v", C.issue20129, 2)
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Issue 20266: use -I with a relative path.
|
||||
|
||||
package cgotest
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -I issue20266 -Iissue20266 -Ddef20266
|
||||
#include "issue20266.h"
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import "testing"
|
||||
|
||||
func test20266(t *testing.T) {
|
||||
if got, want := C.issue20266, 20266; got != want {
|
||||
t.Errorf("got %d, want %d", got, want)
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
#define issue20266 20266
|
||||
|
||||
#ifndef def20266
|
||||
#error "expected def20266 to be defined"
|
||||
#endif
|
||||
@@ -1,20 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cgotest
|
||||
|
||||
/*
|
||||
#define UINT64_MAX 18446744073709551615ULL
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"math"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func test20369(t *testing.T) {
|
||||
if C.UINT64_MAX != math.MaxUint64 {
|
||||
t.Fatalf("got %v, want %v", uint64(C.UINT64_MAX), uint64(math.MaxUint64))
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "_cgo_export.h"
|
||||
|
||||
/* Test calling a Go function with multiple return values. */
|
||||
|
||||
void
|
||||
callMulti(void)
|
||||
{
|
||||
struct multi_return result = multi();
|
||||
assert(strcmp(result.r0, "multi") == 0);
|
||||
assert(result.r1 == 0);
|
||||
free(result.r0);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cgotest
|
||||
|
||||
//void callMulti(void);
|
||||
import "C"
|
||||
|
||||
import "testing"
|
||||
|
||||
//export multi
|
||||
func multi() (*C.char, C.int) {
|
||||
return C.CString("multi"), 0
|
||||
}
|
||||
|
||||
func test20910(t *testing.T) {
|
||||
C.callMulti()
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Fail to guess the kind of the constant "x".
|
||||
// No runtime test; just make sure it compiles.
|
||||
|
||||
package cgotest
|
||||
|
||||
// const int x = 42;
|
||||
import "C"
|
||||
|
||||
var issue21668_X = C.x
|
||||
@@ -1,16 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cgotest
|
||||
|
||||
// #include <stdint.h>
|
||||
// #define CAST_TO_INT64 (int64_t)(-1)
|
||||
import "C"
|
||||
import "testing"
|
||||
|
||||
func test21708(t *testing.T) {
|
||||
if got, want := C.CAST_TO_INT64, -1; got != want {
|
||||
t.Errorf("C.CAST_TO_INT64 == %v, expected %v", got, want)
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cgotest
|
||||
|
||||
// Issue 21809. Compile C `typedef` to go type aliases.
|
||||
|
||||
// typedef long MySigned_t;
|
||||
// /* tests alias-to-alias */
|
||||
// typedef MySigned_t MySigned2_t;
|
||||
//
|
||||
// long takes_long(long x) { return x * x; }
|
||||
// MySigned_t takes_typedef(MySigned_t x) { return x * x; }
|
||||
import "C"
|
||||
|
||||
import "testing"
|
||||
|
||||
func test21809(t *testing.T) {
|
||||
longVar := C.long(3)
|
||||
typedefVar := C.MySigned_t(4)
|
||||
typedefTypedefVar := C.MySigned2_t(5)
|
||||
|
||||
// all three should be considered identical to `long`
|
||||
if ret := C.takes_long(longVar); ret != 9 {
|
||||
t.Errorf("got %v but expected %v", ret, 9)
|
||||
}
|
||||
if ret := C.takes_long(typedefVar); ret != 16 {
|
||||
t.Errorf("got %v but expected %v", ret, 16)
|
||||
}
|
||||
if ret := C.takes_long(typedefTypedefVar); ret != 25 {
|
||||
t.Errorf("got %v but expected %v", ret, 25)
|
||||
}
|
||||
|
||||
// They should also be identical to the typedef'd type
|
||||
if ret := C.takes_typedef(longVar); ret != 9 {
|
||||
t.Errorf("got %v but expected %v", ret, 9)
|
||||
}
|
||||
if ret := C.takes_typedef(typedefVar); ret != 16 {
|
||||
t.Errorf("got %v but expected %v", ret, 16)
|
||||
}
|
||||
if ret := C.takes_typedef(typedefTypedefVar); ret != 25 {
|
||||
t.Errorf("got %v but expected %v", ret, 25)
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user