mirror of
https://github.com/golang/go.git
synced 2026-01-30 15:42:04 +03:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e933ed7c0 | ||
|
|
78d024a588 | ||
|
|
09fc3cc5df | ||
|
|
17a48e0a00 |
11
.github/ISSUE_TEMPLATE
vendored
11
.github/ISSUE_TEMPLATE
vendored
@@ -1,21 +1,20 @@
|
||||
Please answer these questions before submitting your issue. Thanks!
|
||||
|
||||
### What version of Go are you using (`go version`)?
|
||||
1. What version of Go are you using (`go version`)?
|
||||
|
||||
|
||||
### What operating system and processor architecture are you using (`go env`)?
|
||||
2. What operating system and processor architecture are you using (`go env`)?
|
||||
|
||||
|
||||
### What did you do?
|
||||
|
||||
3. 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.
|
||||
|
||||
|
||||
### What did you expect to see?
|
||||
4. What did you expect to see?
|
||||
|
||||
|
||||
### What did you see instead?
|
||||
5. What did you see instead?
|
||||
|
||||
|
||||
|
||||
14
.github/SUPPORT
vendored
14
.github/SUPPORT
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
|
||||
48
.gitignore
vendored
48
.gitignore
vendored
@@ -18,28 +18,28 @@ _cgo_*
|
||||
_obj
|
||||
_test
|
||||
_testmain.go
|
||||
build.out
|
||||
test.out
|
||||
doc/articles/wiki/*.bin
|
||||
misc/cgo/life/run.out
|
||||
misc/cgo/stdio/run.out
|
||||
misc/cgo/testso/main
|
||||
src/cmd/cgo/zdefaultcc.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
|
||||
src/unicode/maketables
|
||||
src/*.*/
|
||||
test/pass.out
|
||||
test/run.out
|
||||
test/times.out
|
||||
test/garbage/*.out
|
||||
goinstall.log
|
||||
last-change
|
||||
VERSION.cache
|
||||
|
||||
/VERSION.cache
|
||||
/bin/
|
||||
/build.out
|
||||
/doc/articles/wiki/*.bin
|
||||
/goinstall.log
|
||||
/last-change
|
||||
/misc/cgo/life/run.out
|
||||
/misc/cgo/stdio/run.out
|
||||
/misc/cgo/testso/main
|
||||
/pkg/
|
||||
/src/*.*/
|
||||
/src/cmd/cgo/zdefaultcc.go
|
||||
/src/cmd/go/internal/cfg/zdefaultcc.go
|
||||
/src/cmd/go/internal/cfg/zosarch.go
|
||||
/src/cmd/internal/objabi/zbootstrap.go
|
||||
/src/go/build/zcgo.go
|
||||
/src/go/doc/headscan
|
||||
/src/runtime/internal/sys/zversion.go
|
||||
/src/unicode/maketables
|
||||
/test.out
|
||||
/test/garbage/*.out
|
||||
/test/pass.out
|
||||
/test/run.out
|
||||
/test/times.out
|
||||
bin/
|
||||
pkg/
|
||||
|
||||
@@ -4,19 +4,10 @@ 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.
|
||||
|
||||
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?
|
||||
@@ -24,16 +15,19 @@ Otherwise, when filing an issue, make sure to answer these five questions:
|
||||
4. What did you expect to see?
|
||||
5. What did you see instead?
|
||||
|
||||
For change proposals, see [Proposing Changes To Go](https://github.com/golang/proposal/).
|
||||
General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker.
|
||||
The gophers there will answer or ask you to file an issue if you've tripped over a bug.
|
||||
|
||||
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.
|
||||
|
||||
415
CONTRIBUTORS
415
CONTRIBUTORS
File diff suppressed because it is too large
Load Diff
56
README.md
56
README.md
@@ -4,42 +4,40 @@ 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].*
|
||||
|
||||
For documentation about how to install and use Go,
|
||||
visit https://golang.org/ or load doc/install-source.html
|
||||
in your web browser.
|
||||
|
||||
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.
|
||||
|
||||
Unless otherwise noted, the Go source files are distributed under the
|
||||
BSD-style license found in the LICENSE file.
|
||||
|
||||
### Download and Install
|
||||
|
||||
#### Binary Distributions
|
||||
|
||||
Official binary distributions are available at https://golang.org/dl/.
|
||||
|
||||
After downloading a binary release, visit https://golang.org/doc/install
|
||||
or load doc/install.html in your web browser for installation
|
||||
instructions.
|
||||
|
||||
#### Install From Source
|
||||
|
||||
If a binary distribution is not available for your combination of
|
||||
operating system and architecture, visit
|
||||
https://golang.org/doc/install/source or load doc/install-source.html
|
||||
in your web browser for source installation instructions.
|
||||
|
||||
### Contributing
|
||||
|
||||
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 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.
|
||||
##### Note that we do not accept pull requests and that we use the issue tracker for bug reports and proposals only. Please ask questions on https://forum.golangbridge.org or https://groups.google.com/forum/#!forum/golang-nuts.
|
||||
|
||||
[rf]: https://reneefrench.blogspot.com/
|
||||
[cc3-by]: https://creativecommons.org/licenses/by/3.0/
|
||||
Unless otherwise noted, the Go source files are distributed
|
||||
under the BSD-style license found in the LICENSE file.
|
||||
|
||||
--
|
||||
|
||||
## Binary Distribution Notes
|
||||
|
||||
If you have just untarred a binary Go distribution, you need to set
|
||||
the environment variable $GOROOT to the full path of the go
|
||||
directory (the one containing this file). You can omit the
|
||||
variable if you unpack it into /usr/local/go, or if you rebuild
|
||||
from sources by running all.bash (see doc/install-source.html).
|
||||
You should also add the Go binary directory $GOROOT/bin
|
||||
to your shell's path.
|
||||
|
||||
For example, if you extracted the tar file into $HOME/go, you might
|
||||
put the following in your .profile:
|
||||
|
||||
export GOROOT=$HOME/go
|
||||
export PATH=$PATH:$GOROOT/bin
|
||||
|
||||
See https://golang.org/doc/install or doc/install.html for more details.
|
||||
|
||||
199
api/except.txt
199
api/except.txt
@@ -1,108 +1,23 @@
|
||||
pkg encoding/json, method (*RawMessage) MarshalJSON() ([]uint8, error)
|
||||
pkg math/big, type Word uintptr
|
||||
pkg net, func ListenUnixgram(string, *UnixAddr) (*UDPConn, error)
|
||||
pkg syscall (darwin-386), func Fchflags(string, int) error
|
||||
pkg syscall (darwin-386-cgo), func Fchflags(string, int) error
|
||||
pkg syscall (darwin-amd64), func Fchflags(string, int) error
|
||||
pkg syscall (darwin-amd64-cgo), func Fchflags(string, int) error
|
||||
pkg syscall (freebsd-386), func Fchflags(string, int) error
|
||||
pkg syscall (freebsd-amd64), func Fchflags(string, int) error
|
||||
pkg syscall (freebsd-arm), func Fchflags(string, int) error
|
||||
pkg syscall (freebsd-arm-cgo), func Fchflags(string, int) error
|
||||
pkg syscall (netbsd-arm), func Fchflags(string, int) error
|
||||
pkg syscall (netbsd-arm-cgo), func Fchflags(string, int) error
|
||||
pkg testing, func RegisterCover(Cover)
|
||||
pkg text/template/parse, type DotNode bool
|
||||
pkg text/template/parse, type Node interface { Copy, String, Type }
|
||||
pkg os (linux-arm), const O_SYNC = 4096
|
||||
pkg os (linux-arm-cgo), const O_SYNC = 4096
|
||||
pkg syscall (darwin-386), const ImplementsGetwd = false
|
||||
pkg syscall (darwin-386), func Fchflags(string, int) error
|
||||
pkg syscall (darwin-386-cgo), const ImplementsGetwd = false
|
||||
pkg syscall (darwin-386-cgo), func Fchflags(string, int) error
|
||||
pkg syscall (darwin-amd64), const ImplementsGetwd = false
|
||||
pkg syscall (darwin-amd64), func Fchflags(string, int) error
|
||||
pkg syscall (darwin-amd64-cgo), const ImplementsGetwd = false
|
||||
pkg syscall (darwin-amd64-cgo), func Fchflags(string, int) error
|
||||
pkg syscall (freebsd-386), const AF_MAX = 38
|
||||
pkg syscall (freebsd-386), const DLT_MATCHING_MAX = 242
|
||||
pkg syscall (freebsd-386), const ELAST = 94
|
||||
pkg syscall (freebsd-386), const O_CLOEXEC = 0
|
||||
pkg syscall (freebsd-386), func Fchflags(string, int) error
|
||||
pkg syscall (freebsd-386-cgo), const AF_MAX = 38
|
||||
pkg syscall (freebsd-386-cgo), const DLT_MATCHING_MAX = 242
|
||||
pkg syscall (freebsd-386-cgo), const ELAST = 94
|
||||
pkg syscall (freebsd-386-cgo), const O_CLOEXEC = 0
|
||||
pkg syscall (freebsd-amd64), const AF_MAX = 38
|
||||
pkg syscall (freebsd-amd64), const DLT_MATCHING_MAX = 242
|
||||
pkg syscall (freebsd-amd64), const ELAST = 94
|
||||
pkg syscall (freebsd-amd64), const O_CLOEXEC = 0
|
||||
pkg syscall (freebsd-amd64), func Fchflags(string, int) error
|
||||
pkg syscall (freebsd-amd64-cgo), const AF_MAX = 38
|
||||
pkg syscall (freebsd-amd64-cgo), const DLT_MATCHING_MAX = 242
|
||||
pkg syscall (freebsd-amd64-cgo), const ELAST = 94
|
||||
pkg syscall (freebsd-amd64-cgo), const O_CLOEXEC = 0
|
||||
pkg syscall (freebsd-arm), const AF_MAX = 38
|
||||
pkg syscall (freebsd-arm), const BIOCGRTIMEOUT = 1074545262
|
||||
pkg syscall (freebsd-arm), const BIOCSRTIMEOUT = 2148287085
|
||||
pkg syscall (freebsd-arm), const ELAST = 94
|
||||
pkg syscall (freebsd-arm), const O_CLOEXEC = 0
|
||||
pkg syscall (freebsd-arm), const SIOCAIFADDR = 2151967019
|
||||
pkg syscall (freebsd-arm), const SIOCGIFSTATUS = 3274991931
|
||||
pkg syscall (freebsd-arm), const SIOCSIFPHYADDR = 2151967046
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_FCNTLS_GET = 537
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_FCNTLS_GET ideal-int
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_FCNTLS_LIMIT = 536
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_FCNTLS_LIMIT ideal-int
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_IOCTLS_GET = 535
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_IOCTLS_GET ideal-int
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_IOCTLS_LIMIT = 534
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_IOCTLS_LIMIT ideal-int
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_RIGHTS_GET = 515
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_RIGHTS_GET ideal-int
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_RIGHTS_LIMIT = 533
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_RIGHTS_LIMIT ideal-int
|
||||
pkg syscall (freebsd-arm), const SizeofBpfHdr = 24
|
||||
pkg syscall (freebsd-arm), const SizeofIfData = 88
|
||||
pkg syscall (freebsd-arm), const SizeofIfMsghdr = 104
|
||||
pkg syscall (freebsd-arm), const SizeofSockaddrDatalink = 56
|
||||
pkg syscall (freebsd-arm), const SizeofSockaddrUnix = 108
|
||||
pkg syscall (freebsd-arm), const TIOCTIMESTAMP = 1074558041
|
||||
pkg syscall (freebsd-arm), func Fchflags(string, int) error
|
||||
pkg syscall (freebsd-arm), type BpfHdr struct, Pad_cgo_0 [2]uint8
|
||||
pkg syscall (freebsd-arm), type RawSockaddrDatalink struct, Pad_cgo_0 [2]uint8
|
||||
pkg syscall (freebsd-arm), type RawSockaddrUnix struct, Pad_cgo_0 [2]uint8
|
||||
pkg syscall (freebsd-arm), type Stat_t struct, Pad_cgo_0 [4]uint8
|
||||
pkg syscall (freebsd-arm-cgo), const AF_MAX = 38
|
||||
pkg syscall (freebsd-arm-cgo), const BIOCGRTIMEOUT = 1074545262
|
||||
pkg syscall (freebsd-arm-cgo), const BIOCSRTIMEOUT = 2148287085
|
||||
pkg syscall (freebsd-arm-cgo), const ELAST = 94
|
||||
pkg syscall (freebsd-arm-cgo), const O_CLOEXEC = 0
|
||||
pkg syscall (freebsd-arm-cgo), const SIOCAIFADDR = 2151967019
|
||||
pkg syscall (freebsd-arm-cgo), const SIOCGIFSTATUS = 3274991931
|
||||
pkg syscall (freebsd-arm-cgo), const SIOCSIFPHYADDR = 2151967046
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_FCNTLS_GET = 537
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_FCNTLS_GET ideal-int
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_FCNTLS_LIMIT = 536
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_FCNTLS_LIMIT ideal-int
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_IOCTLS_GET = 535
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_IOCTLS_GET ideal-int
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_IOCTLS_LIMIT = 534
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_IOCTLS_LIMIT ideal-int
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_RIGHTS_GET = 515
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_RIGHTS_GET ideal-int
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_RIGHTS_LIMIT = 533
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_RIGHTS_LIMIT ideal-int
|
||||
pkg syscall (freebsd-arm-cgo), const SizeofBpfHdr = 24
|
||||
pkg syscall (freebsd-arm-cgo), const SizeofIfData = 88
|
||||
pkg syscall (freebsd-arm-cgo), const SizeofIfMsghdr = 104
|
||||
pkg syscall (freebsd-arm-cgo), const SizeofSockaddrDatalink = 56
|
||||
pkg syscall (freebsd-arm-cgo), const SizeofSockaddrUnix = 108
|
||||
pkg syscall (freebsd-arm-cgo), const TIOCTIMESTAMP = 1074558041
|
||||
pkg syscall (freebsd-arm-cgo), func Fchflags(string, int) error
|
||||
pkg syscall (freebsd-arm-cgo), type BpfHdr struct, Pad_cgo_0 [2]uint8
|
||||
pkg syscall (freebsd-arm-cgo), type RawSockaddrDatalink struct, Pad_cgo_0 [2]uint8
|
||||
pkg syscall (freebsd-arm-cgo), type RawSockaddrUnix struct, Pad_cgo_0 [2]uint8
|
||||
pkg syscall (freebsd-arm-cgo), type Stat_t struct, Pad_cgo_0 [4]uint8
|
||||
pkg syscall (linux-386), type Cmsghdr struct, X__cmsg_data [0]uint8
|
||||
pkg syscall (linux-386-cgo), type Cmsghdr struct, X__cmsg_data [0]uint8
|
||||
pkg syscall (linux-amd64), type Cmsghdr struct, X__cmsg_data [0]uint8
|
||||
pkg syscall (linux-amd64-cgo), type Cmsghdr struct, X__cmsg_data [0]uint8
|
||||
pkg syscall (linux-arm), type Cmsghdr struct, X__cmsg_data [0]uint8
|
||||
pkg syscall (linux-arm-cgo), type Cmsghdr struct, X__cmsg_data [0]uint8
|
||||
pkg syscall (netbsd-arm), const SizeofIfData = 132
|
||||
pkg syscall (netbsd-arm), func Fchflags(string, int) error
|
||||
pkg syscall (netbsd-arm), type IfMsghdr struct, Pad_cgo_1 [4]uint8
|
||||
pkg syscall (netbsd-arm-cgo), const SizeofIfData = 132
|
||||
pkg syscall (netbsd-arm-cgo), func Fchflags(string, int) error
|
||||
pkg syscall (netbsd-arm-cgo), type IfMsghdr struct, Pad_cgo_1 [4]uint8
|
||||
pkg syscall (openbsd-386), const BIOCGRTIMEOUT = 1074283118
|
||||
pkg syscall (openbsd-386), const BIOCSRTIMEOUT = 2148024941
|
||||
pkg syscall (openbsd-386), const RTF_FMASK = 63496
|
||||
@@ -331,15 +246,87 @@ pkg syscall (openbsd-amd64-cgo), type Statfs_t struct, F_spare [3]uint32
|
||||
pkg syscall (openbsd-amd64-cgo), type Statfs_t struct, Pad_cgo_1 [4]uint8
|
||||
pkg syscall (openbsd-amd64-cgo), type Timespec struct, Pad_cgo_0 [4]uint8
|
||||
pkg syscall (openbsd-amd64-cgo), type Timespec struct, Sec int32
|
||||
pkg testing, func RegisterCover(Cover)
|
||||
pkg testing, func MainStart(func(string, string) (bool, error), []InternalTest, []InternalBenchmark, []InternalExample) *M
|
||||
pkg text/template/parse, type DotNode bool
|
||||
pkg text/template/parse, type Node interface { Copy, String, Type }
|
||||
pkg unicode, const Version = "6.2.0"
|
||||
pkg syscall (freebsd-386), const AF_MAX = 38
|
||||
pkg syscall (freebsd-386), const DLT_MATCHING_MAX = 242
|
||||
pkg syscall (freebsd-386), const ELAST = 94
|
||||
pkg syscall (freebsd-386), const O_CLOEXEC = 0
|
||||
pkg syscall (freebsd-386-cgo), const AF_MAX = 38
|
||||
pkg syscall (freebsd-386-cgo), const DLT_MATCHING_MAX = 242
|
||||
pkg syscall (freebsd-386-cgo), const ELAST = 94
|
||||
pkg syscall (freebsd-386-cgo), const O_CLOEXEC = 0
|
||||
pkg syscall (freebsd-amd64), const AF_MAX = 38
|
||||
pkg syscall (freebsd-amd64), const DLT_MATCHING_MAX = 242
|
||||
pkg syscall (freebsd-amd64), const ELAST = 94
|
||||
pkg syscall (freebsd-amd64), const O_CLOEXEC = 0
|
||||
pkg syscall (freebsd-amd64-cgo), const AF_MAX = 38
|
||||
pkg syscall (freebsd-amd64-cgo), const DLT_MATCHING_MAX = 242
|
||||
pkg syscall (freebsd-amd64-cgo), const ELAST = 94
|
||||
pkg syscall (freebsd-amd64-cgo), const O_CLOEXEC = 0
|
||||
pkg syscall (freebsd-arm), const AF_MAX = 38
|
||||
pkg syscall (freebsd-arm), const BIOCGRTIMEOUT = 1074545262
|
||||
pkg syscall (freebsd-arm), const BIOCSRTIMEOUT = 2148287085
|
||||
pkg syscall (freebsd-arm), const ELAST = 94
|
||||
pkg syscall (freebsd-arm), const O_CLOEXEC = 0
|
||||
pkg syscall (freebsd-arm), const SIOCAIFADDR = 2151967019
|
||||
pkg syscall (freebsd-arm), const SIOCGIFSTATUS = 3274991931
|
||||
pkg syscall (freebsd-arm), const SIOCSIFPHYADDR = 2151967046
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_FCNTLS_GET = 537
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_FCNTLS_GET ideal-int
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_FCNTLS_LIMIT = 536
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_FCNTLS_LIMIT ideal-int
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_IOCTLS_GET = 535
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_IOCTLS_GET ideal-int
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_IOCTLS_LIMIT = 534
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_IOCTLS_LIMIT ideal-int
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_RIGHTS_GET = 515
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_RIGHTS_GET ideal-int
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_RIGHTS_LIMIT = 533
|
||||
pkg syscall (freebsd-arm), const SYS_CAP_RIGHTS_LIMIT ideal-int
|
||||
pkg syscall (freebsd-arm), const SizeofBpfHdr = 24
|
||||
pkg syscall (freebsd-arm), const SizeofIfData = 88
|
||||
pkg syscall (freebsd-arm), const SizeofIfMsghdr = 104
|
||||
pkg syscall (freebsd-arm), const SizeofSockaddrDatalink = 56
|
||||
pkg syscall (freebsd-arm), const SizeofSockaddrUnix = 108
|
||||
pkg syscall (freebsd-arm), const TIOCTIMESTAMP = 1074558041
|
||||
pkg syscall (freebsd-arm), type BpfHdr struct, Pad_cgo_0 [2]uint8
|
||||
pkg syscall (freebsd-arm), type RawSockaddrDatalink struct, Pad_cgo_0 [2]uint8
|
||||
pkg syscall (freebsd-arm), type RawSockaddrUnix struct, Pad_cgo_0 [2]uint8
|
||||
pkg syscall (freebsd-arm), type Stat_t struct, Pad_cgo_0 [4]uint8
|
||||
pkg syscall (freebsd-arm-cgo), const AF_MAX = 38
|
||||
pkg syscall (freebsd-arm-cgo), const BIOCGRTIMEOUT = 1074545262
|
||||
pkg syscall (freebsd-arm-cgo), const BIOCSRTIMEOUT = 2148287085
|
||||
pkg syscall (freebsd-arm-cgo), const ELAST = 94
|
||||
pkg syscall (freebsd-arm-cgo), const O_CLOEXEC = 0
|
||||
pkg syscall (freebsd-arm-cgo), const SIOCAIFADDR = 2151967019
|
||||
pkg syscall (freebsd-arm-cgo), const SIOCGIFSTATUS = 3274991931
|
||||
pkg syscall (freebsd-arm-cgo), const SIOCSIFPHYADDR = 2151967046
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_FCNTLS_GET = 537
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_FCNTLS_GET ideal-int
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_FCNTLS_LIMIT = 536
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_FCNTLS_LIMIT ideal-int
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_IOCTLS_GET = 535
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_IOCTLS_GET ideal-int
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_IOCTLS_LIMIT = 534
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_IOCTLS_LIMIT ideal-int
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_RIGHTS_GET = 515
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_RIGHTS_GET ideal-int
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_RIGHTS_LIMIT = 533
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_CAP_RIGHTS_LIMIT ideal-int
|
||||
pkg syscall (freebsd-arm-cgo), const SizeofBpfHdr = 24
|
||||
pkg syscall (freebsd-arm-cgo), const SizeofIfData = 88
|
||||
pkg syscall (freebsd-arm-cgo), const SizeofIfMsghdr = 104
|
||||
pkg syscall (freebsd-arm-cgo), const SizeofSockaddrDatalink = 56
|
||||
pkg syscall (freebsd-arm-cgo), const SizeofSockaddrUnix = 108
|
||||
pkg syscall (freebsd-arm-cgo), const TIOCTIMESTAMP = 1074558041
|
||||
pkg syscall (freebsd-arm-cgo), type BpfHdr struct, Pad_cgo_0 [2]uint8
|
||||
pkg syscall (freebsd-arm-cgo), type RawSockaddrDatalink struct, Pad_cgo_0 [2]uint8
|
||||
pkg syscall (freebsd-arm-cgo), type RawSockaddrUnix struct, Pad_cgo_0 [2]uint8
|
||||
pkg syscall (freebsd-arm-cgo), type Stat_t struct, Pad_cgo_0 [4]uint8
|
||||
pkg syscall (netbsd-arm), const SizeofIfData = 132
|
||||
pkg syscall (netbsd-arm), type IfMsghdr struct, Pad_cgo_1 [4]uint8
|
||||
pkg syscall (netbsd-arm-cgo), const SizeofIfData = 132
|
||||
pkg syscall (netbsd-arm-cgo), type IfMsghdr struct, Pad_cgo_1 [4]uint8
|
||||
pkg unicode, const Version = "6.3.0"
|
||||
pkg unicode, const Version = "7.0.0"
|
||||
pkg unicode, const Version = "8.0.0"
|
||||
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
|
||||
|
||||
261
api/go1.8.txt
261
api/go1.8.txt
@@ -1,261 +0,0 @@
|
||||
pkg compress/gzip, const HuffmanOnly = -2
|
||||
pkg compress/gzip, const HuffmanOnly ideal-int
|
||||
pkg compress/zlib, const HuffmanOnly = -2
|
||||
pkg compress/zlib, const HuffmanOnly ideal-int
|
||||
pkg crypto/tls, const ECDSAWithP256AndSHA256 = 1027
|
||||
pkg crypto/tls, const ECDSAWithP256AndSHA256 SignatureScheme
|
||||
pkg crypto/tls, const ECDSAWithP384AndSHA384 = 1283
|
||||
pkg crypto/tls, const ECDSAWithP384AndSHA384 SignatureScheme
|
||||
pkg crypto/tls, const ECDSAWithP521AndSHA512 = 1539
|
||||
pkg crypto/tls, const ECDSAWithP521AndSHA512 SignatureScheme
|
||||
pkg crypto/tls, const PKCS1WithSHA1 = 513
|
||||
pkg crypto/tls, const PKCS1WithSHA1 SignatureScheme
|
||||
pkg crypto/tls, const PKCS1WithSHA256 = 1025
|
||||
pkg crypto/tls, const PKCS1WithSHA256 SignatureScheme
|
||||
pkg crypto/tls, const PKCS1WithSHA384 = 1281
|
||||
pkg crypto/tls, const PKCS1WithSHA384 SignatureScheme
|
||||
pkg crypto/tls, const PKCS1WithSHA512 = 1537
|
||||
pkg crypto/tls, const PKCS1WithSHA512 SignatureScheme
|
||||
pkg crypto/tls, const PSSWithSHA256 = 2052
|
||||
pkg crypto/tls, const PSSWithSHA256 SignatureScheme
|
||||
pkg crypto/tls, const PSSWithSHA384 = 2053
|
||||
pkg crypto/tls, const PSSWithSHA384 SignatureScheme
|
||||
pkg crypto/tls, const PSSWithSHA512 = 2054
|
||||
pkg crypto/tls, const PSSWithSHA512 SignatureScheme
|
||||
pkg crypto/tls, const TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 = 49187
|
||||
pkg crypto/tls, const TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 uint16
|
||||
pkg crypto/tls, const TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 = 52393
|
||||
pkg crypto/tls, const TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 uint16
|
||||
pkg crypto/tls, const TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 = 49191
|
||||
pkg crypto/tls, const TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 uint16
|
||||
pkg crypto/tls, const TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 = 52392
|
||||
pkg crypto/tls, const TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 uint16
|
||||
pkg crypto/tls, const TLS_RSA_WITH_AES_128_CBC_SHA256 = 60
|
||||
pkg crypto/tls, const TLS_RSA_WITH_AES_128_CBC_SHA256 uint16
|
||||
pkg crypto/tls, const X25519 = 29
|
||||
pkg crypto/tls, const X25519 CurveID
|
||||
pkg crypto/tls, method (*Config) Clone() *Config
|
||||
pkg crypto/tls, method (*Conn) CloseWrite() error
|
||||
pkg crypto/tls, type CertificateRequestInfo struct
|
||||
pkg crypto/tls, type CertificateRequestInfo struct, AcceptableCAs [][]uint8
|
||||
pkg crypto/tls, type CertificateRequestInfo struct, SignatureSchemes []SignatureScheme
|
||||
pkg crypto/tls, type ClientHelloInfo struct, Conn net.Conn
|
||||
pkg crypto/tls, type ClientHelloInfo struct, SignatureSchemes []SignatureScheme
|
||||
pkg crypto/tls, type ClientHelloInfo struct, SupportedProtos []string
|
||||
pkg crypto/tls, type ClientHelloInfo struct, SupportedVersions []uint16
|
||||
pkg crypto/tls, type Config struct, GetClientCertificate func(*CertificateRequestInfo) (*Certificate, error)
|
||||
pkg crypto/tls, type Config struct, GetConfigForClient func(*ClientHelloInfo) (*Config, error)
|
||||
pkg crypto/tls, type Config struct, KeyLogWriter io.Writer
|
||||
pkg crypto/tls, type Config struct, VerifyPeerCertificate func([][]uint8, [][]*x509.Certificate) error
|
||||
pkg crypto/tls, type SignatureScheme uint16
|
||||
pkg crypto/x509, const NameMismatch = 5
|
||||
pkg crypto/x509, const NameMismatch InvalidReason
|
||||
pkg crypto/x509, const SHA256WithRSAPSS = 13
|
||||
pkg crypto/x509, const SHA256WithRSAPSS SignatureAlgorithm
|
||||
pkg crypto/x509, const SHA384WithRSAPSS = 14
|
||||
pkg crypto/x509, const SHA384WithRSAPSS SignatureAlgorithm
|
||||
pkg crypto/x509, const SHA512WithRSAPSS = 15
|
||||
pkg crypto/x509, const SHA512WithRSAPSS SignatureAlgorithm
|
||||
pkg crypto/x509, type UnknownAuthorityError struct, Cert *Certificate
|
||||
pkg database/sql, const LevelDefault = 0
|
||||
pkg database/sql, const LevelDefault IsolationLevel
|
||||
pkg database/sql, const LevelLinearizable = 7
|
||||
pkg database/sql, const LevelLinearizable IsolationLevel
|
||||
pkg database/sql, const LevelReadCommitted = 2
|
||||
pkg database/sql, const LevelReadCommitted IsolationLevel
|
||||
pkg database/sql, const LevelReadUncommitted = 1
|
||||
pkg database/sql, const LevelReadUncommitted IsolationLevel
|
||||
pkg database/sql, const LevelRepeatableRead = 4
|
||||
pkg database/sql, const LevelRepeatableRead IsolationLevel
|
||||
pkg database/sql, const LevelSerializable = 6
|
||||
pkg database/sql, const LevelSerializable IsolationLevel
|
||||
pkg database/sql, const LevelSnapshot = 5
|
||||
pkg database/sql, const LevelSnapshot IsolationLevel
|
||||
pkg database/sql, const LevelWriteCommitted = 3
|
||||
pkg database/sql, const LevelWriteCommitted IsolationLevel
|
||||
pkg database/sql/driver, type ConnBeginTx interface { BeginTx }
|
||||
pkg database/sql/driver, type ConnBeginTx interface, BeginTx(context.Context, TxOptions) (Tx, error)
|
||||
pkg database/sql/driver, type ConnPrepareContext interface { PrepareContext }
|
||||
pkg database/sql/driver, type ConnPrepareContext interface, PrepareContext(context.Context, string) (Stmt, error)
|
||||
pkg database/sql/driver, type ExecerContext interface { ExecContext }
|
||||
pkg database/sql/driver, type ExecerContext interface, ExecContext(context.Context, string, []NamedValue) (Result, error)
|
||||
pkg database/sql/driver, type IsolationLevel int
|
||||
pkg database/sql/driver, type NamedValue struct
|
||||
pkg database/sql/driver, type NamedValue struct, Name string
|
||||
pkg database/sql/driver, type NamedValue struct, Ordinal int
|
||||
pkg database/sql/driver, type NamedValue struct, Value Value
|
||||
pkg database/sql/driver, type Pinger interface { Ping }
|
||||
pkg database/sql/driver, type Pinger interface, Ping(context.Context) error
|
||||
pkg database/sql/driver, type QueryerContext interface { QueryContext }
|
||||
pkg database/sql/driver, type QueryerContext interface, QueryContext(context.Context, string, []NamedValue) (Rows, error)
|
||||
pkg database/sql/driver, type RowsColumnTypeDatabaseTypeName interface { Close, ColumnTypeDatabaseTypeName, Columns, Next }
|
||||
pkg database/sql/driver, type RowsColumnTypeDatabaseTypeName interface, Close() error
|
||||
pkg database/sql/driver, type RowsColumnTypeDatabaseTypeName interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsColumnTypeDatabaseTypeName interface, ColumnTypeDatabaseTypeName(int) string
|
||||
pkg database/sql/driver, type RowsColumnTypeDatabaseTypeName interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsColumnTypeLength interface { Close, ColumnTypeLength, Columns, Next }
|
||||
pkg database/sql/driver, type RowsColumnTypeLength interface, Close() error
|
||||
pkg database/sql/driver, type RowsColumnTypeLength interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsColumnTypeLength interface, ColumnTypeLength(int) (int64, bool)
|
||||
pkg database/sql/driver, type RowsColumnTypeLength interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsColumnTypeNullable interface { Close, ColumnTypeNullable, Columns, Next }
|
||||
pkg database/sql/driver, type RowsColumnTypeNullable interface, Close() error
|
||||
pkg database/sql/driver, type RowsColumnTypeNullable interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsColumnTypeNullable interface, ColumnTypeNullable(int) (bool, bool)
|
||||
pkg database/sql/driver, type RowsColumnTypeNullable interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsColumnTypePrecisionScale interface { Close, ColumnTypePrecisionScale, Columns, Next }
|
||||
pkg database/sql/driver, type RowsColumnTypePrecisionScale interface, Close() error
|
||||
pkg database/sql/driver, type RowsColumnTypePrecisionScale interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsColumnTypePrecisionScale interface, ColumnTypePrecisionScale(int) (int64, int64, bool)
|
||||
pkg database/sql/driver, type RowsColumnTypePrecisionScale interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsColumnTypeScanType interface { Close, ColumnTypeScanType, Columns, Next }
|
||||
pkg database/sql/driver, type RowsColumnTypeScanType interface, Close() error
|
||||
pkg database/sql/driver, type RowsColumnTypeScanType interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsColumnTypeScanType interface, ColumnTypeScanType(int) reflect.Type
|
||||
pkg database/sql/driver, type RowsColumnTypeScanType interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsNextResultSet interface { Close, Columns, HasNextResultSet, Next, NextResultSet }
|
||||
pkg database/sql/driver, type RowsNextResultSet interface, Close() error
|
||||
pkg database/sql/driver, type RowsNextResultSet interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsNextResultSet interface, HasNextResultSet() bool
|
||||
pkg database/sql/driver, type RowsNextResultSet interface, NextResultSet() error
|
||||
pkg database/sql/driver, type RowsNextResultSet interface, Next([]Value) error
|
||||
pkg database/sql/driver, type StmtExecContext interface { ExecContext }
|
||||
pkg database/sql/driver, type StmtExecContext interface, ExecContext(context.Context, []NamedValue) (Result, error)
|
||||
pkg database/sql/driver, type StmtQueryContext interface { QueryContext }
|
||||
pkg database/sql/driver, type StmtQueryContext interface, QueryContext(context.Context, []NamedValue) (Rows, error)
|
||||
pkg database/sql/driver, type TxOptions struct
|
||||
pkg database/sql/driver, type TxOptions struct, Isolation IsolationLevel
|
||||
pkg database/sql/driver, type TxOptions struct, ReadOnly bool
|
||||
pkg database/sql, func Named(string, interface{}) NamedArg
|
||||
pkg database/sql, method (*ColumnType) DatabaseTypeName() string
|
||||
pkg database/sql, method (*ColumnType) DecimalSize() (int64, int64, bool)
|
||||
pkg database/sql, method (*ColumnType) Length() (int64, bool)
|
||||
pkg database/sql, method (*ColumnType) Name() string
|
||||
pkg database/sql, method (*ColumnType) Nullable() (bool, bool)
|
||||
pkg database/sql, method (*ColumnType) ScanType() reflect.Type
|
||||
pkg database/sql, method (*DB) BeginTx(context.Context, *TxOptions) (*Tx, error)
|
||||
pkg database/sql, method (*DB) ExecContext(context.Context, string, ...interface{}) (Result, error)
|
||||
pkg database/sql, method (*DB) PingContext(context.Context) error
|
||||
pkg database/sql, method (*DB) PrepareContext(context.Context, string) (*Stmt, error)
|
||||
pkg database/sql, method (*DB) QueryContext(context.Context, string, ...interface{}) (*Rows, error)
|
||||
pkg database/sql, method (*DB) QueryRowContext(context.Context, string, ...interface{}) *Row
|
||||
pkg database/sql, method (*Rows) ColumnTypes() ([]*ColumnType, error)
|
||||
pkg database/sql, method (*Rows) NextResultSet() bool
|
||||
pkg database/sql, method (*Stmt) ExecContext(context.Context, ...interface{}) (Result, error)
|
||||
pkg database/sql, method (*Stmt) QueryContext(context.Context, ...interface{}) (*Rows, error)
|
||||
pkg database/sql, method (*Stmt) QueryRowContext(context.Context, ...interface{}) *Row
|
||||
pkg database/sql, method (*Tx) ExecContext(context.Context, string, ...interface{}) (Result, error)
|
||||
pkg database/sql, method (*Tx) PrepareContext(context.Context, string) (*Stmt, error)
|
||||
pkg database/sql, method (*Tx) QueryContext(context.Context, string, ...interface{}) (*Rows, error)
|
||||
pkg database/sql, method (*Tx) QueryRowContext(context.Context, string, ...interface{}) *Row
|
||||
pkg database/sql, method (*Tx) StmtContext(context.Context, *Stmt) *Stmt
|
||||
pkg database/sql, type ColumnType struct
|
||||
pkg database/sql, type IsolationLevel int
|
||||
pkg database/sql, type NamedArg struct
|
||||
pkg database/sql, type NamedArg struct, Name string
|
||||
pkg database/sql, type NamedArg struct, Value interface{}
|
||||
pkg database/sql, type TxOptions struct
|
||||
pkg database/sql, type TxOptions struct, Isolation IsolationLevel
|
||||
pkg database/sql, type TxOptions struct, ReadOnly bool
|
||||
pkg debug/pe, method (*COFFSymbol) FullName(StringTable) (string, error)
|
||||
pkg debug/pe, method (StringTable) String(uint32) (string, error)
|
||||
pkg debug/pe, type File struct, COFFSymbols []COFFSymbol
|
||||
pkg debug/pe, type File struct, StringTable StringTable
|
||||
pkg debug/pe, type Reloc struct
|
||||
pkg debug/pe, type Reloc struct, SymbolTableIndex uint32
|
||||
pkg debug/pe, type Reloc struct, Type uint16
|
||||
pkg debug/pe, type Reloc struct, VirtualAddress uint32
|
||||
pkg debug/pe, type Section struct, Relocs []Reloc
|
||||
pkg debug/pe, type StringTable []uint8
|
||||
pkg encoding/base64, method (Encoding) Strict() *Encoding
|
||||
pkg encoding/json, method (RawMessage) MarshalJSON() ([]uint8, error)
|
||||
pkg encoding/json, type UnmarshalTypeError struct, Field string
|
||||
pkg encoding/json, type UnmarshalTypeError struct, Struct string
|
||||
pkg expvar, func Handler() http.Handler
|
||||
pkg expvar, method (*Float) Value() float64
|
||||
pkg expvar, method (Func) Value() interface{}
|
||||
pkg expvar, method (*Int) Value() int64
|
||||
pkg expvar, method (*String) Value() string
|
||||
pkg go/doc, func IsPredeclared(string) bool
|
||||
pkg go/types, func Default(Type) Type
|
||||
pkg go/types, func IdenticalIgnoreTags(Type, Type) bool
|
||||
pkg math/big, method (*Float) Scan(fmt.ScanState, int32) error
|
||||
pkg math/big, method (*Int) Sqrt(*Int) *Int
|
||||
pkg math/rand, func Uint64() uint64
|
||||
pkg math/rand, method (*Rand) Uint64() uint64
|
||||
pkg math/rand, type Source64 interface, Int63() int64
|
||||
pkg math/rand, type Source64 interface { Int63, Seed, Uint64 }
|
||||
pkg math/rand, type Source64 interface, Seed(int64)
|
||||
pkg math/rand, type Source64 interface, Uint64() uint64
|
||||
pkg net/http, const TrailerPrefix ideal-string
|
||||
pkg net/http, const TrailerPrefix = "Trailer:"
|
||||
pkg net/http/httptrace, type ClientTrace struct, TLSHandshakeDone func(tls.ConnectionState, error)
|
||||
pkg net/http/httptrace, type ClientTrace struct, TLSHandshakeStart func()
|
||||
pkg net/http/httputil, type ReverseProxy struct, ModifyResponse func(*http.Response) error
|
||||
pkg net/http, method (*Server) Close() error
|
||||
pkg net/http, method (*Server) Shutdown(context.Context) error
|
||||
pkg net/http, type Pusher interface { Push }
|
||||
pkg net/http, type Pusher interface, Push(string, *PushOptions) error
|
||||
pkg net/http, type PushOptions struct
|
||||
pkg net/http, type PushOptions struct, Header Header
|
||||
pkg net/http, type PushOptions struct, Method string
|
||||
pkg net/http, type Request struct, GetBody func() (io.ReadCloser, error)
|
||||
pkg net/http, type Server struct, IdleTimeout time.Duration
|
||||
pkg net/http, type Server struct, ReadHeaderTimeout time.Duration
|
||||
pkg net/http, type Transport struct, ProxyConnectHeader Header
|
||||
pkg net/http, var ErrAbortHandler error
|
||||
pkg net/http, var ErrServerClosed error
|
||||
pkg net/http, var NoBody noBody
|
||||
pkg net/mail, func ParseDate(string) (time.Time, error)
|
||||
pkg net, method (*Buffers) Read([]uint8) (int, error)
|
||||
pkg net, method (*Buffers) WriteTo(io.Writer) (int64, error)
|
||||
pkg net, method (*Resolver) LookupAddr(context.Context, string) ([]string, error)
|
||||
pkg net, method (*Resolver) LookupCNAME(context.Context, string) (string, error)
|
||||
pkg net, method (*Resolver) LookupHost(context.Context, string) ([]string, error)
|
||||
pkg net, method (*Resolver) LookupIPAddr(context.Context, string) ([]IPAddr, error)
|
||||
pkg net, method (*Resolver) LookupMX(context.Context, string) ([]*MX, error)
|
||||
pkg net, method (*Resolver) LookupNS(context.Context, string) ([]*NS, error)
|
||||
pkg net, method (*Resolver) LookupPort(context.Context, string, string) (int, error)
|
||||
pkg net, method (*Resolver) LookupSRV(context.Context, string, string, string) (string, []*SRV, error)
|
||||
pkg net, method (*Resolver) LookupTXT(context.Context, string) ([]string, error)
|
||||
pkg net, method (*UnixListener) SetUnlinkOnClose(bool)
|
||||
pkg net, type Buffers [][]uint8
|
||||
pkg net, type Dialer struct, Resolver *Resolver
|
||||
pkg net, type Resolver struct
|
||||
pkg net, type Resolver struct, PreferGo bool
|
||||
pkg net/url, func PathEscape(string) string
|
||||
pkg net/url, func PathUnescape(string) (string, error)
|
||||
pkg net/url, method (*URL) Hostname() string
|
||||
pkg net/url, method (*URL) MarshalBinary() ([]uint8, error)
|
||||
pkg net/url, method (*URL) Port() string
|
||||
pkg net/url, method (*URL) UnmarshalBinary([]uint8) error
|
||||
pkg net, var DefaultResolver *Resolver
|
||||
pkg os, func Executable() (string, error)
|
||||
pkg os, var ErrClosed error
|
||||
pkg plugin, func Open(string) (*Plugin, error)
|
||||
pkg plugin, method (*Plugin) Lookup(string) (Symbol, error)
|
||||
pkg plugin, type Plugin struct
|
||||
pkg plugin, type Symbol interface {}
|
||||
pkg reflect, func Swapper(interface{}) func(int, int)
|
||||
pkg runtime, func MutexProfile([]BlockProfileRecord) (int, bool)
|
||||
pkg runtime, func SetMutexProfileFraction(int) int
|
||||
pkg runtime, type MemStats struct, NumForcedGC uint32
|
||||
pkg sort, func Slice(interface{}, func(int, int) bool)
|
||||
pkg sort, func SliceIsSorted(interface{}, func(int, int) bool) bool
|
||||
pkg sort, func SliceStable(interface{}, func(int, int) bool)
|
||||
pkg syscall (linux-arm-cgo), func TimevalToNsec(Timeval) int64
|
||||
pkg syscall (linux-arm), func TimevalToNsec(Timeval) int64
|
||||
pkg syscall (openbsd-386), const SYS_KILL = 122
|
||||
pkg syscall (openbsd-386-cgo), const SYS_KILL = 122
|
||||
pkg syscall (openbsd-amd64), const SYS_KILL = 122
|
||||
pkg syscall (openbsd-amd64-cgo), const SYS_KILL = 122
|
||||
pkg syscall (windows-386), const ERROR_DIR_NOT_EMPTY = 145
|
||||
pkg syscall (windows-386), const ERROR_DIR_NOT_EMPTY Errno
|
||||
pkg syscall (windows-amd64), const ERROR_DIR_NOT_EMPTY = 145
|
||||
pkg syscall (windows-amd64), const ERROR_DIR_NOT_EMPTY Errno
|
||||
pkg testing, func CoverMode() string
|
||||
pkg testing, func MainStart(testDeps, []InternalTest, []InternalBenchmark, []InternalExample) *M
|
||||
pkg testing, method (*B) Name() string
|
||||
pkg testing, method (*T) Name() string
|
||||
pkg testing, type TB interface, Name() string
|
||||
pkg time, func Until(Time) Duration
|
||||
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
|
||||
@@ -97,14 +97,13 @@ a tool like the go command to look at an unfamiliar import path and
|
||||
deduce where to obtain the source code.</p>
|
||||
|
||||
<p>Second, the place to store sources in the local file system is derived
|
||||
in a known way from the import path, specifically
|
||||
<code>$GOPATH/src/<import-path></code>.
|
||||
If unset, <code>$GOPATH</code> defaults to a subdirectory
|
||||
named <code>go</code> in the user's home directory.
|
||||
in a known way from the import path. Specifically, the first choice
|
||||
is <code>$GOPATH/src/<import-path></code>. If <code>$GOPATH</code> is
|
||||
unset, the go command will fall back to storing source code alongside the
|
||||
standard Go packages, in <code>$GOROOT/src/<import-path></code>.
|
||||
If <code>$GOPATH</code> is set to a list of paths, the go command tries
|
||||
<code><dir>/src/<import-path></code> for each of the directories in
|
||||
that list.
|
||||
</p>
|
||||
that list.</p>
|
||||
|
||||
<p>Each of those trees contains, by convention, a top-level directory named
|
||||
"<code>bin</code>", for holding compiled executables, and a top-level directory
|
||||
@@ -138,26 +137,41 @@ to the use of a specific tool chain.</p>
|
||||
|
||||
<h2>Getting started with the go command</h2>
|
||||
|
||||
<p>Finally, a quick tour of how to use the go command.
|
||||
As mentioned above, the default <code>$GOPATH</code> on Unix is <code>$HOME/go</code>.
|
||||
We'll store our programs there.
|
||||
To use a different location, you can set <code>$GOPATH</code>;
|
||||
see <a href="/doc/code.html">How to Write Go Code</a> for details.
|
||||
<p>Finally, a quick tour of how to use the go command, to supplement
|
||||
the information in <a href="/doc/code.html">How to Write Go Code</a>,
|
||||
which you might want to read first. Assuming you want
|
||||
to keep your source code separate from the Go distribution source
|
||||
tree, the first step is to set <code>$GOPATH</code>, the one piece of global
|
||||
configuration that the go command needs. The <code>$GOPATH</code> can be a
|
||||
list of directories, but by far the most common usage should be to set it to a
|
||||
single directory. In particular, you do not need a separate entry in
|
||||
<code>$GOPATH</code> for each of your projects. One <code>$GOPATH</code> can
|
||||
support many projects.</p>
|
||||
|
||||
<p>We first add some source code. Suppose we want to use
|
||||
<p>Here’s an example. Let’s say we decide to keep our Go code in the directory
|
||||
<code>$HOME/mygo</code>. We need to create that directory and set
|
||||
<code>$GOPATH</code> accordingly.</p>
|
||||
|
||||
<pre>
|
||||
$ mkdir $HOME/mygo
|
||||
$ export GOPATH=$HOME/mygo
|
||||
$
|
||||
</pre>
|
||||
|
||||
<p>Into this directory, we now add some source code. Suppose we want to use
|
||||
the indexing library from the codesearch project along with a left-leaning
|
||||
red-black tree. We can install both with the "<code>go get</code>"
|
||||
subcommand:</p>
|
||||
|
||||
<pre>
|
||||
$ go get github.com/google/codesearch/index
|
||||
$ go get code.google.com/p/codesearch/index
|
||||
$ go get github.com/petar/GoLLRB/llrb
|
||||
$
|
||||
</pre>
|
||||
|
||||
<p>Both of these projects are now downloaded and installed into <code>$HOME/go</code>,
|
||||
which contains the two directories
|
||||
<code>src/github.com/google/codesearch/index/</code> and
|
||||
<p>Both of these projects are now downloaded and installed into our
|
||||
<code>$GOPATH</code> directory. The one tree now contains the two directories
|
||||
<code>src/code.google.com/p/codesearch/index/</code> and
|
||||
<code>src/github.com/petar/GoLLRB/llrb/</code>, along with the compiled
|
||||
packages (in <code>pkg/</code>) for those libraries and their dependencies.</p>
|
||||
|
||||
@@ -170,14 +184,13 @@ the pattern "<code>./...</code>" means start in the current directory
|
||||
("<code>...</code>"):</p>
|
||||
|
||||
<pre>
|
||||
$ cd $HOME/go/src
|
||||
$ go list ./...
|
||||
github.com/google/codesearch/cmd/cgrep
|
||||
github.com/google/codesearch/cmd/cindex
|
||||
github.com/google/codesearch/cmd/csearch
|
||||
github.com/google/codesearch/index
|
||||
github.com/google/codesearch/regexp
|
||||
github.com/google/codesearch/sparse
|
||||
code.google.com/p/codesearch/cmd/cgrep
|
||||
code.google.com/p/codesearch/cmd/cindex
|
||||
code.google.com/p/codesearch/cmd/csearch
|
||||
code.google.com/p/codesearch/index
|
||||
code.google.com/p/codesearch/regexp
|
||||
code.google.com/p/codesearch/sparse
|
||||
github.com/petar/GoLLRB/example
|
||||
github.com/petar/GoLLRB/llrb
|
||||
$
|
||||
@@ -187,12 +200,12 @@ $
|
||||
|
||||
<pre>
|
||||
$ go test ./...
|
||||
? github.com/google/codesearch/cmd/cgrep [no test files]
|
||||
? github.com/google/codesearch/cmd/cindex [no test files]
|
||||
? github.com/google/codesearch/cmd/csearch [no test files]
|
||||
ok github.com/google/codesearch/index 0.203s
|
||||
ok github.com/google/codesearch/regexp 0.017s
|
||||
? github.com/google/codesearch/sparse [no test files]
|
||||
? code.google.com/p/codesearch/cmd/cgrep [no test files]
|
||||
? code.google.com/p/codesearch/cmd/cindex [no test files]
|
||||
? code.google.com/p/codesearch/cmd/csearch [no test files]
|
||||
ok code.google.com/p/codesearch/index 0.239s
|
||||
ok code.google.com/p/codesearch/regexp 0.021s
|
||||
? code.google.com/p/codesearch/sparse [no test files]
|
||||
? github.com/petar/GoLLRB/example [no test files]
|
||||
ok github.com/petar/GoLLRB/llrb 0.231s
|
||||
$
|
||||
@@ -202,18 +215,18 @@ $
|
||||
current directory:</p>
|
||||
|
||||
<pre>
|
||||
$ cd github.com/google/codesearch/regexp
|
||||
$ cd $GOPATH/src/code.google.com/p/codesearch/regexp
|
||||
$ go list
|
||||
github.com/google/codesearch/regexp
|
||||
code.google.com/p/codesearch/regexp
|
||||
$ go test -v
|
||||
=== RUN TestNstateEnc
|
||||
--- PASS: TestNstateEnc (0.00s)
|
||||
=== RUN TestMatch
|
||||
--- PASS: TestMatch (0.00s)
|
||||
=== RUN TestGrep
|
||||
--- PASS: TestGrep (0.00s)
|
||||
=== RUN TestNstateEnc
|
||||
--- PASS: TestNstateEnc (0.00 seconds)
|
||||
=== RUN TestMatch
|
||||
--- PASS: TestMatch (0.01 seconds)
|
||||
=== RUN TestGrep
|
||||
--- PASS: TestGrep (0.00 seconds)
|
||||
PASS
|
||||
ok github.com/google/codesearch/regexp 0.018s
|
||||
ok code.google.com/p/codesearch/regexp 0.021s
|
||||
$ go install
|
||||
$
|
||||
</pre>
|
||||
@@ -231,6 +244,9 @@ pick such a long name, but that ability would require additional configuration
|
||||
and complexity in the tool. Typing an extra directory name or two is a small
|
||||
price to pay for the increased simplicity and power.</p>
|
||||
|
||||
<p>As the example shows, it’s fine to work with packages from many different
|
||||
projects at once within a single <code>$GOPATH</code> root directory.</p>
|
||||
|
||||
<h2>Limitations</h2>
|
||||
|
||||
<p>As mentioned above, the go command is not a general-purpose build
|
||||
@@ -239,7 +255,8 @@ In particular, it does not have any facility for generating Go
|
||||
source files <em>during</em> a build, although it does provide
|
||||
<a href="/cmd/go/#hdr-Generate_Go_files_by_processing_source"><code>go</code>
|
||||
<code>generate</code></a>,
|
||||
which can automate the creation of Go files <em>before</em> the build.
|
||||
which can automate the creation of Go files <em>before</em>
|
||||
the build, such as by running <code>yacc</code>.
|
||||
For more advanced build setups, you may need to write a
|
||||
makefile (or a configuration file for the build tool of your choice)
|
||||
to run whatever tool creates the Go files and then check those generated source files
|
||||
|
||||
@@ -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
|
||||
|
||||
38
doc/asm.html
38
doc/asm.html
@@ -838,44 +838,6 @@ It is a scaled mode as on the x86, but the only scale allowed is <code>1</code>.
|
||||
|
||||
</ul>
|
||||
|
||||
<h3 id="mips">MIPS, MIPS64</h3>
|
||||
|
||||
<p>
|
||||
General purpose registers are named <code>R0</code> through <code>R31</code>,
|
||||
floating point registers are <code>F0</code> through <code>F31</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<code>R30</code> is reserved to point to <code>g</code>.
|
||||
<code>R23</code> is used as a temporary register.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
In a <code>TEXT</code> directive, the frame size <code>$-4</code> for MIPS or
|
||||
<code>$-8</code> for MIPS64 instructs the linker not to save <code>LR</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<code>SP</code> refers to the virtual stack pointer.
|
||||
For the hardware register, use <code>R29</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Addressing modes:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<code>16(R1)</code>: The location at <code>R1</code> plus 16.
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<code>(R1)</code>: Alias for <code>0(R1)</code>.
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<h3 id="unsupported_opcodes">Unsupported opcodes</h3>
|
||||
|
||||
<p>
|
||||
|
||||
10
doc/cmd.html
10
doc/cmd.html
@@ -22,7 +22,7 @@ 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
|
||||
Some of the commands, such as <code>yacc</code>, are accessible only through
|
||||
the go <code>tool</code> subcommand.
|
||||
</p>
|
||||
|
||||
@@ -62,7 +62,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>
|
||||
@@ -95,6 +95,12 @@ gofmt</a> command with more general options.</td>
|
||||
calls whose arguments do not align with the format string.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><a href="/cmd/yacc/">yacc</a></td>
|
||||
<td> </td>
|
||||
<td>Yacc is a version of yacc that generates parsers implemented in Go.</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -120,26 +120,22 @@ We will discuss the distinction <a href="#PackageNames">later</a>.
|
||||
|
||||
<p>
|
||||
The <code>GOPATH</code> environment variable specifies the location of your
|
||||
workspace. It defaults to a directory named <code>go</code> inside your home directory,
|
||||
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.
|
||||
workspace. It is likely the only environment variable you'll need to set
|
||||
when developing Go code.
|
||||
</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.
|
||||
(Another common setup is to set <code>GOPATH=$HOME</code>.)
|
||||
Note that <code>GOPATH</code> must <b>not</b> be the
|
||||
To get started, create a workspace directory and set <code>GOPATH</code>
|
||||
accordingly. Your workspace can be located wherever you like, but we'll use
|
||||
<code>$HOME/work</code> in this document. Note that this must <b>not</b> be the
|
||||
same path as your Go installation.
|
||||
(Another common setup is to set <code>GOPATH=$HOME</code>.)
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The command <code>go</code> <code>env</code> <code>GOPATH</code>
|
||||
prints the effective current <code>GOPATH</code>;
|
||||
it prints the default location if the environment variable is unset.
|
||||
</p>
|
||||
<pre>
|
||||
$ <b>mkdir $HOME/work</b>
|
||||
$ <b>export GOPATH=$HOME/work</b>
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
For convenience, add the workspace's <code>bin</code> subdirectory
|
||||
@@ -147,30 +143,13 @@ to your <code>PATH</code>:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ <b>export PATH=$PATH:$(go env GOPATH)/bin</b>
|
||||
$ <b>export PATH=$PATH:$GOPATH/bin</b>
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The scripts in the rest of this document use <code>$GOPATH</code>
|
||||
instead of <code>$(go env GOPATH)</code> for brevity.
|
||||
To make the scripts run as written
|
||||
if you have not set GOPATH,
|
||||
you can substitute $HOME/go in those commands
|
||||
or else run:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ <b>export GOPATH=$(go env GOPATH)</b>
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
To learn more about the <code>GOPATH</code> environment variable, see
|
||||
<a href="/cmd/go/#hdr-GOPATH_environment_variable"><code>'go help gopath'</code></a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To use a custom workspace location,
|
||||
<a href="https://golang.org/wiki/SettingGOPATH">set the <code>GOPATH</code> environment variable</a>.
|
||||
To learn more about setting up the <code>GOPATH</code> environment variable,
|
||||
please see
|
||||
<a href="/cmd/go/#hdr-GOPATH_environment_variable"><code>go help gopath</code></a>
|
||||
</p>
|
||||
|
||||
<h3 id="ImportPaths">Import paths</h3>
|
||||
@@ -270,7 +249,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>
|
||||
|
||||
@@ -20,8 +20,8 @@ ul ul {
|
||||
<p>
|
||||
Online communities include people from many different backgrounds.
|
||||
The Go contributors are committed to providing a friendly, safe and welcoming
|
||||
environment for all, regardless of age, disability, gender, nationality,
|
||||
ethnicity, religion, sexuality, or similar personal characteristic.
|
||||
environment for all, regardless of age, disability, gender, nationality, race,
|
||||
religion, sexuality, or similar personal characteristic.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -67,6 +67,7 @@ official forums operated by the Go project (“Go spaces”):
|
||||
<li>The <a href="https://groups.google.com/group/golang-nuts">golang-nuts</a> and
|
||||
<a href="https://groups.google.com/group/golang-dev">golang-dev</a> mailing lists.
|
||||
<li>The #go-nuts IRC channel on Freenode.
|
||||
<li>The <a href="https://reddit.com/r/golang">/r/golang subreddit</a>.
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
@@ -148,26 +149,29 @@ These actions are explicitly forbidden in Go spaces:
|
||||
|
||||
<p>
|
||||
The Go spaces are not free speech venues; they are for discussion about Go.
|
||||
Each of these spaces have their own moderators.
|
||||
These spaces have moderators.
|
||||
The goal of the moderators is to facilitate civil discussion about Go.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
When using the official Go spaces you should act in the spirit of the “Gopher
|
||||
values”.
|
||||
If a reported conflict cannot be resolved amicably, the CoC Working Group
|
||||
may make a recommendation to the relevant forum moderators.
|
||||
If you conduct yourself in a way that is explicitly forbidden by the CoC,
|
||||
you will be warned and asked to stop.
|
||||
If you do not stop, you will be removed from our community spaces temporarily.
|
||||
Repeated, willful breaches of the CoC will result in a permanent ban.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
CoC Working Group members and forum moderators are held to a higher standard than other community members.
|
||||
If a working group member or moderator creates an inappropriate situation, they
|
||||
should expect less leeway than others, and should expect to be removed from
|
||||
their position if they cannot adhere to the CoC.
|
||||
Moderators are held to a higher standard than other community members.
|
||||
If a moderator creates an inappropriate situation, they should expect less
|
||||
leeway than others, and should expect to be removed from their position if they
|
||||
cannot adhere to the CoC.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Complaints about working group member or moderator actions must be handled
|
||||
using the reporting process below.
|
||||
Complaints about moderator actions must be handled using the reporting process
|
||||
below.
|
||||
</p>
|
||||
|
||||
<h2 id="reporting">Reporting issues</h2>
|
||||
@@ -182,6 +186,8 @@ satisfaction of all parties. They are:
|
||||
<ul>
|
||||
<li>Aditya Mukerjee <dev@chimeracoder.net>
|
||||
<li>Andrew Gerrand <adg@golang.org>
|
||||
<li>Dave Cheney <dave@cheney.net>
|
||||
<li>Jason Buberel <jbuberel@google.com>
|
||||
<li>Peggy Li <peggyli.224@gmail.com>
|
||||
<li>Sarah Adams <sadams.codes@gmail.com>
|
||||
<li>Steve Francia <steve.francia@gmail.com>
|
||||
@@ -196,10 +202,13 @@ particular individual or group.
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>Mail <a href="mailto:conduct@golang.org">conduct@golang.org</a>.
|
||||
<li>Mail <a href="mailto:conduct@golang.org">conduct@golang.org</a> or
|
||||
<a href="https://golang.org/s/conduct-report">submit an anonymous report</a>.
|
||||
<ul>
|
||||
<li>Your message will reach the Working Group.
|
||||
<li>Reports are confidential within the Working Group.
|
||||
<li>Should you choose to remain anonymous then the Working Group cannot
|
||||
notify you of the outcome of your report.
|
||||
<li>You may contact a member of the group directly if you do not feel
|
||||
comfortable contacting the group as a whole. That member will then raise
|
||||
the issue with the Working Group as a whole, preserving the privacy of the
|
||||
@@ -221,8 +230,11 @@ particular individual or group.
|
||||
<li>The Working Group will reach a decision as to how to act. These may include:
|
||||
<ul>
|
||||
<li>Nothing.
|
||||
<li>Passing the report along to the offender.
|
||||
<li>A recommendation of action to the relevant forum moderators.
|
||||
<li>A request for a private or public apology.
|
||||
<li>A private or public warning.
|
||||
<li>An imposed vacation (for instance, asking someone to abstain for a week
|
||||
from a mailing list or IRC).
|
||||
<li>A permanent or temporary ban from some or all Go spaces.
|
||||
</ul>
|
||||
<li>The Working Group will reach out to the original reporter to let them know
|
||||
the decision.
|
||||
@@ -235,6 +247,7 @@ particular individual or group.
|
||||
conflicts in the most harmonious way possible.</b>
|
||||
We hope that in most cases issues may be resolved through polite discussion and
|
||||
mutual agreement.
|
||||
Bannings and other forceful measures are to be employed only as a last resort.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -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.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>
|
||||
<li><a href="/doc/go1.5">Go 1.5</a> <small>(August 2015)</small></li>
|
||||
<li><a href="/doc/go1.4">Go 1.4</a> <small>(December 2014)</small></li>
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
<!--{
|
||||
"Title": "Contribution Guide"
|
||||
"Title": "Contribution Guidelines"
|
||||
}-->
|
||||
|
||||
<h2 id="Introduction">Introduction</h2>
|
||||
|
||||
<p>
|
||||
The Go project welcomes all contributors. The process of contributing
|
||||
to the Go project may be different than many projects you are used to.
|
||||
This document is intended as a guide to help you through the contribution
|
||||
process. This guide assumes you have a basic understanding of Git and Go.
|
||||
This document explains how to contribute changes to the Go project.
|
||||
It assumes you have followed the
|
||||
<a href="/doc/install/source">installation instructions</a> and
|
||||
have <a href="code.html">written and tested your code</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -18,73 +20,103 @@ see <a href="gccgo_contribute.html">Contributing to gccgo</a>.)
|
||||
Sensitive security-related issues should be reported to <a href="mailto:security@golang.org">security@golang.org</a>.
|
||||
</p>
|
||||
|
||||
<h1 id="contributor">Becoming a contributor</h1>
|
||||
<h2 id="Design">Discuss your design</h2>
|
||||
|
||||
<p>
|
||||
Before you can contribute to the Go project you need to setup a few prerequisites.
|
||||
The Go project uses <a href="https://www.gerritcodereview.com/">Gerrit</a>, an open
|
||||
source online tool, to perform all code reviews.
|
||||
Gerrit uses your email address as a unique identifier.
|
||||
The Go project contributing flow is currently configured to work only with Google Accounts.
|
||||
You must go through the following process <em>prior to contributing</em>.
|
||||
You only need to do this once per Google Account.
|
||||
The project welcomes submissions but please let everyone know what
|
||||
you're working on if you want to change or add to the Go repositories.
|
||||
</p>
|
||||
|
||||
<h2 id="go-contrib-init">Automatically set up & diagnose your development environment</h3>
|
||||
<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:
|
||||
Before undertaking to write something new for the Go project,
|
||||
please <a href="https://golang.org/issue/new">file an issue</a>
|
||||
(or claim an <a href="https://golang.org/issues">existing issue</a>).
|
||||
Significant changes must go through the
|
||||
<a href="https://golang.org/s/proposal-process">change proposal process</a>
|
||||
before they can be accepted.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
This process gives everyone a chance to validate the design,
|
||||
helps prevent duplication of effort,
|
||||
and ensures that the idea fits inside the goals for the language and tools.
|
||||
It also checks that the design is sound before code is written;
|
||||
the code review tool is not the place for high-level discussions.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
When planning work, please note that the Go project follows a
|
||||
<a href="https://golang.org/wiki/Go-Release-Cycle">six-month
|
||||
development cycle</a>. The latter half of each cycle is a three-month
|
||||
feature freeze during which only bug fixes and doc updates are accepted.
|
||||
New work cannot be submitted during a feature freeze.
|
||||
</p>
|
||||
|
||||
<h2 id="Testing">Testing redux</h2>
|
||||
|
||||
<p>
|
||||
You've <a href="code.html">written and tested your code</a>, but
|
||||
before sending code out for review, run all the tests for the whole
|
||||
tree to make sure the changes don't break other packages or programs:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ go get -u golang.org/x/tools/cmd/go-contrib-init
|
||||
$ cd /code/to/edit
|
||||
$ go-contrib-init
|
||||
$ cd go/src
|
||||
$ ./all.bash
|
||||
</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.
|
||||
You should already have Git installed.
|
||||
(To build under Windows use <code>all.bat</code>.)
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Gerrit uses Google Accounts for authentication.
|
||||
If you don't have a Google Account, you can create an account which
|
||||
After running for a while, the command should print
|
||||
"<code>ALL</code> <code>TESTS</code> <code>PASSED</code>".
|
||||
</p>
|
||||
|
||||
<h2 id="Code_review">Code review</h2>
|
||||
|
||||
<p>
|
||||
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 the code review
|
||||
system called <a href="https://www.gerritcodereview.com/">Gerrit</a>.
|
||||
</p>
|
||||
|
||||
<h3 id="auth">Set up authentication for code review</h3>
|
||||
|
||||
<p>
|
||||
Gerrit uses Google Accounts for authentication. If you don't have
|
||||
a Google Account, you can create an account which
|
||||
<a href="https://www.google.com/accounts/NewAccount">includes
|
||||
a new Gmail email account</a> or create an account associated
|
||||
<a href="https://accounts.google.com/SignUpWithoutGmail">with your existing
|
||||
email address</a>.
|
||||
</p>
|
||||
|
||||
<h3>Step 1: Sign in to googlesource and generate a password</h3>
|
||||
<p>
|
||||
The email address associated with the Google Account you use will be recorded in
|
||||
the <a href="https://go.googlesource.com/go/+log/">change log</a>
|
||||
and in the <a href="/CONTRIBUTORS">contributors file</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Visit <a href="https://go.googlesource.com">go.googlesource.com</a>
|
||||
To set up your account in Gerrit, visit
|
||||
<a href="https://go.googlesource.com">go.googlesource.com</a>
|
||||
and click on "Generate Password" in the page's top right menu bar.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You will be redirected to accounts.google.com to sign in.
|
||||
</p>
|
||||
|
||||
<h3>Step 2: Run the provided script</h3>
|
||||
<p>
|
||||
After signing in, you are taken to a page on go.googlesource.com with the title "Configure Git".
|
||||
This page contains a personalized script which when run locally will configure git
|
||||
to have your unique authentication key.
|
||||
This key is paired with one generated server side similar to how ssh keys work.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Copy and run this script locally in your command line terminal.
|
||||
(On a Windows computer using cmd you should instead follow the instructions
|
||||
in the yellow box to run the command. If you are using git-bash use the same
|
||||
script as *nix.)
|
||||
Once signed in, you are returned back to go.googlesource.com to "Configure Git".
|
||||
Follow the instructions on the page.
|
||||
(If you are on a Windows computer, you should instead follow the instructions
|
||||
in the yellow box to run the command.)
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -92,25 +124,23 @@ Your secret authentication token is now in a <code>.gitcookie</code> file
|
||||
and Git is configured to use this file.
|
||||
</p>
|
||||
|
||||
<h3 id="gerrit">Step 3: Register with Gerrit</h3>
|
||||
<h3 id="gerrit">Register with Gerrit</h3>
|
||||
|
||||
<p>
|
||||
Now that you have your authentication token, you need to register your
|
||||
account with Gerrit.
|
||||
To do this, visit <a href="https://go-review.googlesource.com/login/">
|
||||
go-review.googlesource.com/login/</a>.
|
||||
Sign in using the same Google Account you used above.
|
||||
Now that you have your authentication token,
|
||||
you need to register your account with Gerrit.
|
||||
To do this, visit
|
||||
<a href="https://go-review.googlesource.com/login/">
|
||||
go-review.googlesource.com/login/</a>. You will immediately be redirected
|
||||
to Google Accounts. Sign in using the same Google Account you used above.
|
||||
That is all that is required.
|
||||
</p>
|
||||
|
||||
<h2 id="cla">Contributor License Agreement</h2>
|
||||
|
||||
<h3 id="which_cla">Which CLA</h3>
|
||||
<p>
|
||||
Before sending your first change to the Go project
|
||||
you must have completed one of the following two CLAs.
|
||||
Which CLA you should sign depends on who owns the copyright to your work.
|
||||
</p>
|
||||
<h3 id="cla">Contributor License Agreement</h3>
|
||||
|
||||
<p>Gerrit serves as the gatekeeper and uses your e-mail address as the key.
|
||||
To send your first change to the Go project from a given address,
|
||||
you must have completed one of the contributor license agreements:
|
||||
<ul>
|
||||
<li>
|
||||
If you are the copyright holder, you will need to agree to the
|
||||
@@ -121,49 +151,37 @@ contributor license agreement</a>, which can be completed online.
|
||||
If your organization is the copyright holder, the organization
|
||||
will need to agree to the
|
||||
<a href="https://developers.google.com/open-source/cla/corporate">corporate
|
||||
contributor license agreement</a>.<br>
|
||||
contributor license agreement</a>.
|
||||
(If the copyright holder for your code has already completed the
|
||||
agreement in connection with another Google open source project,
|
||||
it does not need to be completed again.)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
<i>If the copyright holder for your contribution has already completed the
|
||||
agreement in connection with another Google open source project,
|
||||
it does not need to be completed again.</i>
|
||||
</p>
|
||||
|
||||
<h3 id="signing_cla">Completing the CLA</h3>
|
||||
|
||||
<p>
|
||||
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.
|
||||
You can use the links above to create and sign the contributor license agreement
|
||||
or you can show your current agreements and create new ones through the Gerrit
|
||||
interface. <a href="https://go-review.googlesource.com/login/">Log into Gerrit</a>,
|
||||
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>
|
||||
If the copyright holder for the code you are submitting changes — for example,
|
||||
if you start contributing code on behalf of a new company — please send email
|
||||
to golang-dev and let us know, so that we can make sure an appropriate agreement is
|
||||
completed and update the <code>AUTHORS</code> file.
|
||||
This rigmarole only needs to be done for your first submission for each email address.
|
||||
</p>
|
||||
|
||||
<span id="Code_review"></span>
|
||||
<h1 id="prepare_dev_env">Preparing a Development Environment for Contributing</h1>
|
||||
|
||||
<h2 id="git-codereview">Setting up Git for submission to Gerrit</h2>
|
||||
<p>
|
||||
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> Gerrit.
|
||||
If the copyright holder for the code you are submitting changes—for example,
|
||||
if you start contributing code on behalf of a new company—please send email
|
||||
to let us know, so that we can make sure an appropriate agreement is completed
|
||||
and update the <code>AUTHORS</code> file.
|
||||
</p>
|
||||
|
||||
<h3 id="git-codereview_install">Install the git-codereview command</h3>
|
||||
<h3 id="git-codereview">Install the git-codereview command</h3>
|
||||
|
||||
<p>
|
||||
Install the <code>git-codereview</code> command by running,
|
||||
Now install the <code>git-codereview</code> command by running,
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
@@ -183,29 +201,19 @@ $ git codereview help
|
||||
prints help text, not an error.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
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 executible from $GOPATH/bin to this directory.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Note to Git aficionados:</b>
|
||||
The <code>git-codereview</code> command is not required to
|
||||
upload and manage Gerrit code reviews.
|
||||
For those who prefer plain Git, the text below gives the Git equivalent of
|
||||
each git-codereview command.
|
||||
upload and manage Gerrit code reviews. For those who prefer plain Git, the text
|
||||
below gives the Git equivalent of each git-codereview command.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If you do use plain Git, note that you still need the commit hooks that the
|
||||
git-codereview command configures; those hooks add a Gerrit
|
||||
<code>Change-Id</code> line to the commit message and check that all Go source
|
||||
files have been formatted with gofmt.
|
||||
Even if you intend to use plain Git for
|
||||
daily work, install the hooks in a new Git checkout by running
|
||||
<code>git-codereview</code> <code>hooks</code>.
|
||||
<p>If you do use plain
|
||||
Git, note that you still need the commit hooks that the git-codereview command
|
||||
configures; those hooks add a Gerrit <code>Change-Id</code> line to the commit
|
||||
message and check that all Go source files have been formatted with gofmt. Even
|
||||
if you intend to use plain Git for daily work, install the hooks in a new Git
|
||||
checkout by running <code>git-codereview</code> <code>hooks</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -256,8 +264,7 @@ To install them, copy this text into your Git configuration file
|
||||
sync = codereview sync
|
||||
</pre>
|
||||
|
||||
<span id="help"></span>
|
||||
<h3 id="understanding_git-codereview">Understanding the git-codereview command</h3>
|
||||
<h3 id="help">Understanding the git-codereview command</h3>
|
||||
|
||||
<p>After installing the <code>git-codereview</code> command, you can run</p>
|
||||
|
||||
@@ -270,70 +277,11 @@ to learn more about its commands.
|
||||
You can also read the <a href="https://godoc.org/golang.org/x/review/git-codereview">command documentation</a>.
|
||||
</p>
|
||||
|
||||
|
||||
<h1 id="making_a_contribution">Making a Contribution</h1>
|
||||
|
||||
<h2 id="Design">Discuss your design</h2>
|
||||
|
||||
<p>
|
||||
The project welcomes submissions but please let everyone know what
|
||||
you're working on if you want to change or add to the Go repositories.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Before undertaking to write something new for the Go project,
|
||||
please <a href="https://golang.org/issue/new">file an issue</a>
|
||||
(or claim an <a href="https://golang.org/issues">existing issue</a>).
|
||||
Significant changes must go through the
|
||||
<a href="https://golang.org/s/proposal-process">change proposal process</a>
|
||||
before they can be accepted.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
This process gives everyone a chance to validate the design,
|
||||
helps prevent duplication of effort,
|
||||
and ensures that the idea fits inside the goals for the language and tools.
|
||||
It also checks that the design is sound before code is written;
|
||||
the code review tool is not the place for high-level discussions.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
When planning work, please note that the Go project follows a <a
|
||||
href="https://golang.org/wiki/Go-Release-Cycle">six-month development cycle</a>.
|
||||
The latter half of each cycle is a three-month feature freeze during
|
||||
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>
|
||||
|
||||
<h2 id="making_a_change">Making a change</h2>
|
||||
|
||||
<h3 id="checkout_go">Getting Go Source</h3>
|
||||
<p>
|
||||
First you need to have a local copy of the source checked out from the correct
|
||||
repository.
|
||||
As Go builds Go you will also likely need to have a working version
|
||||
of Go installed (some documentation changes may not need this).
|
||||
This should be a recent version of Go and can be obtained via any package or
|
||||
binary distribution or you can build it from source.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You should checkout the Go source repo anywhere you want as long as it's
|
||||
outside of your $GOPATH.
|
||||
Go to a directory where you want the source to appear and run the following
|
||||
command in a terminal.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ git clone https://go.googlesource.com/go
|
||||
$ cd go
|
||||
</pre>
|
||||
|
||||
<h3 id="master">Contributing to the main Go tree</h3>
|
||||
<h3 id="master">Switch to the master branch</h3>
|
||||
|
||||
<p>
|
||||
Most Go installations use a release branch, but new changes should
|
||||
only be made based on the master branch. <br>
|
||||
only be made based on the master branch.
|
||||
(They may be applied later to a release branch as part of the release process,
|
||||
but most contributors won't do this themselves.)
|
||||
Before making a change, make sure you start on the master branch:
|
||||
@@ -349,61 +297,10 @@ $ git sync
|
||||
<code>git</code> <code>pull</code> <code>-r</code>.)
|
||||
</p>
|
||||
|
||||
<h3 id="subrepos">Contributing to subrepositories (golang.org/x/...)</h3>
|
||||
|
||||
<p>
|
||||
If you are contributing a change to a subrepository, obtain the
|
||||
Go package using <code>go get</code>. For example, to contribute
|
||||
to <code>golang.org/x/oauth2</code>, check out the code by running:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ go get -d golang.org/x/oauth2/...
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Then, change your directory to the package's source directory
|
||||
(<code>$GOPATH/src/golang.org/x/oauth2</code>).
|
||||
</p>
|
||||
|
||||
<h3 id="change">Make your changes</h3>
|
||||
|
||||
<p>
|
||||
The entire checked-out tree is editable.
|
||||
Make your changes as you see fit ensuring that you create appropriate
|
||||
tests along with your changes. Test your changes as you go.
|
||||
</p>
|
||||
|
||||
<h3 id="copyright">Copyright</h3>
|
||||
|
||||
<p>
|
||||
Files in the Go repository don't list author names, both to avoid clutter
|
||||
and to avoid having to keep the lists up to date.
|
||||
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 perodically.
|
||||
The <a href="/AUTHORS"><code>AUTHORS</code></a> file defines who “The Go
|
||||
Authors”—the copyright holders—are.
|
||||
</p>
|
||||
|
||||
<p>New files that you contribute should use the standard copyright header:</p>
|
||||
|
||||
<pre>
|
||||
// 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>
|
||||
|
||||
<p>
|
||||
Files in the repository are copyright the year they are added.
|
||||
Do not update the copyright year on files that you change.
|
||||
</p>
|
||||
|
||||
<h3 id="commit_changes">Commit your changes</h3>
|
||||
<h3 id="change">Make a change</h3>
|
||||
|
||||
<p>
|
||||
The entire checked-out tree is writable.
|
||||
Once you have edited files, you must tell Git that they have been modified.
|
||||
You must also tell Git about any files that are added, removed, or renamed files.
|
||||
These operations are done with the usual Git commands,
|
||||
@@ -414,20 +311,16 @@ and
|
||||
</p>
|
||||
|
||||
<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>
|
||||
If you wish to checkpoint your work, or are ready to send the code out for review, run</p>
|
||||
|
||||
<pre>
|
||||
$ git change <i><branch></i>
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
from any directory in your Go repository to commit the changes so far.
|
||||
The name <i><branch></i> is an arbitrary one you choose to identify the
|
||||
local branch containing your changes and will not be used elsewhere.
|
||||
This is an offline operation and nothing will be sent to the server yet.
|
||||
local branch containing your changes.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -438,11 +331,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,
|
||||
Git will open a change description file in your editor.
|
||||
(It uses the editor named by the <code>$EDITOR</code> environment variable,
|
||||
<code>vi</code> by default.)
|
||||
|
||||
The file will look like:
|
||||
</p>
|
||||
|
||||
@@ -461,7 +352,7 @@ At the beginning of this file is a blank line; replace it
|
||||
with a thorough description of your change.
|
||||
The first line of the change description is conventionally a one-line
|
||||
summary of the change, prefixed by the primary affected package,
|
||||
and is used as the subject for code review email.
|
||||
and is used as the subject for code review mail.
|
||||
It should complete the sentence "This change modifies Go to _____."
|
||||
The rest of the description elaborates and should provide context for the
|
||||
change and explain what it does.
|
||||
@@ -496,7 +387,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>
|
||||
@@ -504,7 +395,7 @@ the command and move that file to a different branch.
|
||||
<p>
|
||||
The special notation "Fixes #159" associates the change with issue 159 in the
|
||||
<a href="https://golang.org/issue/159">Go issue tracker</a>.
|
||||
When this change is eventually applied, the issue
|
||||
When this change is eventually submitted, the issue
|
||||
tracker will automatically mark the issue as fixed.
|
||||
(There are several such conventions, described in detail in the
|
||||
<a href="https://help.github.com/articles/closing-issues-via-commit-messages/">GitHub Issue Tracker documentation</a>.)
|
||||
@@ -515,13 +406,6 @@ Once you have finished writing the commit message,
|
||||
save the file and exit the editor.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You must have the $EDITOR environment variable set properly and working properly (exiting cleanly)
|
||||
for this operation to succeed.
|
||||
If you run into any issues at this step, it's likely your editor isn't exiting cleanly.
|
||||
Try setting a different editor in your $EDITOR environment variable.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If you wish to do more editing, re-stage your changes using
|
||||
<code>git</code> <code>add</code>, and then run
|
||||
@@ -532,8 +416,8 @@ $ git change
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
to update the change description and incorporate the staged changes.
|
||||
The change description contains a <code>Change-Id</code> line near the bottom,
|
||||
to update the change description and incorporate the staged changes. The
|
||||
change description contains a <code>Change-Id</code> line near the bottom,
|
||||
added by a Git commit hook during the initial
|
||||
<code>git</code> <code>change</code>.
|
||||
That line is used by Gerrit to match successive uploads of the same change.
|
||||
@@ -545,44 +429,35 @@ Do not edit or delete it.
|
||||
runs <code>git</code> <code>commit</code> <code>--amend</code>.)
|
||||
</p>
|
||||
|
||||
<h3 id="Testing">Testing</h3>
|
||||
<h3 id="mail">Mail the change for review</h3>
|
||||
|
||||
<p>
|
||||
You've <a href="code.html">written and tested your code</a>, but
|
||||
before sending code out for review, run all the tests for the whole
|
||||
tree to make sure the changes don't break other packages or programs:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ cd go/src
|
||||
$ ./all.bash
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
(To build under Windows use <code>all.bat</code>.)
|
||||
</p>
|
||||
|
||||
<p>
|
||||
After running for a while, the command should print
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
"ALL TESTS PASSED".
|
||||
</pre>
|
||||
|
||||
<h3 id="mail">Send the change for review</h3>
|
||||
|
||||
<p>
|
||||
Once the change is ready, send it for review.
|
||||
This is similar to a <code>git push</code> in a GitHub style workflow.
|
||||
This is done via the mail alias setup earlier which despite its name, doesn't
|
||||
directly mail anything, it simply sends the change to Gerrit via git push.
|
||||
Once the change is ready, mail it out for review:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ git mail
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
You can specify a reviewer or CC interested parties
|
||||
using the <code>-r</code> or <code>-cc</code> options.
|
||||
Both accept a comma-separated list of email addresses:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ git mail -r joe@golang.org -cc mabel@example.com,math-nuts@swtch.com
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Unless explicitly told otherwise, such as in the discussion leading
|
||||
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
|
||||
delay before it appears on the mailing list, to prevent spam.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
(In Git terms, <code>git</code> <code>mail</code> pushes the local committed
|
||||
changes to Gerrit using <code>git</code> <code>push</code> <code>origin</code>
|
||||
@@ -591,7 +466,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>
|
||||
@@ -604,76 +479,7 @@ remote: New Changes:
|
||||
remote: https://go-review.googlesource.com/99999 math: improved Sin, Cos and Tan precision for very large arguments
|
||||
</pre>
|
||||
|
||||
<h3>Troubleshooting</h3>
|
||||
|
||||
<p>
|
||||
The most common way that the <code>git mail</code> command fails is because the
|
||||
email address used has not gone through the setup above.
|
||||
<br>
|
||||
If you see something like...
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
remote: Processing changes: refs: 1, done
|
||||
remote:
|
||||
remote: ERROR: In commit ab13517fa29487dcf8b0d48916c51639426c5ee9
|
||||
remote: ERROR: author email address XXXXXXXXXXXXXXXXXXX
|
||||
remote: ERROR: does not match your user account.
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
You need to either add the email address listed to the CLA or set this repo to use
|
||||
another email address already approved.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
First let's change the email address for this repo so this doesn't happen again.
|
||||
You can change your email address for this repo with the following command:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ git config user.email email@address.com
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Then change the previous commit to use this alternative email address.
|
||||
You can do that with:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ git commit --amend --author="Author Name <email@address.com>"
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Finally try to resend with:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ git mail
|
||||
</pre>
|
||||
|
||||
<h3 id="cc">Specifying a reviewer / CCing others</h3>
|
||||
|
||||
<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.
|
||||
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
|
||||
delay before it appears on the mailing list, to prevent spam.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You can specify a reviewer or CC interested parties
|
||||
using the <code>-r</code> or <code>-cc</code> options.
|
||||
Both accept a comma-separated list of email addresses:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ git mail -r joe@golang.org -cc mabel@example.com,math-nuts@swtch.com
|
||||
</pre>
|
||||
|
||||
<h2 id="review">Going through the review process</h2>
|
||||
<h3 id="review">Reviewing code</h3>
|
||||
|
||||
<p>
|
||||
Running <code>git</code> <code>mail</code> will send an email to you and the
|
||||
@@ -685,15 +491,7 @@ 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>
|
||||
|
||||
<p>
|
||||
The Go contribution workflow is optimized for iterative revisions based on
|
||||
feedback.
|
||||
It is rare that an initial contribution will be ready to be applied as is.
|
||||
As you revise your contribution and resend Gerrit will retain a history of
|
||||
all the changes and comments made in the single URL.
|
||||
</p>
|
||||
<h3 id="revise">Revise and upload</h3>
|
||||
|
||||
<p>
|
||||
You must respond to review comments through the web interface.
|
||||
@@ -704,7 +502,7 @@ You must respond to review comments through the web interface.
|
||||
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>
|
||||
|
||||
@@ -736,8 +534,6 @@ $ git sync
|
||||
<code>git</code> <code>pull</code> <code>-r</code>.)
|
||||
</p>
|
||||
|
||||
<h3 id="resolving_conflicts">Resolving Conflicts</h3>
|
||||
|
||||
<p>
|
||||
If files you were editing have changed, Git does its best to merge the
|
||||
remote changes into your local changes.
|
||||
@@ -813,8 +609,8 @@ might turn up:
|
||||
<p>
|
||||
Git doesn't show it, but suppose the original text that both edits
|
||||
started with was 1e8; you changed it to 1e10 and the other change to 1e9,
|
||||
so the correct answer might now be 1e10.
|
||||
First, edit the section to remove the markers and leave the correct code:
|
||||
so the correct answer might now be 1e10. First, edit the section
|
||||
to remove the markers and leave the correct code:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
@@ -843,13 +639,10 @@ restore the change commit.
|
||||
<h3 id="download">Reviewing code by others</h3>
|
||||
|
||||
<p>
|
||||
As part of the review process reviewers can propose changes directly (in the
|
||||
GitHub workflow this would be someone else attaching commits to a pull request).
|
||||
|
||||
You can import these changes proposed by someone else into your local Git repository.
|
||||
You can import a change proposed by someone else into your local Git repository.
|
||||
On the Gerrit review page, click the "Download ▼" link in the upper right
|
||||
corner, copy the "Checkout" command and run it from your local Git repo. It
|
||||
should look something like this:
|
||||
corner, copy the "Checkout" command and run it from your local Git repo.
|
||||
It should look something like this:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
@@ -860,11 +653,11 @@ $ git fetch https://go.googlesource.com/review refs/changes/21/1221/1 &&
|
||||
To revert, change back to the branch you were working in.
|
||||
</p>
|
||||
|
||||
<h2 id="submit">Apply the change to the master branch</h2>
|
||||
<h3 id="submit">Submit the change after the review</h3>
|
||||
|
||||
<p>
|
||||
After the code has been <code>LGTM</code>'ed, an approver may
|
||||
apply it to the master branch using the Gerrit UI.
|
||||
submit it to the master branch using the Gerrit UI.
|
||||
There is a "Submit" button on the web page for the change
|
||||
that appears once the change is approved (marked +2).
|
||||
</p>
|
||||
@@ -876,13 +669,41 @@ and the code review will be updated with a link to the change
|
||||
in the repository.
|
||||
Since the method used to integrate the changes is "Cherry Pick",
|
||||
the commit hashes in the repository will be changed by
|
||||
the "Submit" operation.
|
||||
the submit operation.
|
||||
</p>
|
||||
|
||||
<h2 id="more">More information</h2>
|
||||
<h3 id="more">More information</h3>
|
||||
|
||||
<p>
|
||||
In addition to the information here, the Go community maintains a <a
|
||||
href="https://golang.org/wiki/CodeReview">CodeReview</a> wiki page.
|
||||
In addition to the information here, the Go community maintains a <a href="https://golang.org/wiki/CodeReview">CodeReview</a> wiki page.
|
||||
Feel free to contribute to this page as you learn the review process.
|
||||
</p>
|
||||
|
||||
<h2 id="copyright">Copyright</h2>
|
||||
|
||||
<p>Files in the Go repository don't list author names,
|
||||
both to avoid clutter and to avoid having to keep the lists up to date.
|
||||
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.
|
||||
</p>
|
||||
|
||||
<p>The <a href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file
|
||||
defines who the Go contributors—the people—are;
|
||||
the <a href="/AUTHORS"><code>AUTHORS</code></a> file defines
|
||||
who “The Go Authors”—the copyright holders—are.
|
||||
These files will be periodically updated based on the commit logs.
|
||||
|
||||
<p>Code that you contribute should use the standard copyright header:</p>
|
||||
|
||||
<pre>
|
||||
// Copyright 2016 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>
|
||||
|
||||
<p>
|
||||
Files in the repository are copyright the year they are added. It is not
|
||||
necessary to update the copyright year on files that you change.
|
||||
</p>
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
}-->
|
||||
|
||||
<p><i>
|
||||
This applies to the standard toolchain (the <code>gc</code> Go
|
||||
compiler and tools). Gccgo has native gdb support.
|
||||
This applies to the <code>gc</code> toolchain. 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>
|
||||
@@ -50,14 +49,6 @@ when debugging, pass the flags <code>-gcflags "-N -l"</code> to the
|
||||
debugged.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If you want to use gdb to inspect a core dump, you can trigger a dump
|
||||
on a program crash, on systems that permit it, by setting
|
||||
<code>GOTRACEBACK=crash</code> in the environment (see the
|
||||
<a href="/pkg/runtime/#hdr-Environment_Variables"> runtime package
|
||||
documentation</a> for more info).
|
||||
</p>
|
||||
|
||||
<h3 id="Common_Operations">Common Operations</h3>
|
||||
|
||||
<ul>
|
||||
@@ -139,7 +130,7 @@ the DWARF code.
|
||||
|
||||
<p>
|
||||
If you're interested in what the debugging information looks like, run
|
||||
'<code>objdump -W a.out</code>' and browse through the <code>.debug_*</code>
|
||||
'<code>objdump -W 6.out</code>' and browse through the <code>.debug_*</code>
|
||||
sections.
|
||||
</p>
|
||||
|
||||
@@ -386,9 +377,7 @@ $3 = struct hchan<*testing.T>
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
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.
|
||||
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 it's contents.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -15,98 +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.8.1, Go 1.8.2, and so on).
|
||||
</p>
|
||||
|
||||
<h2 id="go1.8">go1.8 (released 2017/02/16)</h2>
|
||||
|
||||
<p>
|
||||
Go 1.8 is a major release of Go.
|
||||
Read the <a href="/doc/go1.8">Go 1.8 Release Notes</a> for more information.
|
||||
</p>
|
||||
|
||||
<h3 id="go1.8.minor">Minor revisions</h3>
|
||||
|
||||
<p>
|
||||
go1.8.1 (released 2017/04/07) includes fixes to the compiler, linker, runtime,
|
||||
documentation, <code>go</code> command and the <code>crypto/tls</code>,
|
||||
<code>encoding/xml</code>, <code>image/png</code>, <code>net</code>,
|
||||
<code>net/http</code>, <code>reflect</code>, <code>text/template</code>,
|
||||
and <code>time</code> packages.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.8.1">Go
|
||||
1.8.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.8.2 (released 2017/05/23) includes a security fix to the
|
||||
<code>crypto/elliptic</code> package.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.8.2">Go
|
||||
1.8.2 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.8.3 (released 2017/05/24) includes fixes to the compiler, runtime,
|
||||
documentation, and the <code>database/sql</code> package.
|
||||
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>
|
||||
|
||||
<h2 id="go1.7">go1.7 (released 2016/08/15)</h2>
|
||||
|
||||
<p>
|
||||
Go 1.7 is a major release of Go.
|
||||
Read the <a href="/doc/go1.7">Go 1.7 Release Notes</a> for more information.
|
||||
</p>
|
||||
|
||||
<h3 id="go1.7.minor">Minor revisions</h3>
|
||||
|
||||
<p>
|
||||
go1.7.1 (released 2016/09/07) includes fixes to the compiler, runtime,
|
||||
documentation, and the <code>compress/flate</code>, <code>hash/crc32</code>,
|
||||
<code>io</code>, <code>net</code>, <code>net/http</code>,
|
||||
<code>path/filepath</code>, <code>reflect</code>, and <code>syscall</code>
|
||||
packages.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.7.1">Go
|
||||
1.7.1 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.7.2 should not be used. It was tagged but not fully released.
|
||||
The release was deferred due to a last minute bug report.
|
||||
Use go1.7.3 instead, and refer to the summary of changes below.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.7.3 (released 2016/10/19) includes fixes to the compiler, runtime,
|
||||
and the <code>crypto/cipher</code>, <code>crypto/tls</code>,
|
||||
<code>net/http</code>, and <code>strings</code> packages.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.7.3">Go
|
||||
1.7.3 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.7.4 (released 2016/12/01) includes two security fixes.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.7.4">Go
|
||||
1.7.4 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.7.5 (released 2017/01/26) includes fixes to the compiler, runtime,
|
||||
and the <code>crypto/x509</code> and <code>time</code> packages.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.7.5">Go
|
||||
1.7.5 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.7.6 (released 2017/05/23) includes the same security fix as Go 1.8.2 and
|
||||
was released at the same time.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.8.2">Go
|
||||
1.8.2 milestone</a> 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.6">go1.6 (released 2016/02/17)</h2>
|
||||
@@ -135,18 +56,11 @@ See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.6.2">Go
|
||||
<p>
|
||||
go1.6.3 (released 2016/07/17) includes security fixes to the
|
||||
<code>net/http/cgi</code> package and <code>net/http</code> package when used in
|
||||
a CGI environment.
|
||||
a CGI environment. This release also adds support for macOS Sierra.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.6.3">Go
|
||||
1.6.3 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.6.4 (released 2016/12/01) includes two security fixes.
|
||||
It contains the same fixes as Go 1.7.4 and was released at the same time.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.7.4">Go
|
||||
1.7.4 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<h2 id="go1.5">go1.5 (released 2015/08/19)</h2>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -519,7 +519,7 @@ Other changes:
|
||||
fix FreeBSD signal handling around thread creation (thanks Devon H. O'Dell),
|
||||
goroutine profile, stack dumps,
|
||||
implement runtime.osyield on FreeBSD 386, amd64 (thanks Devon H. O'Dell),
|
||||
permit default behavior of SIGTSTP, SIGTTIN, SIGTTOU,
|
||||
permit default behaviour of SIGTSTP, SIGTTIN, SIGTTOU,
|
||||
release unused memory to the OS (thanks Sébastien Paolacci),
|
||||
remove an obsolete file (thanks Mikio Hara).
|
||||
* spec: make all comparison results untyped bool,
|
||||
@@ -2450,7 +2450,7 @@ The http package's URL parsing and query escaping code (such as ParseURL and
|
||||
URLEscape) has been moved to the new url package, with several simplifications
|
||||
to the names. Client code can be updated automatically with gofix.
|
||||
|
||||
* asn1: support unmarshaling structs with int32 members (thanks Dave Cheney).
|
||||
* asn1: support unmarshalling structs with int32 members (thanks Dave Cheney).
|
||||
* build: allow builds without cgo or hg,
|
||||
support versioning without hg (thanks Gustavo Niemeyer).
|
||||
* builtin: add documentation for builtins.
|
||||
@@ -3030,7 +3030,7 @@ Other changes:
|
||||
* 5g: alignment fixes.
|
||||
* 6l, 8l: fix Mach-O binaries with many dynamic libraries.
|
||||
* 8l: emit resources (.rsrc) in Windows PE. (thanks Wei Guangjing).
|
||||
* asn1: fix marshaling of empty optional RawValues (thanks Mikkel Krautz).
|
||||
* asn1: fix marshalling of empty optional RawValues (thanks Mikkel Krautz).
|
||||
* big: make Int and Rat implement fmt.Scanner (thanks Evan Shaw),
|
||||
~8x faster number scanning,
|
||||
remove some unnecessary conversions.
|
||||
@@ -4157,7 +4157,7 @@ Other changes in this release:
|
||||
* suffixarray: use binary search for both ends of Lookup (thanks Eric Eisner).
|
||||
* syscall: add missing network interface constants (thanks Mikio Hara).
|
||||
* template: treat map keys as zero, not non-existent (thanks Roger Peppe).
|
||||
* time: allow canceling of After events (thanks Roger Peppe),
|
||||
* time: allow cancelling of After events (thanks Roger Peppe),
|
||||
support Solaris zoneinfo directory.
|
||||
* token/position: added SetLinesForContent.
|
||||
* unicode: update to unicode 6.0.0.
|
||||
@@ -4238,7 +4238,7 @@ example: http://golang.org/pkg/xml/
|
||||
<pre>
|
||||
The json, gob, and template packages have changed, and code that uses them
|
||||
may need to be updated after this release. They will no longer read or write
|
||||
unexported struct fields. When marshaling a struct with json or gob the
|
||||
unexported struct fields. When marshalling a struct with json or gob the
|
||||
unexported fields will be silently ignored. Attempting to unmarshal json or
|
||||
gob data into an unexported field will generate an error. Accessing an
|
||||
unexported field from a template will cause the Execute function to return
|
||||
@@ -5682,7 +5682,7 @@ Other changes:
|
||||
pidigits ~10% performance win by using adds instead of shifts.
|
||||
* time: remove incorrect time.ISO8601 and add time.RFC3339 (thanks Micah Stetson).
|
||||
* utf16: add DecodeRune, EncodeRune.
|
||||
* xml: add support for XML marshaling embedded structs (thanks Raif S. Naffah),
|
||||
* xml: add support for XML marshalling embedded structs (thanks Raif S. Naffah),
|
||||
new "innerxml" tag to collect inner XML.
|
||||
</pre>
|
||||
|
||||
@@ -5696,7 +5696,7 @@ This release contains many changes:
|
||||
* cmath: new complex math library (thanks Charles L. Dorian).
|
||||
* docs: update to match current coding style (thanks Christopher Wedgwood).
|
||||
* exp/eval: fix example and add target to Makefile (thanks Evan Shaw).
|
||||
* fmt: change behavior of format verb %b to match %x when negative (thanks Andrei Vieru).
|
||||
* fmt: change behaviour of format verb %b to match %x when negative (thanks Andrei Vieru).
|
||||
* gc: compile s == "" as len(s) == 0,
|
||||
distinguish fatal compiler bug from error+exit,
|
||||
fix alignment on non-amd64,
|
||||
@@ -5925,10 +5925,10 @@ Other changes and fixes:
|
||||
* 8a/8l: Added CMOVcc instructions (thanks Evan Shaw)
|
||||
* 8l: pe executable building code changed to include import table for kernel32.dll functions (thanks Alex Brainman)
|
||||
* 5g/6g/8g: bug fixes
|
||||
* asn1: bug fixes and additions (incl marshaling)
|
||||
* asn1: bug fixes and additions (incl marshalling)
|
||||
* build: fix build for Native Client, Linux/ARM
|
||||
* dashboard: show benchmarks, add garbage collector benchmarks
|
||||
* encoding/pem: add marshaling support
|
||||
* encoding/pem: add marshalling support
|
||||
* exp/draw: fast paths for a nil mask
|
||||
* godoc: support for directories outside $GOROOT
|
||||
* http: sort header keys when writing Response or Request to wire (thanks Petar Maymounkov)
|
||||
|
||||
@@ -40,13 +40,7 @@ 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 <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>
|
||||
This will place the <code>gotour</code> binary in your workspace's <code>bin</code> directory.
|
||||
<a href="//code.google.com/p/go-tour/">install it locally</a>.
|
||||
</p>
|
||||
|
||||
<h3 id="code"><a href="code.html">How to write Go code</a></h3>
|
||||
@@ -57,12 +51,6 @@ 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.
|
||||
</p>
|
||||
|
||||
<h3 id="effective_go"><a href="effective_go.html">Effective Go</a></h3>
|
||||
<p>
|
||||
A document that gives tips for writing clear, idiomatic Go code.
|
||||
|
||||
210
doc/editors.html
210
doc/editors.html
@@ -1,210 +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 Go</a>: a plugin for Vim to provide Go programming language support</li>
|
||||
<li><a href="https://marketplace.visualstudio.com/items?itemName=lukehoban.Go">Visual Studio Code Go</a>:
|
||||
an extension for Visual Studio Code to provide support for the Go programming language</li>
|
||||
<li><a href="https://www.jetbrains.com/go">Gogland</a>: Gogland is distributed either as a standalone IDE
|
||||
or as a plugin for the IntelliJ Platform IDEs</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>
|
||||
|
||||
<p>
|
||||
Each development environment integrates a number of Go-specific tools.
|
||||
The following feature matrix lists and compares the most significant features.
|
||||
</p>
|
||||
|
||||
<table class="features-matrix">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><img title="Vim Go" src="/doc/editors/vimgo.png"><br>Vim Go</th>
|
||||
<th><img title="Visual Studio Code" src="/doc/editors/vscodego.png"><br>Visual Studio Code Go</th>
|
||||
<th><img title="Gogland" src="/doc/editors/gogland.png"><br>Gogland</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="feature-row" colspan="4">Editing features</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Build and run from the editor/IDE</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Autocompletion of identifers (variable, method, and function names)</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Autocompletion based on type</td>
|
||||
<td class="no">No</td>
|
||||
<td class="no">No</td>
|
||||
<td class="yes">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Rename identifiers</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Auto format, build, vet, and lint on save</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes<sup>1</sup></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Auto insert import paths and remove unused on save</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes<sup>2</sup></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Auto generate JSON, XML tags for struct fields</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="feature-row" colspan="4">Navigation features</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Display documentation inline, or open godoc in browser</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Switch between <code>*.go</code> and <code>*_test.go</code> file</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Jump to definition and referees</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Look up for interface implementations</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Search for callers and callees</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="feature-row" colspan="4">Testing and debugging features</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Debugger support</td>
|
||||
<td class="no">No</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Run a single test case, all tests from file, or all tests from a package</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Auto generate tests for packages, files and identifiers</td>
|
||||
<td class="no">No</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="no">No</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Debug tests</td>
|
||||
<td class="no">No</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Display test coverage</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
<td class="yes">Yes</td>
|
||||
</tr>
|
||||
<tr class="download">
|
||||
<td></td>
|
||||
<td><a href="https://github.com/fatih/vim-go">Install<a/></td>
|
||||
<td><a href="https://marketplace.visualstudio.com/items?itemName=lukehoban.Go">Install<a/></td>
|
||||
<td><a href="https://www.jetbrains.com/go">Install<a/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<sup>1</sup>: Possible when enabled via Settings > Go > On Save, <code>go</code> <code>vet</code> and <code>golint</code> are available via plugins. Also runs tests on save if configured.
|
||||
<br>
|
||||
<sup>2</sup>: Additionally, user input can disambiguate when two or more options are available.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.features-matrix {
|
||||
min-width: 800px;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.features-matrix th {
|
||||
width: 60px;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
.features-matrix th img {
|
||||
width: 48px;
|
||||
}
|
||||
.features-matrix .yes {
|
||||
text-align: center;
|
||||
}
|
||||
.features-matrix .no {
|
||||
text-align: center;
|
||||
background-color: #ffe9e9;
|
||||
}
|
||||
.features-matrix .download {
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
.features-matrix td {
|
||||
padding: 11px 5px 11px 5px;
|
||||
border-bottom: solid 1px #ebebeb;
|
||||
}
|
||||
.features-matrix .feature-row {
|
||||
background-color: #ebebeb;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!--TODO(jbd): Add the Atom comparison-->
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 9.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 7.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.3 KiB |
@@ -245,15 +245,15 @@ func Compile(str string) (*Regexp, error) {
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
If every doc comment begins with the name of the item it describes,
|
||||
the output of <code>godoc</code> can usefully be run through <code>grep</code>.
|
||||
If the name always begins the comment, the output of <code>godoc</code>
|
||||
can usefully be run through <code>grep</code>.
|
||||
Imagine you couldn't remember the name "Compile" but were looking for
|
||||
the parsing function for regular expressions, so you ran
|
||||
the command,
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ godoc regexp | grep -i parse
|
||||
$ godoc regexp | grep parse
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -1580,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>
|
||||
@@ -1833,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
|
||||
@@ -2409,7 +2409,7 @@ The <code>http</code> package contains this code:
|
||||
// Handler object that calls f.
|
||||
type HandlerFunc func(ResponseWriter, *Request)
|
||||
|
||||
// ServeHTTP calls f(w, req).
|
||||
// ServeHTTP calls f(c, req).
|
||||
func (f HandlerFunc) ServeHTTP(w ResponseWriter, req *Request) {
|
||||
f(w, req)
|
||||
}
|
||||
@@ -2447,7 +2447,7 @@ the handler installed at that page has value <code>ArgServer</code>
|
||||
and type <code>HandlerFunc</code>.
|
||||
The HTTP server will invoke the method <code>ServeHTTP</code>
|
||||
of that type, with <code>ArgServer</code> as the receiver, which will in turn call
|
||||
<code>ArgServer</code> (via the invocation <code>f(w, req)</code>
|
||||
<code>ArgServer</code> (via the invocation <code>f(c, req)</code>
|
||||
inside <code>HandlerFunc.ServeHTTP</code>).
|
||||
The arguments will then be displayed.
|
||||
</p>
|
||||
|
||||
@@ -12,7 +12,7 @@ information on building gccgo for yourself,
|
||||
see <a href="/doc/gccgo_install.html">Setting up and using gccgo</a>.
|
||||
For more of the gritty details on the process of doing development
|
||||
with the gccgo frontend,
|
||||
see <a href="https://go.googlesource.com/gofrontend/+/master/HACKING">the
|
||||
see <a href="https://code.google.com/p/gofrontend/source/browse/HACKING">the
|
||||
file HACKING</a> in the gofrontend repository.
|
||||
</p>
|
||||
|
||||
|
||||
@@ -52,19 +52,6 @@ user libraries. The Go 1.4 runtime is not fully merged, but that
|
||||
should not be visible to Go programs.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The GCC 6 releases include a complete implementation of the Go 1.6.1
|
||||
user libraries. The Go 1.6 runtime is not fully merged, but that
|
||||
should not be visible to Go programs.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
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>
|
||||
|
||||
<p>
|
||||
@@ -173,6 +160,23 @@ make
|
||||
make install
|
||||
</pre>
|
||||
|
||||
<h3 id="Ubuntu">A note on Ubuntu</h3>
|
||||
|
||||
<p>
|
||||
Current versions of Ubuntu and versions of GCC before 4.8 disagree on
|
||||
where system libraries and header files are found. This is not a
|
||||
gccgo issue. When building older versions of GCC, setting these
|
||||
environment variables while configuring and building gccgo may fix the
|
||||
problem.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
|
||||
C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu
|
||||
CPLUS_INCLUDE_PATH=/usr/include/x86_64-linux-gnu
|
||||
export LIBRARY_PATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH
|
||||
</pre>
|
||||
|
||||
<h2 id="Using_gccgo">Using gccgo</h2>
|
||||
|
||||
<p>
|
||||
@@ -360,15 +364,12 @@ or with C++ code compiled using <code>extern "C"</code>.
|
||||
<h3 id="Types">Types</h3>
|
||||
|
||||
<p>
|
||||
Basic types map directly: an <code>int32</code> in Go is
|
||||
an <code>int32_t</code> in C, an <code>int64</code> is
|
||||
an <code>int64_t</code>, etc.
|
||||
The Go type <code>int</code> is an integer that is the same size as a
|
||||
pointer, and as such corresponds to the C type <code>intptr_t</code>.
|
||||
Go <code>byte</code> is equivalent to C <code>unsigned char</code>.
|
||||
Pointers in Go are pointers in C.
|
||||
A Go <code>struct</code> is the same as C <code>struct</code> with the
|
||||
same fields and types.
|
||||
Basic types map directly: an <code>int</code> in Go is an <code>int</code>
|
||||
in C, an <code>int32</code> is an <code>int32_t</code>,
|
||||
etc. Go <code>byte</code> is equivalent to C <code>unsigned
|
||||
char</code>.
|
||||
Pointers in Go are pointers in C. A Go <code>struct</code> is the same as C
|
||||
<code>struct</code> with the same fields and types.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -379,7 +380,7 @@ structure (this is <b style="color: red;">subject to change</b>):
|
||||
<pre>
|
||||
struct __go_string {
|
||||
const unsigned char *__data;
|
||||
intptr_t __length;
|
||||
int __length;
|
||||
};
|
||||
</pre>
|
||||
|
||||
@@ -399,8 +400,8 @@ A slice in Go is a structure. The current definition is
|
||||
<pre>
|
||||
struct __go_slice {
|
||||
void *__values;
|
||||
intptr_t __count;
|
||||
intptr_t __capacity;
|
||||
int __count;
|
||||
int __capacity;
|
||||
};
|
||||
</pre>
|
||||
|
||||
@@ -525,3 +526,15 @@ This procedure is full of unstated caveats and restrictions and we make no
|
||||
guarantee that it will not change in the future. It is more useful as a
|
||||
starting point for real Go code than as a regular procedure.
|
||||
</p>
|
||||
|
||||
<h2 id="RTEMS_Port">RTEMS Port</h2>
|
||||
<p>
|
||||
The gccgo compiler has been ported to <a href="http://www.rtems.com/">
|
||||
<code>RTEMS</code></a>. <code>RTEMS</code> is a real-time executive
|
||||
that provides a high performance environment for embedded applications
|
||||
on a range of processors and embedded hardware. The current gccgo
|
||||
port is for x86. The goal is to extend the port to most of the
|
||||
<a href="http://www.rtems.org/wiki/index.php/SupportedCPUs">
|
||||
architectures supported by <code>RTEMS</code></a>. For more information on the port,
|
||||
as well as instructions on how to install it, please see this
|
||||
<a href="http://www.rtems.org/wiki/index.php/GCCGoRTEMS"><code>RTEMS</code> Wiki page</a>.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!--{
|
||||
"Title": "Go 1.7 Release Notes",
|
||||
"Title": "Go 1.7 Release Notes DRAFT",
|
||||
"Path": "/doc/go1.7",
|
||||
"Template": true
|
||||
}-->
|
||||
@@ -25,6 +25,15 @@ Do not send CLs removing the interior tags from such phrases.
|
||||
ul li { margin: 0.5em 0; }
|
||||
</style>
|
||||
|
||||
<p>
|
||||
<!-- TODO: REMOVE THIS COMMENT -->
|
||||
<!-- TODO: Also remove "DRAFT" in the "Title" at the top of this file. -->
|
||||
<i>NOTE: This is a DRAFT of the Go 1.7 release notes, prepared for the Go 1.7 beta.
|
||||
Go 1.7 has NOT yet been released.
|
||||
By our regular schedule, it is expected some time in August 2016.
|
||||
</i>
|
||||
</p>
|
||||
|
||||
<h2 id="introduction">Introduction to Go 1.7</h2>
|
||||
|
||||
<p>
|
||||
@@ -43,7 +52,7 @@ includes the <a href="#context">context package</a>, promoted from the
|
||||
and now used in the standard library;
|
||||
and <a href="#testing">adds support in the testing package</a> for
|
||||
creating hierarchies of tests and benchmarks.
|
||||
The release also <a href="#cmd_go">finalizes the vendoring support</a>
|
||||
The release also <a href="#cmd/go">finalizes the vendoring support</a>
|
||||
started in Go 1.5, making it a standard feature.
|
||||
</p>
|
||||
|
||||
@@ -67,7 +76,8 @@ This change has no effect on the correctness of existing programs.
|
||||
|
||||
<p>
|
||||
Go 1.7 adds support for macOS 10.12 Sierra.
|
||||
Binaries built with versions of Go before 1.7 will not work
|
||||
This support was backported to Go 1.6.3.
|
||||
Binaries built with versions of Go before 1.6.3 will not work
|
||||
correctly on Sierra.
|
||||
</p>
|
||||
|
||||
@@ -357,7 +367,7 @@ the code generation changes alone typically reduce program CPU time by 5-35%.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<!-- git log -''-grep '-[0-9][0-9]\.[0-9][0-9]%' go1.6.. -->
|
||||
<!-- git log --grep '-[0-9][0-9]\.[0-9][0-9]%' go1.6.. -->
|
||||
There have been significant optimizations bringing more than 10% improvements
|
||||
to implementations in the
|
||||
<a href="/pkg/crypto/sha1/"><code>crypto/sha1</code></a>,
|
||||
@@ -394,9 +404,9 @@ This allows the use of contexts for cancelation, timeouts, and passing
|
||||
request-scoped data in other standard library packages,
|
||||
including
|
||||
<a href="#net">net</a>,
|
||||
<a href="#net_http">net/http</a>,
|
||||
<a href="#net/http">net/http</a>,
|
||||
and
|
||||
<a href="#os_exec">os/exec</a>,
|
||||
<a href="#os/exec">os/exec</a>,
|
||||
as noted below.
|
||||
</p>
|
||||
|
||||
@@ -552,9 +562,10 @@ The
|
||||
|
||||
<dd>
|
||||
<p>
|
||||
There are many performance optimizations throughout the package.
|
||||
As noted above,
|
||||
there are significant performance optimizations throughout the package.
|
||||
Decompression speed is improved by about 10%,
|
||||
while compression for <code>DefaultCompression</code> is twice as fast.
|
||||
while compression speed for <code>DefaultCompression</code> is roughly doubled.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -908,7 +919,7 @@ For example, the address on which a request received is
|
||||
<p>
|
||||
The server's <a href="/pkg/net/http/#Server.Serve"><code>Serve</code></a> method
|
||||
now only enables HTTP/2 support if the <code>Server.TLSConfig</code> field is <code>nil</code>
|
||||
or includes <code>"h2"</code> in its <code>TLSConfig.NextProtos</code>.
|
||||
or includes <code>"h2"</code> in its <code>TLSConfig.NextProto</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
1666
doc/go1.8.html
1666
doc/go1.8.html
File diff suppressed because it is too large
Load Diff
985
doc/go1.9.html
985
doc/go1.9.html
@@ -1,985 +0,0 @@
|
||||
<!--{
|
||||
"Title": "Go 1.9 Release Notes",
|
||||
"Path": "/doc/go1.9",
|
||||
"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.
|
||||
-->
|
||||
|
||||
<style>
|
||||
ul li { margin: 0.5em 0; }
|
||||
</style>
|
||||
|
||||
<h2 id="introduction">DRAFT RELEASE NOTES - Introduction to Go 1.9</h2>
|
||||
|
||||
<p><strong>
|
||||
Go 1.9 is not yet released. These are work-in-progress
|
||||
release notes. Go 1.9 is expected to be released in August 2017.
|
||||
</strong></p>
|
||||
|
||||
<p>
|
||||
The latest Go release, version 1.9, arrives six months
|
||||
after <a href="go1.8">Go 1.8</a> and is the tenth release in
|
||||
the <a href="https://golang.org/doc/devel/release.html">Go 1.x
|
||||
series</a>.
|
||||
There are two <a href="#language">changes to the language</a>:
|
||||
adding support for type aliases and defining when implementations
|
||||
may fuse floating point operations.
|
||||
Most of the changes are in the implementation of the toolchain,
|
||||
runtime, and libraries.
|
||||
As always, the release maintains the Go 1
|
||||
<a href="/doc/go1compat.html">promise of compatibility</a>.
|
||||
We expect almost all Go programs to continue to compile and run as
|
||||
before.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The release
|
||||
adds <a href="#monotonic-time">transparent monotonic time support</a>,
|
||||
<a href="#parallel-compile">parallelizes compilation of functions</a> within a package,
|
||||
better supports <a href="#test-helper">test helper functions</a>,
|
||||
includes a new <a href="#math-bits">bit manipulation package</a>,
|
||||
and has a new <a href="#sync-map">concurrent map type</a>.
|
||||
</p>
|
||||
|
||||
<h2 id="language">Changes to the language</h2>
|
||||
|
||||
<p>
|
||||
There are two changes to the language.
|
||||
</p>
|
||||
<p>
|
||||
Go now supports type aliases to support gradual code repair while
|
||||
moving a type between packages.
|
||||
The <a href="https://golang.org/design/18130-type-alias">type alias
|
||||
design document</a>
|
||||
and <a href="https://talks.golang.org/2016/refactor.article">an
|
||||
article on refactoring</a> cover the problem in detail.
|
||||
In short, a type alias declaration has the form:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
type T1 = T2
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
This declaration introduces an alias name <code>T1</code>—an
|
||||
alternate spelling—for the type denoted by <code>T2</code>; that is,
|
||||
both <code>T1</code> and <code>T2</code> denote the same type.
|
||||
</p>
|
||||
|
||||
<p> <!-- CL 40391 -->
|
||||
A smaller language change is that the
|
||||
<a href="/ref/spec#Floating_point_operators">language specification
|
||||
now states</a> when implementations are allowed to fuse floating
|
||||
point operations together, such as by using an architecture's "fused
|
||||
multiply and add" (FMA) instruction to compute <code>x*y</code> <code>+</code> <code>z</code>
|
||||
without rounding the intermediate result <code>x*y</code>.
|
||||
To force the intermediate rounding, write <code>float64(x*y)</code> <code>+</code> <code>z</code>.
|
||||
</p>
|
||||
|
||||
<h2 id="ports">Ports</h2>
|
||||
|
||||
<p>
|
||||
There are no new supported operating systems or processor
|
||||
architectures in this release.
|
||||
</p>
|
||||
|
||||
<h3 id="power8">ppc64x requires POWER8</h3>
|
||||
|
||||
<p> <!-- CL 36725, CL 36832 -->
|
||||
Both <code>GOARCH=ppc64</code> and <code>GOARCH=ppc64le</code> now
|
||||
require at least POWER8 support. In previous releases,
|
||||
only <code>GOARCH=ppc64le</code> required POWER8 and the big
|
||||
endian <code>ppc64</code> architecture supported older
|
||||
hardware.
|
||||
<p>
|
||||
|
||||
<h3 id="freebsd">FreeBSD</h3>
|
||||
|
||||
<p>
|
||||
Go 1.9 is the last release that will run on FreeBSD 9.3,
|
||||
which is already
|
||||
<a href="https://www.freebsd.org/security/unsupported.html">unsupported by FreeBSD</a>.
|
||||
Go 1.10 will require FreeBSD 10.3+.
|
||||
</p>
|
||||
|
||||
<h3 id="openbsd">OpenBSD 6.0</h3>
|
||||
|
||||
<p> <!-- CL 40331 -->
|
||||
Go 1.9 now enables PT_TLS generation for cgo binaries and thus
|
||||
requires OpenBSD 6.0 or newer. Go 1.9 no longer supports
|
||||
OpenBSD 5.9.
|
||||
<p>
|
||||
|
||||
<h3 id="known_issues">Known Issues</h3>
|
||||
|
||||
<p>
|
||||
There are some instabilities on FreeBSD that are known but not understood.
|
||||
These can lead to program crashes in rare cases.
|
||||
See <a href="https://golang.org/issue/15658">issue 15658</a>.
|
||||
Any help in solving this FreeBSD-specific issue would be appreciated.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Go stopped running NetBSD builders during the Go 1.9 development
|
||||
cycle due to NetBSD kernel crashes, up to and including NetBSD 7.1.
|
||||
As Go 1.9 is being released, NetBSD 7.1.1 is being released with a fix.
|
||||
However, at this time we have no NetBSD builders passing our test suite.
|
||||
Any help investigating the
|
||||
<a href="https://github.com/golang/go/labels/OS-NetBSD">various NetBSD issues</a>
|
||||
would be appreciated.
|
||||
</p>
|
||||
|
||||
<h2 id="tools">Tools</h2>
|
||||
|
||||
<h3 id="parallel-compile">Parallel Compilation</h3>
|
||||
|
||||
<p>
|
||||
The Go compiler now supports compiling a package's functions in parallel, taking
|
||||
advantage of multiple cores. This is in addition to the <code>go</code> command's
|
||||
existing support for parallel compilation of separate packages.
|
||||
Parallel compilation is on by default, but it can be disabled by setting the
|
||||
environment variable <code>GO19CONCURRENTCOMPILATION</code> to <code>0</code>.
|
||||
</p>
|
||||
|
||||
<h3 id="vendor-dotdotdot">Vendor matching with ./...</h3>
|
||||
|
||||
<p><!-- CL 38745 -->
|
||||
By popular request, <code>./...</code> no longer matches packages
|
||||
in <code>vendor</code> directories in tools accepting package names,
|
||||
such as <code>go</code> <code>test</code>. To match vendor
|
||||
directories, write <code>./vendor/...</code>.
|
||||
</p>
|
||||
|
||||
<h3 id="compiler">Compiler Toolchain</h3>
|
||||
|
||||
<p><!-- CL 37441 -->
|
||||
Complex division is now C99-compatible. This has always been the
|
||||
case in gccgo and is now fixed in the gc toolchain.
|
||||
</p>
|
||||
|
||||
<p> <!-- CL 36983 -->
|
||||
The linker will now generate DWARF information for cgo executables on Windows.
|
||||
</p>
|
||||
|
||||
<p> <!-- CL 44210, CL 40095 -->
|
||||
The compiler now includes lexical scopes in the generated DWARF if the
|
||||
<code>-N -l</code> flags are provided, allowing
|
||||
debuggers to hide variables that are not in scope. The <code>.debug_info</code>
|
||||
section is now DWARF version 4.
|
||||
</p>
|
||||
|
||||
<p> <!-- CL 43855 -->
|
||||
The values of <code>GOARM</code> and <code>GO386</code> now affect a
|
||||
compiled package's build ID, as used by the <code>go</code> tool's
|
||||
dependency caching.
|
||||
</p>
|
||||
|
||||
<h3 id="asm">Assembler</h3>
|
||||
|
||||
<p> <!-- CL 42028 -->
|
||||
The four-operand ARM <code>MULA</code> instruction is now assembled correctly,
|
||||
with the addend register as the third argument and the result
|
||||
register as the fourth and final argument.
|
||||
In previous releases, the two meanings were reversed.
|
||||
The three-operand form, in which the fourth argument is implicitly
|
||||
the same as the third, is unaffected.
|
||||
Code using four-operand <code>MULA</code> instructions
|
||||
will need to be updated, but we believe this form is very rarely used.
|
||||
<code>MULAWT</code> and <code>MULAWB</code> were already
|
||||
using the correct order in all forms and are unchanged.
|
||||
</p>
|
||||
|
||||
<p> <!-- CL 42990 -->
|
||||
The assembler now supports <code>ADDSUBPS/PD</code>, completing the
|
||||
two missing x86 SSE3 instructions.
|
||||
</p>
|
||||
|
||||
<h3 id="go-doc">Doc</h3>
|
||||
|
||||
<p><!-- CL 36031 -->
|
||||
Long lists of arguments are now truncated. This improves the readability
|
||||
of <code>go</code> <code>doc</code> on some generated code.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 38438 -->
|
||||
Viewing documentation on struct fields is now supported.
|
||||
For example, <code>go</code> <code>doc</code> <code>http.Client.Jar</code>.
|
||||
</p>
|
||||
|
||||
<h3 id="go-env-json">Env</h3>
|
||||
|
||||
<p> <!-- CL 38757 -->
|
||||
The new <code>go</code> <code>env</code> <code>-json</code> flag
|
||||
enables JSON output, instead of the default OS-specific output
|
||||
format.
|
||||
</p>
|
||||
|
||||
<h3 id="go-test-list">Test</h3>
|
||||
|
||||
<p> <!-- CL 41195 -->
|
||||
The <a href="/cmd/go/#hdr-Description_of_testing_flags"><code>go</code> <code>test</code></a>
|
||||
command accepts a new <code>-list</code> flag, which takes a regular
|
||||
expression as an argument and prints to stdout the name of any
|
||||
tests, benchmarks, or examples that match it, without running them.
|
||||
</p>
|
||||
|
||||
|
||||
<h3 id="go-tool-pprof">Pprof</h3>
|
||||
|
||||
<p> <!-- CL 34192 -->
|
||||
Profiles produced by the <code>runtime/pprof</code> package now
|
||||
include symbol information, so they can be viewed
|
||||
in <code>go</code> <code>tool</code> <code>pprof</code>
|
||||
without the binary that produced the profile.
|
||||
</p>
|
||||
|
||||
<p> <!-- CL 38343 -->
|
||||
The <code>go</code> <code>tool</code> <code>pprof</code> command now
|
||||
uses the HTTP proxy information defined in the environment, using
|
||||
<a href="/pkg/net/http/#ProxyFromEnvironment"><code>http.ProxyFromEnvironment</code></a>.
|
||||
</p>
|
||||
|
||||
<h3 id="vet">Vet</h3>
|
||||
|
||||
<!-- CL 40112 -->
|
||||
<p>
|
||||
The <a href="/cmd/vet/"><code>vet</code> command</a>
|
||||
has been better integrated into the
|
||||
<a href="/cmd/go/"><code>go</code> tool</a>,
|
||||
so <code>go</code> <code>vet</code> now supports all standard build
|
||||
flags while <code>vet</code>'s own flags are now available
|
||||
from <code>go</code> <code>vet</code> as well as
|
||||
from <code>go</code> <code>tool</code> <code>vet</code>.
|
||||
</p>
|
||||
|
||||
<h3 id="gccgo">Gccgo</h3>
|
||||
|
||||
<p>
|
||||
Due to the alignment of Go's semiannual release schedule with GCC's
|
||||
annual release schedule,
|
||||
GCC release 7 contains the Go 1.8.3 version of gccgo.
|
||||
We expect that the next release, GCC 8, will contain the Go 1.10
|
||||
version of gccgo.
|
||||
</p>
|
||||
|
||||
<h2 id="runtime">Runtime</h2>
|
||||
|
||||
<h3 id="callersframes">Call stacks with inlined frames</h3>
|
||||
|
||||
<p>
|
||||
Users of
|
||||
<a href="/pkg/runtime#Callers"><code>runtime.Callers</code></a>
|
||||
should avoid directly inspecting the resulting PC slice and instead use
|
||||
<a href="/pkg/runtime#CallersFrames"><code>runtime.CallersFrames</code></a>
|
||||
to get a complete view of the call stack, or
|
||||
<a href="/pkg/runtime#Caller"><code>runtime.Caller</code></a>
|
||||
to get information about a single caller.
|
||||
This is because an individual element of the PC slice cannot account
|
||||
for inlined frames or other nuances of the call stack.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Specifically, code that directly iterates over the PC slice and uses
|
||||
functions such as
|
||||
<a href="/pkg/runtime#FuncForPC"><code>runtime.FuncForPC</code></a>
|
||||
to resolve each PC individually will miss inlined frames.
|
||||
To get a complete view of the stack, such code should instead use
|
||||
<code>CallersFrames</code>.
|
||||
Likewise, code should not assume that the length returned by
|
||||
<code>Callers</code> is any indication of the call depth.
|
||||
It should instead count the number of frames returned by
|
||||
<code>CallersFrames</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Code that queries a single caller at a specific depth should use
|
||||
<code>Caller</code> rather than passing a slice of length 1 to
|
||||
<code>Callers</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="/pkg/runtime#CallersFrames"><code>runtime.CallersFrames</code></a>
|
||||
has been available since Go 1.7, so code can be updated prior to
|
||||
upgrading to Go 1.9.
|
||||
</p>
|
||||
|
||||
<h2 id="performance">Performance</h2>
|
||||
|
||||
<p>
|
||||
As always, the changes are so general and varied that precise
|
||||
statements about performance are difficult to make. Most programs
|
||||
should run a bit faster, due to speedups in the garbage collector,
|
||||
better generated code, and optimizations in the core library.
|
||||
</p>
|
||||
|
||||
<h3 id="gc">Garbage Collector</h3>
|
||||
|
||||
<p> <!-- CL 37520 -->
|
||||
Library functions that used to trigger stop-the-world garbage
|
||||
collection now trigger concurrent garbage collection.
|
||||
|
||||
Specifically, <a href="/pkg/runtime/#GC"><code>runtime.GC</code></a>,
|
||||
<a href="/pkg/runtime/debug/#SetGCPercent"><code>debug.SetGCPercent</code></a>,
|
||||
and
|
||||
<a href="/pkg/runtime/debug/#FreeOSMemory"><code>debug.FreeOSMemory</code></a>,
|
||||
now trigger concurrent garbage collection, blocking only the calling
|
||||
goroutine until the garbage collection is done.
|
||||
</p>
|
||||
|
||||
<p> <!-- CL 34103, CL 39835 -->
|
||||
The
|
||||
<a href="/pkg/runtime/debug/#SetGCPercent"><code>debug.SetGCPercent</code></a>
|
||||
function only triggers a garbage collection if one is immediately
|
||||
necessary because of the new GOGC value.
|
||||
This makes it possible to adjust GOGC on-the-fly.
|
||||
</p>
|
||||
|
||||
<p> <!-- CL 38732 -->
|
||||
Large object allocation performance is significantly improved in
|
||||
applications using large (>50GB) heaps containing many large
|
||||
objects.
|
||||
</p>
|
||||
|
||||
<p> <!-- CL 34937 -->
|
||||
The <a href="/pkg/runtime/#ReadMemStats"><code>runtime.ReadMemStats</code></a>
|
||||
function now takes less than 100µs even for very large heaps.
|
||||
</p>
|
||||
|
||||
<h2 id="library">Core library</h2>
|
||||
|
||||
<h3 id="monotonic-time">Transparent Monotonic Time support</h3>
|
||||
|
||||
<p> <!-- CL 36255 -->
|
||||
The <a href="/pkg/time/"><code>time</code></a> package now transparently
|
||||
tracks monotonic time in each <a href="/pkg/time/#Time"><code>Time</code></a>
|
||||
value, making computing durations between two <code>Time</code> values
|
||||
a safe operation in the presence of wall clock adjustments.
|
||||
See the <a href="/pkg/time/#hdr-Monotonic_Clocks">package docs</a> and
|
||||
<a href="https://golang.org/design/12914-monotonic">design document</a>
|
||||
for details.
|
||||
</p>
|
||||
|
||||
<h3 id="math-bits">New bit manipulation package</h3>
|
||||
|
||||
<p> <!-- CL 36315 -->
|
||||
Go 1.9 includes a new package,
|
||||
<a href="/pkg/math/bits/"><code>math/bits</code></a>, with optimized
|
||||
implementations for manipulating bits. On most architectures,
|
||||
functions in this package are additionally recognized by the
|
||||
compiler and treated as intrinsics for additional performance.
|
||||
</p>
|
||||
|
||||
<h3 id="test-helper">Test Helper Functions</h3>
|
||||
|
||||
<p> <!-- CL 38796 -->
|
||||
The
|
||||
new <a href="/pkg/testing/#T.Helper"><code>(*T).Helper</code></a>
|
||||
and <a href="/pkg/testing/#B.Helper"><code>(*B).Helper</code></a>
|
||||
methods mark the calling function as a test helper function. When
|
||||
printing file and line information, that function will be skipped.
|
||||
This permits writing test helper functions while still having useful
|
||||
line numbers for users.
|
||||
</p>
|
||||
|
||||
<h3 id="sync-map">Concurrent Map</h3>
|
||||
|
||||
<p> <!-- CL 36617 -->
|
||||
The new <a href="/pkg/sync/#Map"><code>Map</code></a> type
|
||||
in the <a href="/pkg/sync/"><code>sync</code></a> package
|
||||
is a concurrent map with amortized-constant-time loads, stores, and
|
||||
deletes. It is safe for multiple goroutines to call a <code>Map</code>'s methods
|
||||
concurrently.
|
||||
</p>
|
||||
|
||||
<h3 id="pprof-labels">Profiler Labels</h3>
|
||||
|
||||
<p><!-- CL 34198 -->
|
||||
The <a href="/pkg/runtime/pprof"><code>runtime/pprof</code> package</a>
|
||||
now supports adding labels to <code>pprof</code> profiler records.
|
||||
Labels form a key-value map that is used to distinguish calls of the
|
||||
same function in different contexts when looking at profiles
|
||||
with the <a href="/cmd/pprof/"><code>pprof</code> command</a>.
|
||||
The <code>pprof</code> package's
|
||||
new <a href="/pkg/runtime/pprof/#Do"><code>Do</code> function</a>
|
||||
runs code associated with some provided labels. Other new functions
|
||||
in the package help work with labels.
|
||||
</p>
|
||||
|
||||
</dl><!-- runtime/pprof -->
|
||||
|
||||
|
||||
<h3 id="minor_library_changes">Minor changes to the library</h3>
|
||||
|
||||
<p>
|
||||
As always, there are various minor changes and updates to the library,
|
||||
made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
|
||||
in mind.
|
||||
</p>
|
||||
|
||||
<dl id="archive/zip"><dt><a href="/pkg/archive/zip/">archive/zip</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 39570 -->
|
||||
The
|
||||
ZIP <a href="/pkg/archive/zip/#Writer"><code>Writer</code></a>
|
||||
now sets the UTF-8 bit in
|
||||
the <a href="/pkg/archive/zip/#FileHeader.Flags"><code>FileHeader.Flags</code></a>
|
||||
when appropriate.
|
||||
</p>
|
||||
|
||||
</dl><!-- archive/zip -->
|
||||
|
||||
<dl id="crypto/rand"><dt><a href="/pkg/crypto/rand/">crypto/rand</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 43852 -->
|
||||
On Linux, Go now calls the <code>getrandom</code> system call
|
||||
without the <code>GRND_NONBLOCK</code> flag; it will now block
|
||||
until the kernel has sufficient randomness. On kernels predating
|
||||
the <code>getrandom</code> system call, Go continues to read
|
||||
from <code>/dev/urandom</code>.
|
||||
</p>
|
||||
|
||||
</dl><!-- crypto/rand -->
|
||||
|
||||
<dl id="crypto/x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 36093 -->
|
||||
|
||||
On Unix systems the environment
|
||||
variables <code>SSL_CERT_FILE</code>
|
||||
and <code>SSL_CERT_DIR</code> can now be used to override the
|
||||
system default locations for the SSL certificate file and SSL
|
||||
certificate files directory, respectively.
|
||||
</p>
|
||||
|
||||
<p>The FreeBSD file <code>/usr/local/etc/ssl/cert.pem</code> is
|
||||
now included in the certificate search path.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 36900 -->
|
||||
|
||||
The package now supports excluded domains in name constraints.
|
||||
In addition to enforcing such constraints,
|
||||
<a href="/pkg/crypto/x509/#CreateCertificate"><code>CreateCertificate</code></a>
|
||||
will create certificates with excluded name constraints
|
||||
if the provided template certificate has the new
|
||||
field
|
||||
<a href="/pkg/crypto/x509/#Certificate.ExcludedDNSDomains"><code>ExcludedDNSDomains</code></a>
|
||||
populated.
|
||||
</p>
|
||||
|
||||
</dl><!-- crypto/x509 -->
|
||||
|
||||
<dl id="database/sql"><dt><a href="/pkg/database/sql/">database/sql</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 35476 -->
|
||||
The package will now use a cached <a href="/pkg/database/sql/#Stmt"><code>Stmt</code></a> if
|
||||
available in <a href="/pkg/database/sql/#Tx.Stmt"><code>Tx.Stmt</code></a>.
|
||||
This prevents statements from being re-prepared each time
|
||||
<a href="/pkg/database/sql/#Tx.Stmt"><code>Tx.Stmt</code></a> is called.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 38533 -->
|
||||
The package now allows drivers to implement their own argument checkers by implementing
|
||||
<a href="/pkg/database/sql/driver/#NamedValueChecker"><code>driver.NamedValueChecker</code></a>.
|
||||
This also allows drivers to support <code>OUTPUT</code> and <code>INOUT</code> parameter types.
|
||||
<a href="/pkg/database/sql/#Out"><code>Out</code></a> should be used to return output parameters
|
||||
when supported by the driver.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 39031 -->
|
||||
<a href="/pkg/database/sql/#Rows.Scan"><code>Rows.Scan</code></a> can now scan user-defined string types.
|
||||
Previously the package supported scanning into numeric types like <code>type</code> <code>Int</code> <code>int64</code>. It now also supports
|
||||
scanning into string types like <code>type</code> <code>String</code> <code>string</code>.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 40694 -->
|
||||
The new <a href="/pkg/database/sql/#DB.Conn"><code>DB.Conn</code></a> method returns the new
|
||||
<a href="/pkg/database/sql/#Conn"><code>Conn</code></a> type representing an
|
||||
exclusive connection to the database from the connection pool. All queries run on
|
||||
a <a href="/pkg/database/sql/#Conn"><code>Conn</code></a> will use the same underlying
|
||||
connection until <a href="/pkg/database/sql/#Conn.Close"><code>Conn.Close</code></a> is called
|
||||
to return the connection to the connection pool.
|
||||
</p>
|
||||
|
||||
</dl><!-- database/sql -->
|
||||
|
||||
<dl id="encoding/asn1"><dt><a href="/pkg/encoding/asn1/">encoding/asn1</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 38660 -->
|
||||
The new
|
||||
<a href="/pkg/encoding/asn1/#NullBytes"><code>NullBytes</code></a>
|
||||
and
|
||||
<a href="/pkg/encoding/asn1/#NullRawValue"><code>NullRawValue</code></a>
|
||||
represent the ASN.1 NULL type.
|
||||
</p>
|
||||
|
||||
</dl><!-- encoding/asn1 -->
|
||||
|
||||
<dl id="encoding/base32"><dt><a href="/pkg/encoding/base32/">encoding/base32</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 38634 -->
|
||||
The new <a href="/pkg/encoding/base32/#Encoding.WithPadding">Encoding.WithPadding</a>
|
||||
method adds support for custom padding characters and disabling padding.
|
||||
</p>
|
||||
|
||||
</dl><!-- encoding/base32 -->
|
||||
|
||||
<dl id="encoding/csv"><dt><a href="/pkg/encoding/csv/">encoding/csv</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 41730 -->
|
||||
The new field
|
||||
<a href="/pkg/encoding/csv/#Reader.ReuseRecord"><code>Reader.ReuseRecord</code></a>
|
||||
controls whether calls to
|
||||
<a href="/pkg/encoding/csv/#Reader.Read"><code>Read</code></a>
|
||||
may return a slice sharing the backing array of the previous
|
||||
call's returned slice for improved performance.
|
||||
</p>
|
||||
|
||||
</dl><!-- encoding/csv -->
|
||||
|
||||
<dl id="fmt"><dt><a href="/pkg/fmt/">fmt</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 37051 -->
|
||||
The sharp flag ('<code>#</code>') is now supported when printing
|
||||
floating point and complex numbers. It will always print a
|
||||
decimal point
|
||||
for <code>%e</code>, <code>%E</code>, <code>%f</code>, <code>%F</code>, <code>%g</code>
|
||||
and <code>%G</code>; it will not remove trailing zeros
|
||||
for <code>%g</code> and <code>%G</code>.
|
||||
</p>
|
||||
|
||||
</dl><!-- fmt -->
|
||||
|
||||
<dl id="hash/fnv"><dt><a href="/pkg/hash/fnv/">hash/fnv</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 38356 -->
|
||||
The package now includes 128-bit FNV-1 and FNV-1a hash support with
|
||||
<a href="/pkg/hash/fnv/#New128"><code>New128</code></a> and
|
||||
<a href="/pkg/hash/fnv/#New128a"><code>New128a</code></a>, respectively.
|
||||
</p>
|
||||
|
||||
</dl><!-- hash/fnv -->
|
||||
|
||||
<dl id="html/template"><dt><a href="/pkg/html/template/">html/template</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 37880, CL 40936 -->
|
||||
The package now reports an error if a predefined escaper (one of
|
||||
"html", "urlquery" and "js") is found in a pipeline and does not match
|
||||
what the auto-escaper would have decided on its own.
|
||||
This avoids certain security or correctness issues.
|
||||
Now use of one of these escapers is always either a no-op or an error.
|
||||
(The no-op case eases migration from <a href="/pkg/text/template/">text/template</a>.)
|
||||
</p>
|
||||
|
||||
</dl><!-- html/template -->
|
||||
|
||||
<dl id="image"><dt><a href="/pkg/image/">image</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 36734 -->
|
||||
The <a href="/pkg/image/#Rectangle.Intersect"><code>Rectangle.Intersect</code></a>
|
||||
method now returns a zero <code>Rectangle</code> when called on
|
||||
adjacent but non-overlapping rectangles, as documented. In
|
||||
earlier releases it would incorrectly return an empty but
|
||||
non-zero <code>Rectangle</code>.
|
||||
</p>
|
||||
|
||||
</dl><!-- image -->
|
||||
|
||||
<dl id="image/color"><dt><a href="/pkg/image/color/">image/color</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 36732 -->
|
||||
The YCbCr to RGBA conversion formula has been tweaked to ensure
|
||||
that rounding adjustments span the complete [0, 0xffff] RGBA
|
||||
range.
|
||||
</p>
|
||||
|
||||
</dl><!-- image/color -->
|
||||
|
||||
<dl id="image/png"><dt><a href="/pkg/image/png/">image/png</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 34150 -->
|
||||
The new <a href="/pkg/image/png/#Encoder.BufferPool"><code>Encoder.BufferPool</code></a>
|
||||
field allows specifying an <a href="/pkg/image/png/#EncoderBufferPool"><code>EncoderBufferPool</code></a>,
|
||||
that will be used by the encoder to get temporary <code>EncoderBuffer</code>
|
||||
buffers when encoding a PNG image.
|
||||
|
||||
The use of a <code>BufferPool</code> reduces the number of
|
||||
memory allocations performed while encoding multiple images.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 38271 -->
|
||||
The package now supports the decoding of transparent 8-bit
|
||||
grayscale ("Gray8") images.
|
||||
</p>
|
||||
|
||||
</dl><!-- image/png -->
|
||||
|
||||
<dl id="math/big"><dt><a href="/pkg/math/big/">math/big</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 36487 -->
|
||||
The new
|
||||
<a href="/pkg/math/big/#Int.IsInt64"><code>IsInt64</code></a>
|
||||
and
|
||||
<a href="/pkg/math/big/#Int.IsUint64"><code>IsUint64</code></a>
|
||||
methods report whether an <code>Int</code>
|
||||
may be represented as an <code>int64</code> or <code>uint64</code>
|
||||
value.
|
||||
</p>
|
||||
|
||||
</dl><!-- math/big -->
|
||||
|
||||
<dl id="mime/multipart"><dt><a href="/pkg/mime/multipart/">mime/multipart</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 39223 -->
|
||||
The new
|
||||
<a href="/pkg/mime/multipart/#FileHeader.Size"><code>FileHeader.Size</code></a>
|
||||
field describes the size of a file in a multipart message.
|
||||
</p>
|
||||
|
||||
</dl><!-- mime/multipart -->
|
||||
|
||||
<dl id="net"><dt><a href="/pkg/net/">net</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 32572 -->
|
||||
The new
|
||||
<a href="/pkg/net/#Resolver.StrictErrors"><code>Resolver.StrictErrors</code></a>
|
||||
provides control over how Go's built-in DNS resolver handles
|
||||
temporary errors during queries composed of multiple sub-queries,
|
||||
such as an A+AAAA address lookup.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 37260 -->
|
||||
The new
|
||||
<a href="/pkg/net/#Resolver.Dial"><code>Resolver.Dial</code></a>
|
||||
allows a <code>Resolver</code> to use a custom dial function.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 40510 -->
|
||||
<a href="/pkg/net/#JoinHostPort"><code>JoinHostPort</code></a> now only places an address in square brackets if the host contains a colon.
|
||||
In previous releases it would also wrap addresses in square brackets if they contained a percent ('<code>%</code>') sign.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 37913 -->
|
||||
The new methods
|
||||
<a href="/pkg/net/#TCPConn.SyscallConn"><code>TCPConn.SyscallConn</code></a>,
|
||||
<a href="/pkg/net/#IPConn.SyscallConn"><code>IPConn.SyscallConn</code></a>,
|
||||
<a href="/pkg/net/#UDPConn.SyscallConn"><code>UDPConn.SyscallConn</code></a>,
|
||||
and
|
||||
<a href="/pkg/net/#UnixConn.SyscallConn"><code>UnixConn.SyscallConn</code></a>
|
||||
provide access to the connections' underlying file descriptors.
|
||||
</p>
|
||||
|
||||
<p><!-- 45088 -->
|
||||
It is now safe to call <a href="/pkg/net/#Dial"><code>Dial</code></a> with the address obtained from
|
||||
<code>(*TCPListener).String()</code> after creating the listener with
|
||||
<code><a href="/pkg/net/#Listen">Listen</a>("tcp", ":0")</code>.
|
||||
Previously it failed on some machines with half-configured IPv6 stacks.
|
||||
</p>
|
||||
|
||||
</dl><!-- net -->
|
||||
|
||||
<dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt>
|
||||
<dd>
|
||||
|
||||
<p><!-- CL 37328 -->
|
||||
The <a href="/pkg/net/http/#Cookie.String"><code>Cookie.String</code></a> method, used for
|
||||
<code>Cookie</code> and <code>Set-Cookie</code> headers, now encloses values in double quotes
|
||||
if the value contains either a space or a comma.
|
||||
</p>
|
||||
|
||||
<p>Server changes:</p>
|
||||
<ul>
|
||||
<li><!-- CL 38194 -->
|
||||
<a href="/pkg/net/http/#ServeMux"><code>ServeMux</code></a> now ignores ports in the host
|
||||
header when matching handlers. The host is matched unmodified for <code>CONNECT</code> requests.
|
||||
</li>
|
||||
|
||||
<li><!-- CL 34727 -->
|
||||
<a href="/pkg/net/http/#Server.WriteTimeout"><code>Server.WriteTimeout</code></a>
|
||||
now applies to HTTP/2 connections and is enforced per-stream.
|
||||
</li>
|
||||
|
||||
<li><!-- CL 43231 -->
|
||||
HTTP/2 now uses the priority write scheduler by default.
|
||||
Frames are scheduled by following HTTP/2 priorities as described in
|
||||
<a href="https://tools.ietf.org/html/rfc7540#section-5.3">RFC 7540 Section 5.3</a>.
|
||||
</li>
|
||||
|
||||
<li><!-- CL 36483 -->
|
||||
The HTTP handler returned by <a href="/pkg/net/http/#StripPrefix"><code>StripPrefix</code></a>
|
||||
now calls its provided handler with a modified clone of the original <code>*http.Request</code>.
|
||||
Any code storing per-request state in maps keyed by <code>*http.Request</code> should
|
||||
use
|
||||
<a href="/pkg/net/http/#Request.Context"><code>Request.Context</code></a>,
|
||||
<a href="/pkg/net/http/#Request.WithContext"><code>Request.WithContext</code></a>,
|
||||
and
|
||||
<a href="/pkg/context/#WithValue"><code>context.WithValue</code></a> instead.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>Client & Transport changes:</p>
|
||||
<ul>
|
||||
<li><!-- CL 35488 -->
|
||||
The <a href="/pkg/net/http/#Transport"><code>Transport</code></a>
|
||||
now supports making requests via SOCKS5 proxy when the URL returned by
|
||||
<a href="/net/http/#Transport.Proxy"><code>Transport.Proxy</code></a>
|
||||
has the scheme <code>socks5</code>.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</dl><!-- net/http -->
|
||||
|
||||
<dl id="net/http/fcgi"><dt><a href="/pkg/net/http/fcgi/">net/http/fcgi</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 40012 -->
|
||||
The new
|
||||
<a href="/pkg/net/http/fcgi/#ProcessEnv"><code>ProcessEnv</code></a>
|
||||
function returns FastCGI environment variables associated with an HTTP request
|
||||
for which there are no appropriate
|
||||
<a href="/pkg/net/http/#Request"><code>http.Request</code></a>
|
||||
fields, such as <code>REMOTE_USER</code>.
|
||||
</p>
|
||||
|
||||
</dl><!-- net/http/fcgi -->
|
||||
|
||||
<dl id="net/http/httptest"><dt><a href="/pkg/net/http/httptest/">net/http/httptest</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 34639 -->
|
||||
The new
|
||||
<a href="/pkg/net/http/httptest/#Server.Client"><code>Server.Client</code></a>
|
||||
method returns an HTTP client configured for making requests to the test server.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The new
|
||||
<a href="/pkg/net/http/httptest/#Server.Certificate"><code>Server.Certificate</code></a>
|
||||
method returns the test server's TLS certificate, if any.
|
||||
</p>
|
||||
|
||||
</dl><!-- net/http/httptest -->
|
||||
|
||||
<dl id="os"><dt><a href="/pkg/os/">os</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 36800 -->
|
||||
The <code>os</code> package now uses the internal runtime poller
|
||||
for file I/O.
|
||||
This reduces the number of threads required for read/write
|
||||
operations on pipes, and it eliminates races when one goroutine
|
||||
closes a file while another is using the file for I/O.
|
||||
</p>
|
||||
|
||||
<dd>
|
||||
<p><!-- CL 37915 -->
|
||||
On Windows,
|
||||
<a href="/pkg/os/#Args"><code>Args</code></a>
|
||||
is now populated without <code>shell32.dll</code>, improving process start-up time by 1-7 ms.
|
||||
</p>
|
||||
|
||||
</dl><!-- os -->
|
||||
|
||||
<dl id="os/exec"><dt><a href="/pkg/os/exec/">os/exec</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 37586 -->
|
||||
The <code>os/exec</code> package now prevents child processes from being created with
|
||||
any duplicate environment variables.
|
||||
If <a href="/pkg/os/exec/#Cmd.Env"><code>Cmd.Env</code></a>
|
||||
contains duplicate environment keys, only the last
|
||||
value in the slice for each duplicate key is used.
|
||||
</p>
|
||||
|
||||
</dl><!-- os/exec -->
|
||||
|
||||
<dl id="os/user"><dt><a href="/pkg/os/user/">os/user</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 37664 -->
|
||||
<a href="/pkg/os/user/#Lookup"><code>Lookup</code></a> and
|
||||
<a href="/pkg/os/user/#LookupId"><code>LookupId</code></a> now
|
||||
work on Unix systems when <code>CGO_ENABLED=0</code> by reading
|
||||
the <code>/etc/passwd</code> file.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 33713 -->
|
||||
<a href="/pkg/os/user/#LookupGroup"><code>LookupGroup</code></a> and
|
||||
<a href="/pkg/os/user/#LookupGroupId"><code>LookupGroupId</code></a> now
|
||||
work on Unix systems when <code>CGO_ENABLED=0</code> by reading
|
||||
the <code>/etc/group</code> file.
|
||||
</p>
|
||||
|
||||
</dl><!-- os/user -->
|
||||
|
||||
<dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 38335 -->
|
||||
The new
|
||||
<a href="/pkg/reflect/#MakeMapWithSize"><code>MakeMapWithSize</code></a>
|
||||
function creates a map with a capacity hint.
|
||||
</p>
|
||||
|
||||
</dl><!-- reflect -->
|
||||
|
||||
<dl id="runtime"><dt><a href="/pkg/runtime/">runtime</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 37233, CL 37726 -->
|
||||
Tracebacks generated by the runtime and recorded in profiles are
|
||||
now accurate in the presence of inlining.
|
||||
To retrieve tracebacks programmatically, applications should use
|
||||
<a href="/pkg/runtime/#CallersFrames"><code>runtime.CallersFrames</code></a>
|
||||
rather than directly iterating over the results of
|
||||
<a href="/pkg/runtime/#Callers"><code>runtime.Callers</code></a>.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 38403 -->
|
||||
On Windows, Go no longer forces the system timer to run at high
|
||||
resolution when the program is idle.
|
||||
This should reduce the impact of Go programs on battery life.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 29341 -->
|
||||
On FreeBSD, <code>GOMAXPROCS</code> and
|
||||
<a href="/pkg/runtime/#NumCPU"><code>runtime.NumCPU</code></a>
|
||||
are now based on the process' CPU mask, rather than the total
|
||||
number of CPUs.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 43641 -->
|
||||
The runtime has preliminary support for Android O.
|
||||
</p>
|
||||
|
||||
</dl><!-- runtime -->
|
||||
|
||||
<dl id="runtime/debug"><dt><a href="/pkg/runtime/debug/">runtime/debug</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 34013 -->
|
||||
Calling
|
||||
<a href="/pkg/runtime/debug/#SetGCPercent"><code>SetGCPercent</code></a>
|
||||
with a negative value no longer runs an immediate garbage collection.
|
||||
</p>
|
||||
|
||||
</dl><!-- runtime/debug -->
|
||||
|
||||
<dl id="runtime/trace"><dt><a href="/pkg/runtime/trace/">runtime/trace</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 36015 -->
|
||||
The execution trace now displays mark assist events, which
|
||||
indicate when an application goroutine is forced to assist
|
||||
garbage collection because it is allocating too quickly.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 40810 -->
|
||||
"Sweep" events now encompass the entire process of finding free
|
||||
space for an allocation, rather than recording each individual
|
||||
span that is swept.
|
||||
This reduces allocation latency when tracing allocation-heavy
|
||||
programs.
|
||||
The sweep event shows how many bytes were swept and how many
|
||||
were reclaimed.
|
||||
</p>
|
||||
|
||||
</dl><!-- runtime/trace -->
|
||||
|
||||
<dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 34310 -->
|
||||
<a href="/pkg/sync/#Mutex"><code>Mutex</code></a> is now more fair.
|
||||
</p>
|
||||
|
||||
</dl><!-- sync -->
|
||||
|
||||
<dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 36697 -->
|
||||
The new field
|
||||
<a href="/pkg/syscall/#Credential.NoSetGroups"><code>Credential.NoSetGroups</code></a>
|
||||
controls whether Unix systems make a <code>setgroups</code> system call
|
||||
to set supplementary groups when starting a new process.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 43512 -->
|
||||
The new field
|
||||
<a href="/pkg/syscall/#SysProcAttr.AmbientCaps"><code>SysProcAttr.AmbientCaps</code></a>
|
||||
allows setting ambient capabilities on Linux 4.3+ when creating
|
||||
a new process.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 37439 -->
|
||||
On 64-bit x86 Linux, process creation latency has been optimized with
|
||||
use of <code>CLONE_VFORK</code> and <code>CLONE_VM</code>.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 37913 -->
|
||||
The new
|
||||
<a href="/pkg/syscall/#Conn"><code>Conn</code></a>
|
||||
interface describes some types in the
|
||||
<a href="/pkg/net/"><code>net</code></a>
|
||||
package that can provide access to their underlying file descriptor
|
||||
using the new
|
||||
<a href="/pkg/syscall/#RawConn"><code>RawConn</code></a>
|
||||
interface.
|
||||
</p>
|
||||
|
||||
</dl><!-- syscall -->
|
||||
|
||||
|
||||
<dl id="testing/quick"><dt><a href="/pkg/testing/quick/">testing/quick</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 39152 -->
|
||||
The package now chooses values in the full range when
|
||||
generating <code>int64</code> and <code>uint64</code> random
|
||||
numbers; in earlier releases generated values were always
|
||||
limited to the [-2<sup>62</sup>, 2<sup>62</sup>) range.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
In previous releases, using a nil
|
||||
<a href="/pkg/testing/quick/#Config.Rand"><code>Config.Rand</code></a>
|
||||
value caused a fixed deterministic random number generator to be used.
|
||||
It now uses a random number generator seeded with the current time.
|
||||
For the old behavior, set <code>Config.Rand</code> to <code>rand.New(rand.NewSource(0))</code>.
|
||||
</p>
|
||||
|
||||
</dl><!-- testing/quick -->
|
||||
|
||||
<dl id="text/template"><dt><a href="/pkg/text/template/">text/template</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 38420 -->
|
||||
The handling of empty blocks, which was broken by a Go 1.8
|
||||
change that made the result dependent on the order of templates,
|
||||
has been fixed, restoring the old Go 1.7 behavior.
|
||||
</p>
|
||||
|
||||
</dl><!-- text/template -->
|
||||
|
||||
<dl id="time"><dt><a href="/pkg/time/">time</a></dt>
|
||||
<dd>
|
||||
<p><!-- CL 36615 -->
|
||||
The new methods
|
||||
<a href="/pkg/time/#Duration.Round"><code>Duration.Round</code></a>
|
||||
and
|
||||
<a href="/pkg/time/#Duration.Truncate"><code>Duration.Truncate</code></a>
|
||||
handle rounding and truncating durations to multiples of a given duration.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 35710 -->
|
||||
Retrieving the time and sleeping now work correctly under Wine.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If a <code>Time</code> value has a monotonic clock reading, its
|
||||
string representation (as returned by <code>String</code>) now includes a
|
||||
final field <code>"m=±value"</code>, where <code>value</code> is the
|
||||
monotonic clock reading formatted as a decimal number of seconds.
|
||||
</p>
|
||||
|
||||
<p><!-- CL 44832 -->
|
||||
The included <code>tzdata</code> timezone database has been
|
||||
updated to version 2017b. As always, it is only used if the
|
||||
system does not already have the database available.
|
||||
</p>
|
||||
|
||||
</dl><!-- time -->
|
||||
@@ -271,27 +271,6 @@ you will need to abide by the guidelines at
|
||||
|
||||
<h2 id="Design">Design</h2>
|
||||
|
||||
<h3 id="runtime">
|
||||
Does Go have a runtime?</h3>
|
||||
|
||||
<p>
|
||||
Go does have an extensive library, called the <em>runtime</em>,
|
||||
that is part of every Go program.
|
||||
The runtime library implements garbage collection, concurrency,
|
||||
stack management, and other critical features of the Go language.
|
||||
Although it is more central to the language, Go's runtime is analogous
|
||||
to <code>libc</code>, the C library.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
It is important to understand, however, that Go's runtime does not
|
||||
include a virtual machine, such as is provided by the Java runtime.
|
||||
Go programs are compiled ahead of time to native machine code.
|
||||
Thus, although the term is often used to describe the virtual
|
||||
environment in which a program runs, in Go the word “runtime”
|
||||
is just the name given to the library providing critical language services.
|
||||
</p>
|
||||
|
||||
<h3 id="unicode_identifiers">
|
||||
What's up with Unicode identifiers?</h3>
|
||||
|
||||
@@ -769,29 +748,6 @@ for i, v := range t {
|
||||
}
|
||||
</pre>
|
||||
|
||||
<h3 id="convert_slice_with_same_underlying_type">
|
||||
Can I convert []T1 to []T2 if T1 and T2 have the same underlying type?</h3>
|
||||
|
||||
This last line of this code sample does not compile.
|
||||
|
||||
<pre>
|
||||
type T1 int
|
||||
type T2 int
|
||||
var t1 T1
|
||||
var x = T2(t1) // OK
|
||||
var st1 []T1
|
||||
var sx = ([]T2)(st1) // NOT OK
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
In Go, types are closely tied to methods, in that every named type has
|
||||
a (possibly empty) method set.
|
||||
The general rule is that you can change the name of the type being
|
||||
converted (and thus possibly change its method set) but you can't
|
||||
change the name (and method set) of elements of a composite type.
|
||||
Go requires you to be explicit about type conversions.
|
||||
</p>
|
||||
|
||||
<h3 id="nil_error">
|
||||
Why is my nil error value not equal to nil?
|
||||
</h3>
|
||||
@@ -912,7 +868,6 @@ Why does Go not have covariant result types?</h3>
|
||||
|
||||
<p>
|
||||
Covariant result types would mean that an interface like
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
type Copyable interface {
|
||||
@@ -920,15 +875,13 @@ type Copyable interface {
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
would be satisfied by the method
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
func (v Value) Copy() Value
|
||||
</pre>
|
||||
|
||||
<p>because <code>Value</code> implements the empty interface.
|
||||
because <code>Value</code> implements the empty interface.
|
||||
In Go method types must match exactly, so <code>Value</code> does not
|
||||
implement <code>Copyable</code>.
|
||||
Go separates the notion of what a
|
||||
@@ -1094,7 +1047,7 @@ it's easy to work around this. For GitHub, try one of these solutions:
|
||||
<ul>
|
||||
<li>Manually clone the repository in the expected package directory:
|
||||
<pre>
|
||||
$ cd src/github.com/username
|
||||
$ cd $GOPATH/src/github.com/username
|
||||
$ git clone git@github.com:username/package.git
|
||||
</pre>
|
||||
</li>
|
||||
@@ -1140,7 +1093,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.
|
||||
@@ -1148,13 +1101,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/FAQ.md">the <code>dep</code> FAQ</a>.
|
||||
</p>
|
||||
|
||||
<h2 id="Pointers">Pointers and Allocation</h2>
|
||||
|
||||
<h3 id="pass_by_value">
|
||||
@@ -1181,12 +1127,6 @@ struct. If the interface value holds a pointer, copying the interface value
|
||||
makes a copy of the pointer, but again not the data it points to.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Note that this discussion is about the semantics of the operations.
|
||||
Actual implementations may apply optimizations to avoid copying
|
||||
as long as the optimizations do not change the semantics.
|
||||
</p>
|
||||
|
||||
<h3 id="pointer_to_interface">
|
||||
When should I use a pointer to an interface?</h3>
|
||||
|
||||
@@ -1322,26 +1262,11 @@ size of value should use an explicitly sized type, like <code>int64</code>.
|
||||
Prior to Go 1.1, the 64-bit Go compilers (both gc and gccgo) used
|
||||
a 32-bit representation for <code>int</code>. As of Go 1.1 they use
|
||||
a 64-bit representation.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
On the other hand, floating-point scalars and complex
|
||||
types are always sized (there are no <code>float</code> or <code>complex</code> basic types),
|
||||
because programmers should be aware of precision when using floating-point numbers.
|
||||
The default type used for an (untyped) floating-point constant is <code>float64</code>.
|
||||
Thus <code>foo</code> <code>:=</code> <code>3.0</code> declares a variable <code>foo</code>
|
||||
of type <code>float64</code>.
|
||||
For a <code>float32</code> variable initialized by an (untyped) constant, the variable type
|
||||
must be specified explicitly in the variable declaration:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
var foo float32 = 3.0
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Alternatively, the constant must be given a type with a conversion as in
|
||||
<code>foo := float32(3.0)</code>.
|
||||
numbers are always sized: <code>float32</code>, <code>complex64</code>,
|
||||
etc., because programmers should be aware of precision when using
|
||||
floating-point numbers.
|
||||
The default size of a floating-point constant is <code>float64</code>.
|
||||
</p>
|
||||
|
||||
<h3 id="stack_or_heap">
|
||||
@@ -1745,7 +1670,8 @@ What compiler technology is used to build the compilers?</h3>
|
||||
|
||||
<p>
|
||||
<code>Gccgo</code> has a front end written in C++, with a recursive descent parser coupled to the
|
||||
standard GCC back end. <code>Gc</code> is written in Go with a recursive descent parser
|
||||
standard GCC back end. <code>Gc</code> is written in Go using
|
||||
<code>yacc</code>/<code>bison</code> for the parser
|
||||
and uses a custom loader, also written in Go but
|
||||
based on the Plan 9 loader, to generate ELF/Mach-O/PE binaries.
|
||||
</p>
|
||||
@@ -1806,7 +1732,7 @@ A simple C "hello, world" program compiled and linked statically using gcc
|
||||
on Linux is around 750 kB,
|
||||
including an implementation of <code>printf</code>.
|
||||
An equivalent Go program using <code>fmt.Printf</code>
|
||||
is around 1.5 MB, but
|
||||
is around 2.3 MB, but
|
||||
that includes more powerful run-time support and type information.
|
||||
</p>
|
||||
|
||||
|
||||
375
doc/go_spec.html
375
doc/go_spec.html
@@ -1,6 +1,6 @@
|
||||
<!--{
|
||||
"Title": "The Go Programming Language Specification",
|
||||
"Subtitle": "Version of June 28, 2017",
|
||||
"Subtitle": "Version of May 31, 2016",
|
||||
"Path": "/ref/spec"
|
||||
}-->
|
||||
|
||||
@@ -154,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
|
||||
@@ -197,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>,
|
||||
@@ -254,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">
|
||||
+ & += &= && == != ( )
|
||||
@@ -606,7 +605,7 @@ implementation must:
|
||||
|
||||
<li>Represent floating-point constants, including the parts of
|
||||
a complex constant, with a mantissa of at least 256 bits
|
||||
and a signed binary exponent of at least 16 bits.</li>
|
||||
and a signed exponent of at least 32 bits.</li>
|
||||
|
||||
<li>Give an error if unable to represent an integer constant
|
||||
precisely.</li>
|
||||
@@ -686,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">
|
||||
@@ -701,7 +702,6 @@ TypeLit = ArrayType | StructType | PointerType | FunctionType | InterfaceType
|
||||
<p>
|
||||
Named instances of the boolean, numeric, and string types are
|
||||
<a href="#Predeclared_identifiers">predeclared</a>.
|
||||
Other named types are introduced with <a href="#Type_declarations">type declarations</a>.
|
||||
<i>Composite types</i>—array, struct, pointer, function,
|
||||
interface, slice, map, and channel types—may be constructed using
|
||||
type literals.
|
||||
@@ -717,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>
|
||||
@@ -745,7 +738,7 @@ The method set of any other type <code>T</code> consists of all
|
||||
The method set of the corresponding <a href="#Pointer_types">pointer type</a> <code>*T</code>
|
||||
is the set of all methods declared with receiver <code>*T</code> or <code>T</code>
|
||||
(that is, it also contains the method set of <code>T</code>).
|
||||
Further rules apply to structs containing embedded fields, as described
|
||||
Further rules apply to structs containing anonymous fields, as described
|
||||
in the section on <a href="#Struct_types">struct types</a>.
|
||||
Any other type has an empty method set.
|
||||
In a method set, each method must have a
|
||||
@@ -954,16 +947,16 @@ Moreover, the inner slices must be initialized individually.
|
||||
<p>
|
||||
A struct is a sequence of named elements, called fields, each of which has a
|
||||
name and a type. Field names may be specified explicitly (IdentifierList) or
|
||||
implicitly (EmbeddedField).
|
||||
implicitly (AnonymousField).
|
||||
Within a struct, non-<a href="#Blank_identifier">blank</a> field names must
|
||||
be <a href="#Uniqueness_of_identifiers">unique</a>.
|
||||
</p>
|
||||
|
||||
<pre class="ebnf">
|
||||
StructType = "struct" "{" { FieldDecl ";" } "}" .
|
||||
FieldDecl = (IdentifierList Type | EmbeddedField) [ Tag ] .
|
||||
EmbeddedField = [ "*" ] TypeName .
|
||||
Tag = string_lit .
|
||||
StructType = "struct" "{" { FieldDecl ";" } "}" .
|
||||
FieldDecl = (IdentifierList Type | AnonymousField) [ Tag ] .
|
||||
AnonymousField = [ "*" ] TypeName .
|
||||
Tag = string_lit .
|
||||
</pre>
|
||||
|
||||
<pre>
|
||||
@@ -981,15 +974,16 @@ struct {
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
A field declared with a type but no explicit field name is called an <i>embedded field</i>.
|
||||
An embedded field must be specified as
|
||||
A field declared with a type but no explicit field name is an <i>anonymous field</i>,
|
||||
also called an <i>embedded</i> field or an embedding of the type in the struct.
|
||||
An embedded type must be specified as
|
||||
a type name <code>T</code> or as a pointer to a non-interface type name <code>*T</code>,
|
||||
and <code>T</code> itself may not be
|
||||
a pointer type. The unqualified type name acts as the field name.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
// A struct with four embedded fields of types T1, *T2, P.T3 and *P.T4
|
||||
// A struct with four anonymous fields of type T1, *T2, P.T3 and *P.T4
|
||||
struct {
|
||||
T1 // field name is T1
|
||||
*T2 // field name is T2
|
||||
@@ -1006,15 +1000,15 @@ in a struct type:
|
||||
|
||||
<pre>
|
||||
struct {
|
||||
T // conflicts with embedded field *T and *P.T
|
||||
*T // conflicts with embedded field T and *P.T
|
||||
*P.T // conflicts with embedded field T and *T
|
||||
T // conflicts with anonymous field *T and *P.T
|
||||
*T // conflicts with anonymous field T and *P.T
|
||||
*P.T // conflicts with anonymous field T and *T
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
A field or <a href="#Method_declarations">method</a> <code>f</code> of an
|
||||
embedded field in a struct <code>x</code> is called <i>promoted</i> if
|
||||
anonymous field in a struct <code>x</code> is called <i>promoted</i> if
|
||||
<code>x.f</code> is a legal <a href="#Selectors">selector</a> that denotes
|
||||
that field or method <code>f</code>.
|
||||
</p>
|
||||
@@ -1031,7 +1025,7 @@ promoted methods are included in the method set of the struct as follows:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
If <code>S</code> contains an embedded field <code>T</code>,
|
||||
If <code>S</code> contains an anonymous field <code>T</code>,
|
||||
the <a href="#Method_sets">method sets</a> of <code>S</code>
|
||||
and <code>*S</code> both include promoted methods with receiver
|
||||
<code>T</code>. The method set of <code>*S</code> also
|
||||
@@ -1039,7 +1033,7 @@ promoted methods are included in the method set of the struct as follows:
|
||||
</li>
|
||||
|
||||
<li>
|
||||
If <code>S</code> contains an embedded field <code>*T</code>,
|
||||
If <code>S</code> contains an anonymous field <code>*T</code>,
|
||||
the method sets of <code>S</code> and <code>*S</code> both
|
||||
include promoted methods with receiver <code>T</code> or
|
||||
<code>*T</code>.
|
||||
@@ -1424,10 +1418,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>
|
||||
@@ -1439,8 +1434,8 @@ components have identical types. In detail:
|
||||
<li>Two struct types are identical if they have the same sequence of fields,
|
||||
and if corresponding fields have the same names, and identical types,
|
||||
and identical tags.
|
||||
<a href="#Exported_identifiers">Non-exported</a> field names from different
|
||||
packages are always different.</li>
|
||||
Two anonymous fields are considered to have the same name. Lower-case field
|
||||
names from different packages are always different.</li>
|
||||
|
||||
<li>Two pointer types are identical if they have identical base types.</li>
|
||||
|
||||
@@ -1450,9 +1445,8 @@ components have identical types. In detail:
|
||||
Parameter and result names are not required to match.</li>
|
||||
|
||||
<li>Two interface types are identical if they have the same set of methods
|
||||
with the same names and identical function types.
|
||||
<a href="#Exported_identifiers">Non-exported</a> method names from different
|
||||
packages are always different. The order of the methods is irrelevant.</li>
|
||||
with the same names and identical function types. Lower-case 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 value types.</li>
|
||||
|
||||
@@ -1466,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>
|
||||
@@ -1491,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, 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>
|
||||
|
||||
|
||||
@@ -1524,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
|
||||
@@ -1533,7 +1511,7 @@ 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>
|
||||
@@ -1862,60 +1840,23 @@ last non-empty expression list.
|
||||
<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 {
|
||||
@@ -1931,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>
|
||||
|
||||
@@ -1951,7 +1891,7 @@ type NewMutex Mutex
|
||||
type PtrMutex *Mutex
|
||||
|
||||
// The method set of *PrintableMutex contains the methods
|
||||
// Lock and Unlock bound to its embedded field Mutex.
|
||||
// Lock and Unlock bound to its anonymous field Mutex.
|
||||
type PrintableMutex struct {
|
||||
Mutex
|
||||
}
|
||||
@@ -1961,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>
|
||||
@@ -1984,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">
|
||||
@@ -2066,7 +2006,7 @@ _, y, _ := coord(p) // coord() returns three values; only interested in y coord
|
||||
<p>
|
||||
Unlike regular variable declarations, a short variable declaration may <i>redeclare</i>
|
||||
variables provided they were originally declared earlier in the same block
|
||||
(or the parameter lists if the block is the function body) with the same type,
|
||||
(or the parameter lists if the block is the function body) with the same type,
|
||||
and at least one of the non-<a href="#Blank_identifier">blank</a> variables is new.
|
||||
As a consequence, redeclaration can only appear in a multi-variable short declaration.
|
||||
Redeclaration does not introduce a new variable; it just assigns a new value to the original.
|
||||
@@ -2143,8 +2083,8 @@ and associates the method with the receiver's <i>base type</i>.
|
||||
</p>
|
||||
|
||||
<pre class="ebnf">
|
||||
MethodDecl = "func" Receiver MethodName ( Function | Signature ) .
|
||||
Receiver = Parameters .
|
||||
MethodDecl = "func" Receiver MethodName ( Function | Signature ) .
|
||||
Receiver = Parameters .
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -2153,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>.
|
||||
@@ -2295,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>
|
||||
@@ -2347,10 +2286,8 @@ For array and slice literals the following rules apply:
|
||||
<li>Each element has an associated integer index marking
|
||||
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 representable by
|
||||
a value of type <code>int</code>; and if it is typed
|
||||
it must be of integer type.
|
||||
<li>An element with a key uses the key as its index; the
|
||||
key must be a constant integer expression.
|
||||
</li>
|
||||
<li>An element without a key uses the previous element's index plus one.
|
||||
If the first element has no key, its index is zero.
|
||||
@@ -2383,7 +2320,7 @@ days := [...]string{"Sat", "Sun"} // len(days) == 2
|
||||
|
||||
<p>
|
||||
A slice literal describes the entire underlying array literal.
|
||||
Thus the length and capacity of a slice literal are the maximum
|
||||
Thus, the length and capacity of a slice literal are the maximum
|
||||
element index plus one. A slice literal has the form
|
||||
</p>
|
||||
|
||||
@@ -2413,11 +2350,10 @@ the <code>&T</code> when the element or key type is <code>*T</code>.
|
||||
[][]int{{1, 2, 3}, {4, 5}} // same as [][]int{[]int{1, 2, 3}, []int{4, 5}}
|
||||
[][]Point{{{0, 1}, {1, 2}}} // same as [][]Point{[]Point{Point{0, 1}, Point{1, 2}}}
|
||||
map[string]Point{"orig": {0, 0}} // same as map[string]Point{"orig": Point{0, 0}}
|
||||
map[Point]string{{0, 0}: "orig"} // same as map[Point]string{Point{0, 0}: "orig"}
|
||||
|
||||
type PPoint *Point
|
||||
[2]*Point{{1.5, -3.5}, {}} // same as [2]*Point{&Point{1.5, -3.5}, &Point{}}
|
||||
[2]PPoint{{1.5, -3.5}, {}} // same as [2]PPoint{PPoint(&Point{1.5, -3.5}), PPoint(&Point{})}
|
||||
[...]*Point{{1.5, -3.5}, {0, 0}} // same as [...]*Point{&Point{1.5, -3.5}, &Point{0, 0}}
|
||||
|
||||
map[Point]string{{0, 0}: "orig"} // same as map[Point]string{Point{0, 0}: "orig"}
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -2553,13 +2489,13 @@ If <code>x</code> is a package name, see the section on
|
||||
A selector <code>f</code> may denote a field or method <code>f</code> of
|
||||
a type <code>T</code>, or it may refer
|
||||
to a field or method <code>f</code> of a nested
|
||||
<a href="#Struct_types">embedded field</a> of <code>T</code>.
|
||||
The number of embedded fields traversed
|
||||
<a href="#Struct_types">anonymous field</a> of <code>T</code>.
|
||||
The number of anonymous fields traversed
|
||||
to reach <code>f</code> is called its <i>depth</i> in <code>T</code>.
|
||||
The depth of a field or method <code>f</code>
|
||||
declared in <code>T</code> is zero.
|
||||
The depth of a field or method <code>f</code> declared in
|
||||
an embedded field <code>A</code> in <code>T</code> is the
|
||||
an anonymous field <code>A</code> in <code>T</code> is the
|
||||
depth of <code>f</code> in <code>A</code> plus one.
|
||||
</p>
|
||||
|
||||
@@ -2997,7 +2933,6 @@ used in an <a href="#Assignments">assignment</a> or initialization of the specia
|
||||
v, ok = a[x]
|
||||
v, ok := a[x]
|
||||
var v, ok = a[x]
|
||||
var v, ok T = a[x]
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -3178,16 +3113,13 @@ known to be <code>T</code> in a correct program.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
var x interface{} = 7 // x has dynamic type int and value 7
|
||||
i := x.(int) // i has type int and value 7
|
||||
var x interface{} = 7 // x has dynamic type int and value 7
|
||||
i := x.(int) // i has type int and value 7
|
||||
|
||||
type I interface { m() }
|
||||
|
||||
func f(y I) {
|
||||
s := y.(string) // illegal: string does not implement I (missing method m)
|
||||
r := y.(io.Reader) // r has type io.Reader and the dynamic type of y must implement both I and io.Reader
|
||||
…
|
||||
}
|
||||
var y I
|
||||
s := y.(string) // illegal: string does not implement I (missing method m)
|
||||
r := y.(io.Reader) // r has type io.Reader and y must implement both I and io.Reader
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -3198,7 +3130,6 @@ A type assertion used in an <a href="#Assignments">assignment</a> or initializat
|
||||
v, ok = x.(T)
|
||||
v, ok := x.(T)
|
||||
var v, ok = x.(T)
|
||||
var v, ok T1 = x.(T)
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -3384,7 +3315,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 representable 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.
|
||||
@@ -3582,33 +3513,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>
|
||||
|
||||
@@ -3667,7 +3571,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>
|
||||
|
||||
@@ -3833,7 +3737,6 @@ A receive expression used in an <a href="#Assignments">assignment</a> or initial
|
||||
x, ok = <-ch
|
||||
x, ok := <-ch
|
||||
var x, ok = <-ch
|
||||
var x, ok T = <-ch
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -3931,14 +3834,11 @@ in any of these cases:
|
||||
to <code>T</code>.
|
||||
</li>
|
||||
<li>
|
||||
ignoring struct tags (see below),
|
||||
<code>x</code>'s type and <code>T</code> have <a href="#Type_identity">identical</a>
|
||||
<code>x</code>'s type and <code>T</code> have identical
|
||||
<a href="#Types">underlying types</a>.
|
||||
</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>
|
||||
@@ -3957,31 +3857,6 @@ in any of these cases:
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
<a href="#Struct_types">Struct tags</a> are ignored when comparing struct types
|
||||
for identity for the purpose of conversion:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
type Person struct {
|
||||
Name string
|
||||
Address *struct {
|
||||
Street string
|
||||
City string
|
||||
}
|
||||
}
|
||||
|
||||
var data *struct {
|
||||
Name string `json:"name"`
|
||||
Address *struct {
|
||||
Street string `json:"street"`
|
||||
City string `json:"city"`
|
||||
} `json:"address"`
|
||||
}
|
||||
|
||||
var person = (*Person)(data) // ignoring tags, the underlying types are identical
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Specific rules apply to (non-constant) conversions between numeric types or
|
||||
to and from a string type.
|
||||
@@ -4523,8 +4398,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
|
||||
@@ -4812,8 +4687,8 @@ TypeList = Type { "," Type } .
|
||||
<p>
|
||||
The TypeSwitchGuard may include a
|
||||
<a href="#Short_variable_declarations">short variable declaration</a>.
|
||||
When that form is used, the variable is declared at the end of the
|
||||
TypeSwitchCase in the <a href="#Blocks">implicit block</a> of each clause.
|
||||
When that form is used, the variable is declared at the beginning of
|
||||
the <a href="#Blocks">implicit block</a> in each clause.
|
||||
In clauses with a case listing exactly one type, the variable
|
||||
has that type; otherwise, the variable has the type of the expression
|
||||
in the TypeSwitchGuard.
|
||||
@@ -4888,8 +4763,8 @@ The "fallthrough" statement is not permitted in a type switch.
|
||||
<h3 id="For_statements">For statements</h3>
|
||||
|
||||
<p>
|
||||
A "for" statement specifies repeated execution of a block. There are three forms:
|
||||
The iteration may be controlled by a single condition, a "for" clause, or a "range" clause.
|
||||
A "for" statement specifies repeated execution of a block. The iteration is
|
||||
controlled by a condition, a "for" clause, or a "range" clause.
|
||||
</p>
|
||||
|
||||
<pre class="ebnf">
|
||||
@@ -4897,8 +4772,6 @@ ForStmt = "for" [ Condition | ForClause | RangeClause ] Block .
|
||||
Condition = Expression .
|
||||
</pre>
|
||||
|
||||
<h4 id="For_condition">For statements with single condition</h4>
|
||||
|
||||
<p>
|
||||
In its simplest form, a "for" statement specifies the repeated execution of
|
||||
a block as long as a boolean condition evaluates to true.
|
||||
@@ -4913,8 +4786,6 @@ for a < b {
|
||||
}
|
||||
</pre>
|
||||
|
||||
<h4 id="For_clause">For statements with <code>for</code> clause</h4>
|
||||
|
||||
<p>
|
||||
A "for" statement with a ForClause is also controlled by its condition, but
|
||||
additionally it may specify an <i>init</i>
|
||||
@@ -4953,8 +4824,6 @@ for cond { S() } is the same as for ; cond ; { S() }
|
||||
for { S() } is the same as for true { S() }
|
||||
</pre>
|
||||
|
||||
<h4 id="For_range">For statements with <code>range</code> clause</h4>
|
||||
|
||||
<p>
|
||||
A "for" statement with a "range" clause
|
||||
iterates through all entries of an array, slice, string or map,
|
||||
@@ -5025,8 +4894,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.
|
||||
@@ -5126,7 +4995,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>
|
||||
|
||||
|
||||
@@ -5672,7 +5541,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
|
||||
@@ -5695,15 +5564,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>
|
||||
|
||||
@@ -5860,12 +5723,12 @@ var a = complex(2, -2) // complex128
|
||||
const b = complex(1.0, -1.4) // untyped complex constant 1 - 1.4i
|
||||
x := float32(math.Cos(math.Pi/2)) // float32
|
||||
var c64 = complex(5, -x) // complex64
|
||||
var s uint = complex(1, 0) // untyped complex constant 1 + 0i can be converted to uint
|
||||
_ = complex(1, 2<<s) // illegal: 2 assumes floating-point type, cannot shift
|
||||
const s uint = complex(1, 0) // untyped complex constant 1 + 0i can be converted to uint
|
||||
_ = complex(1, 2<<s) // illegal: 2 has floating-point type, cannot shift
|
||||
var rl = real(c64) // float32
|
||||
var im = imag(a) // float64
|
||||
const c = imag(b) // untyped constant -1.4
|
||||
_ = imag(3 << s) // illegal: 3 assumes complex type, cannot shift
|
||||
_ = imag(3 << s) // illegal: 3 has complex type, cannot shift
|
||||
</pre>
|
||||
|
||||
<h3 id="Handling_panics">Handling panics</h3>
|
||||
@@ -5965,11 +5828,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>
|
||||
|
||||
@@ -6301,10 +6159,9 @@ func init() { … }
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Multiple such functions may be defined per package, even within a single
|
||||
source file. In the package block, the <code>init</code> identifier can
|
||||
be used only to declare <code>init</code> functions, yet the identifier
|
||||
itself is not <a href="#Declarations_and_scope">declared</a>. Thus
|
||||
Multiple such functions may be defined, even within a single
|
||||
source file. The <code>init</code> identifier is not
|
||||
<a href="#Declarations_and_scope">declared</a> and thus
|
||||
<code>init</code> functions cannot be referred to from anywhere
|
||||
in a program.
|
||||
</p>
|
||||
@@ -6431,7 +6288,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>
|
||||
|
||||
@@ -6509,7 +6366,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,238 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32.000001"
|
||||
id="svg4416"
|
||||
version="1.1"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="favicon.svg"
|
||||
inkscape:export-filename="../../favicon.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90">
|
||||
<defs
|
||||
id="defs4418" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="15.839192"
|
||||
inkscape:cx="17.966652"
|
||||
inkscape:cy="9.2991824"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
units="px"
|
||||
inkscape:snap-bbox="true"
|
||||
inkscape:snap-bbox-edge-midpoints="false"
|
||||
inkscape:bbox-nodes="true"
|
||||
showguides="false"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1018"
|
||||
inkscape:window-x="1912"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:object-nodes="true"
|
||||
inkscape:snap-smooth-nodes="true"
|
||||
inkscape:snap-global="false">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid5148" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata4421">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="icon"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-1020.3622)">
|
||||
<ellipse
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#384e54;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
id="ellipse4216"
|
||||
cx="-907.35657"
|
||||
cy="479.90009"
|
||||
rx="3.5793996"
|
||||
ry="3.8207953"
|
||||
transform="matrix(-0.49169095,-0.87076978,-0.87076978,0.49169095,0,0)"
|
||||
inkscape:transform-center-x="0.67794294"
|
||||
inkscape:transform-center-y="-2.3634048" />
|
||||
<ellipse
|
||||
inkscape:transform-center-y="-2.3633882"
|
||||
inkscape:transform-center-x="-0.67793718"
|
||||
transform="matrix(0.49169095,-0.87076978,0.87076978,0.49169095,0,0)"
|
||||
ry="3.8207953"
|
||||
rx="3.5793996"
|
||||
cy="507.8461"
|
||||
cx="-891.57654"
|
||||
id="ellipse4463"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#384e54;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#384e54;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="m 16.091693,1021.3642 c -1.105749,0.01 -2.210341,0.049 -3.31609,0.09 C 6.8422558,1021.6738 2,1026.3942 2,1032.3622 c 0,2.9786 0,13 0,20 l 28,0 c 0,-8 0,-16 0,-20 0,-5.9683 -4.667345,-10.4912 -10.59023,-10.908 -1.10575,-0.078 -2.212328,-0.099 -3.318077,-0.09 z"
|
||||
id="path4465"
|
||||
sodipodi:nodetypes="ccsccscc" />
|
||||
<path
|
||||
inkscape:transform-center-y="-1.3604657"
|
||||
inkscape:transform-center-x="-0.98424303"
|
||||
sodipodi:nodetypes="sssssss"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4469"
|
||||
d="m 4.6078867,1025.0462 c 0.459564,0.2595 1.818262,1.2013 1.980983,1.648 0.183401,0.5035 0.159385,1.0657 -0.114614,1.551 -0.346627,0.6138 -1.005341,0.9487 -1.696421,0.9365 -0.339886,-0.01 -1.720283,-0.6372 -2.042561,-0.8192 -0.97754,-0.5519 -1.350795,-1.7418 -0.833686,-2.6576 0.517109,-0.9158 1.728749,-1.2107 2.706299,-0.6587 z"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#76e1fe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
|
||||
<rect
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:0.32850246;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
id="rect4473"
|
||||
width="3.0866659"
|
||||
height="3.5313663"
|
||||
x="14.406213"
|
||||
y="1035.6842"
|
||||
ry="0.62426329" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#76e1fe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="m 16,1023.3622 c -9,0 -12,3.7153 -12,9 l 0,20 24,0 c -0.04889,-7.3562 0,-18 0,-20 0,-5.2848 -3,-9 -12,-9 z"
|
||||
id="path4471"
|
||||
sodipodi:nodetypes="zsccsz" />
|
||||
<path
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#76e1fe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="m 27.074073,1025.0462 c -0.45957,0.2595 -1.818257,1.2013 -1.980979,1.648 -0.183401,0.5035 -0.159384,1.0657 0.114614,1.551 0.346627,0.6138 1.005335,0.9487 1.696415,0.9365 0.33988,-0.01 1.72029,-0.6372 2.04256,-0.8192 0.97754,-0.5519 1.35079,-1.7418 0.83369,-2.6576 -0.51711,-0.9158 -1.72876,-1.2107 -2.7063,-0.6587 z"
|
||||
id="path4481"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="sssssss"
|
||||
inkscape:transform-center-x="0.98424094"
|
||||
inkscape:transform-center-y="-1.3604657" />
|
||||
<circle
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
id="circle4477"
|
||||
cx="21.175734"
|
||||
cy="1030.3542"
|
||||
r="4.6537542"
|
||||
inkscape:export-filename=".\rect4485.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90" />
|
||||
<circle
|
||||
r="4.8316345"
|
||||
cy="1030.3542"
|
||||
cx="10.339486"
|
||||
id="circle4483"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
inkscape:export-filename=".\rect4485.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90" />
|
||||
<rect
|
||||
inkscape:export-ydpi="90"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-filename=".\rect4485.png"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:0.32941176;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
id="rect4246"
|
||||
width="3.6673687"
|
||||
height="4.1063409"
|
||||
x="14.115863"
|
||||
y="1035.9174"
|
||||
ry="0.72590536" />
|
||||
<rect
|
||||
ry="0.72590536"
|
||||
y="1035.2253"
|
||||
x="14.115863"
|
||||
height="4.1063409"
|
||||
width="3.6673687"
|
||||
id="rect4485"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#fffcfb;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
inkscape:export-filename=".\rect4485.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90" />
|
||||
<path
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:0.32941176;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="m 19.999735,1036.5289 c 0,0.838 -0.871228,1.2682 -2.144766,1.1659 -0.02366,0 -0.04795,-0.6004 -0.254147,-0.5832 -0.503669,0.042 -1.095902,-0.02 -1.685964,-0.02 -0.612939,0 -1.206342,0.1826 -1.68549,0.017 -0.110233,-0.038 -0.178298,0.5838 -0.261532,0.5816 -1.243685,-0.033 -2.078803,-0.3383 -2.078803,-1.1618 0,-1.2118 1.815635,-2.1941 4.055351,-2.1941 2.239704,0 4.055351,0.9823 4.055351,2.1941 z"
|
||||
id="path4487"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="sssssssss"
|
||||
inkscape:export-filename=".\rect4485.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90" />
|
||||
<path
|
||||
sodipodi:nodetypes="sssssssss"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4489"
|
||||
d="m 19.977414,1035.7004 c 0,0.5685 -0.433659,0.8554 -1.138091,1.0001 -0.291933,0.06 -0.630371,0.096 -1.003719,0.1166 -0.56405,0.032 -1.207782,0.031 -1.89122,0.031 -0.672834,0 -1.307182,0 -1.864904,-0.029 -0.306268,-0.017 -0.589429,-0.043 -0.843164,-0.084 -0.813833,-0.1318 -1.324962,-0.417 -1.324962,-1.0344 0,-1.1601 1.805642,-2.1006 4.03303,-2.1006 2.227377,0 4.03303,0.9405 4.03303,2.1006 z"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#c38c74;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
inkscape:export-filename=".\rect4485.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90" />
|
||||
<ellipse
|
||||
cy="1033.8501"
|
||||
cx="15.944382"
|
||||
id="ellipse4491"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#23201f;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
rx="2.0801733"
|
||||
ry="1.343747"
|
||||
inkscape:export-filename=".\rect4485.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90" />
|
||||
<circle
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#171311;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
id="circle4493"
|
||||
cx="12.414201"
|
||||
cy="1030.3542"
|
||||
r="1.9630634"
|
||||
inkscape:export-filename=".\rect4485.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90" />
|
||||
<circle
|
||||
r="1.9630634"
|
||||
cy="1030.3542"
|
||||
cx="23.110121"
|
||||
id="circle4495"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#171311;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
inkscape:export-filename=".\rect4485.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4497"
|
||||
d="m 5.0055377,1027.2727 c -1.170435,-1.0835 -2.026973,-0.7721 -2.044172,-0.7463"
|
||||
style="display:inline;fill:none;fill-rule:evenodd;stroke:#384e54;stroke-width:0.39730874;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
style="display:inline;fill:none;fill-rule:evenodd;stroke:#384e54;stroke-width:0.39730874;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 4.3852457,1026.9152 c -1.158557,0.036 -1.346704,0.6303 -1.33881,0.6523"
|
||||
id="path4499"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="display:inline;fill:none;fill-rule:evenodd;stroke:#384e54;stroke-width:0.39730874;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 26.630533,1027.1724 c 1.17043,-1.0835 2.02697,-0.7721 2.04417,-0.7463"
|
||||
id="path4501"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4503"
|
||||
d="m 27.321773,1026.673 c 1.15856,0.036 1.3467,0.6302 1.3388,0.6522"
|
||||
style="display:inline;fill:none;fill-rule:evenodd;stroke:#384e54;stroke-width:0.39730874;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 17 KiB |
@@ -11,9 +11,6 @@
|
||||
|
||||
<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.
|
||||
</p>
|
||||
<p>
|
||||
Search the <a href="https://groups.google.com/group/golang-nuts">golang-nuts</a>
|
||||
archives and consult the <a href="/doc/go_faq.html">FAQ</a> and
|
||||
<a href="//golang.org/wiki">wiki</a> before posting.
|
||||
@@ -21,12 +18,12 @@ archives and consult the <a href="/doc/go_faq.html">FAQ</a> and
|
||||
|
||||
<h3 id="forum"><a href="https://forum.golangbridge.org/">Go Forum</a></h3>
|
||||
<p>
|
||||
The <a href="https://forum.golangbridge.org/">Go Forum</a> is a discussion
|
||||
The <a href="https://forum.golangbridge.org/">Go Forum</a> is an alternate discussion
|
||||
forum for Go programmers.
|
||||
</p>
|
||||
|
||||
<h3 id="slack"><a href="https://blog.gopheracademy.com/gophers-slack-community/">Gopher Slack</a></h3>
|
||||
<p>Get live support from other users in the Go slack channel.</p>
|
||||
<p>Get live support from the official Go slack channel.</p>
|
||||
|
||||
<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
|
||||
@@ -59,12 +56,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>
|
||||
|
||||
<h2 id="community">Community resources</h2>
|
||||
|
||||
<h3 id="go_user_groups"><a href="/wiki/GoUserGroups">Go User Groups</a></h3>
|
||||
|
||||
@@ -33,7 +33,7 @@ compiler using the GCC back end, see
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The Go compilers support eight instruction sets.
|
||||
The Go compilers support seven instruction sets.
|
||||
There are important differences in the quality of the compilers for the different
|
||||
architectures.
|
||||
</p>
|
||||
@@ -43,19 +43,23 @@ architectures.
|
||||
<code>amd64</code> (also known as <code>x86-64</code>)
|
||||
</dt>
|
||||
<dd>
|
||||
A mature implementation.
|
||||
A mature implementation. New in 1.7 is its SSA-based back end
|
||||
that generates compact, efficient code.
|
||||
</dd>
|
||||
<dt>
|
||||
<code>386</code> (<code>x86</code> or <code>x86-32</code>)
|
||||
</dt>
|
||||
<dd>
|
||||
Comparable to the <code>amd64</code> port.
|
||||
Comparable to the <code>amd64</code> port, but does
|
||||
not yet use the SSA-based back end. It has an effective
|
||||
optimizer (registerizer) and generates good code (although
|
||||
<code>gccgo</code> can do noticeably better sometimes).
|
||||
</dd>
|
||||
<dt>
|
||||
<code>arm</code> (<code>ARM</code>)
|
||||
</dt>
|
||||
<dd>
|
||||
Supports Linux, FreeBSD, NetBSD, OpenBSD and Darwin binaries. Less widely used than the other ports.
|
||||
Supports Linux, FreeBSD, NetBSD and Darwin binaries. Less widely used than the other ports.
|
||||
</dd>
|
||||
<dt>
|
||||
<code>arm64</code> (<code>AArch64</code>)
|
||||
@@ -69,12 +73,6 @@ architectures.
|
||||
<dd>
|
||||
Supports Linux binaries. New in 1.5 and not as well exercised as other ports.
|
||||
</dd>
|
||||
<dt>
|
||||
<code>mips, mipsle</code> (32-bit MIPS big- and little-endian)
|
||||
</dt>
|
||||
<dd>
|
||||
Supports Linux binaries. New in 1.8 and not as well exercised as other ports.
|
||||
</dd>
|
||||
<dt>
|
||||
<code>mips64, mips64le</code> (64-bit MIPS big- and little-endian)
|
||||
</dt>
|
||||
@@ -121,42 +119,27 @@ Go does not support CentOS 6 on these systems.
|
||||
<p>
|
||||
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>
|
||||
is <code>$HOME/go1.4</code>.
|
||||
chain in <code>$HOME/go1.4</code>.
|
||||
(This path may be overridden by setting the <code>GOROOT_BOOTSTRAP</code>
|
||||
environment variable.)
|
||||
</p>
|
||||
|
||||
<p>
|
||||
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 tool chain.
|
||||
Build the tools with Go version 1.4 or a point release (1.4.1, 1.4.2 etc.).
|
||||
Go 1.4 binaries can be found at <a href="/dl/">the downloads page</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
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.
|
||||
Download the zip or tarball of Go 1.4 for your platform and extract it to
|
||||
<code>$HOME/go1.4</code> (or your nominated <code>GOROOT_BOOTSTRAP</code>
|
||||
location).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To build a bootstrap tool chain from source, use
|
||||
either the git branch <code>release-branch.go1.4</code> or
|
||||
<a href="https://storage.googleapis.com/golang/go1.4-bootstrap-20170531.tar.gz">go1.4-bootstrap-20170531.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 tool chain was written in C.)
|
||||
After unpacking the Go 1.4 source, <code>cd</code> to
|
||||
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 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>.
|
||||
If you want to install Go 1.5 on a system that is not supported by Go 1.4 (such
|
||||
as <code>linux/ppc64</code> and <code>linux/mips64le</code>) you can either use
|
||||
<a href="/src/bootstrap.bash">bootstrap.bash</a> on a system that can bootstrap Go
|
||||
1.5 normally, or bootstrap with gccgo 5.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -175,9 +158,8 @@ and used as <code>GOROOT_BOOTSTRAP</code> to bootstrap a local build.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To use gccgo as the bootstrap toolchain, you need to arrange
|
||||
for <code>$GOROOT_BOOTSTRAP/bin/go</code> to be the go tool that comes
|
||||
as part of gccgo 5. For example on Ubuntu Vivid:
|
||||
To use gccgo, you need to arrange for <code>$GOROOT_BOOTSTRAP/bin/go</code> to be
|
||||
the go tool that comes as part of gccgo 5. For example on Ubuntu Vivid:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
@@ -221,7 +203,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.8.1</code>, for example):</p>
|
||||
(<code class="versionTag">go1.6</code>, for example):</p>
|
||||
|
||||
<pre>
|
||||
$ git clone https://go.googlesource.com/go
|
||||
@@ -338,7 +320,7 @@ You just need to do a little more setup.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The <a href="/doc/code.html">How to Write Go Code</a> document
|
||||
The <a href="/doc/code.html">How to Write Go Code</a> document
|
||||
provides <b>essential setup instructions</b> for using the Go tools.
|
||||
</p>
|
||||
|
||||
@@ -364,7 +346,7 @@ $ go get golang.org/x/tools/cmd/godoc
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
To install these tools, the <code>go</code> <code>get</code> command requires
|
||||
To install these tools, the <code>go</code> <code>get</code> command requires
|
||||
that <a href="#git">Git</a> be installed locally.
|
||||
</p>
|
||||
|
||||
@@ -409,7 +391,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.8.1</code>.
|
||||
<code class="versionTag">go1.6</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -439,7 +421,7 @@ to override the defaults.
|
||||
<ul>
|
||||
<li><code>$GOROOT</code>
|
||||
<p>
|
||||
The root of the Go tree, often <code>$HOME/go1.X</code>.
|
||||
The root of the Go tree, often <code>$HOME/go</code>.
|
||||
Its value is built into the tree when it is compiled, and
|
||||
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
|
||||
@@ -452,7 +434,7 @@ The value assumed by installed binaries and scripts when
|
||||
<code>$GOROOT</code> is not set explicitly.
|
||||
It defaults to the value of <code>$GOROOT</code>.
|
||||
If you want to build the Go tree in one location
|
||||
but move it elsewhere after the build, set
|
||||
but move it elsewhere after the build, set
|
||||
<code>$GOROOT_FINAL</code> to the eventual location.
|
||||
</p>
|
||||
|
||||
@@ -464,7 +446,7 @@ These default to the values of <code>$GOHOSTOS</code> and
|
||||
|
||||
<p>
|
||||
Choices for <code>$GOOS</code> are
|
||||
<code>darwin</code> (Mac OS X 10.8 and above and iOS), <code>dragonfly</code>, <code>freebsd</code>,
|
||||
<code>darwin</code> (Mac OS X 10.7 and above and iOS), <code>dragonfly</code>, <code>freebsd</code>,
|
||||
<code>linux</code>, <code>netbsd</code>, <code>openbsd</code>,
|
||||
<code>plan9</code>, <code>solaris</code> and <code>windows</code>.
|
||||
Choices for <code>$GOARCH</code> are
|
||||
@@ -472,7 +454,6 @@ Choices for <code>$GOARCH</code> are
|
||||
<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), 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>
|
||||
@@ -524,12 +505,6 @@ The valid combinations of <code>$GOOS</code> and <code>$GOARCH</code> are:
|
||||
<td></td><td><code>linux</code></td> <td><code>ppc64le</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td><td><code>linux</code></td> <td><code>mips</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td><td><code>linux</code></td> <td><code>mipsle</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td><td><code>linux</code></td> <td><code>mips64</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -582,7 +557,7 @@ architecture.
|
||||
Valid choices are the same as for <code>$GOOS</code> and
|
||||
<code>$GOARCH</code>, listed above.
|
||||
The specified values must be compatible with the local system.
|
||||
For example, you should not set <code>$GOHOSTARCH</code> to
|
||||
For example, you should not set <code>$GOHOSTARCH</code> to
|
||||
<code>arm</code> on an x86 system.
|
||||
</p>
|
||||
|
||||
@@ -643,12 +618,12 @@ not <code>amd64</code>.
|
||||
<p>
|
||||
If you choose to override the defaults,
|
||||
set these variables in your shell profile (<code>$HOME/.bashrc</code>,
|
||||
<code>$HOME/.profile</code>, or equivalent). The settings might look
|
||||
<code>$HOME/.profile</code>, or equivalent). The settings might look
|
||||
something like this:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
export GOROOT=$HOME/go1.X
|
||||
export GOROOT=$HOME/go
|
||||
export GOARCH=amd64
|
||||
export GOOS=linux
|
||||
</pre>
|
||||
|
||||
@@ -33,7 +33,7 @@ system and architecture, try
|
||||
<h2 id="requirements">System requirements</h2>
|
||||
|
||||
<p>
|
||||
Go <a href="https://golang.org/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,14 +47,14 @@ 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 9.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</td> <td>Debian GNU/kFreeBSD not supported</td></tr>
|
||||
<tr><td>Linux 2.6.23 or later with glibc</td> <td>amd64, 386, arm</td> <td>CentOS/RHEL 5.x not supported</td></tr>
|
||||
<tr><td>Mac OS X 10.7 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>
|
||||
<sup>†</sup>A C compiler is required only if you plan to use
|
||||
<sup>†</sup><code>gcc</code> is required only if you plan to use
|
||||
<a href="/cmd/cgo">cgo</a>.<br/>
|
||||
<sup>‡</sup>You only need to install the command line tools for
|
||||
<a href="http://developer.apple.com/Xcode/">Xcode</a>. If you have already
|
||||
@@ -117,12 +117,12 @@ to point to the directory in which it was installed.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For example, if you installed Go to your home directory you should add
|
||||
commands like the following to <code>$HOME/.profile</code>:
|
||||
For example, if you installed Go to your home directory you should add the
|
||||
following commands to <code>$HOME/.profile</code>:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
export GOROOT=$HOME/go1.X
|
||||
export GOROOT=$HOME/go
|
||||
export PATH=$PATH:$GOROOT/bin
|
||||
</pre>
|
||||
|
||||
@@ -219,15 +219,37 @@ and building a simple program, as follows.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
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>.)
|
||||
Create a directory to contain your <a href="code.html#Workspaces">workspace</a>,
|
||||
<code class="testUnix">$HOME/work</code>
|
||||
<code class="testWindows" style="display: none">C:\work</code>
|
||||
for example, and set the <code>GOPATH</code> environment
|
||||
variable to point to that location.
|
||||
</p>
|
||||
|
||||
<pre class="testUnix">
|
||||
$ <b>export GOPATH=$HOME/work</b>
|
||||
</pre>
|
||||
|
||||
<pre class="testWindows" style="display: none">
|
||||
C:\> <b>set GOPATH=C:\work</b>
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
<span class="testUnix">
|
||||
You should put the above command in your shell startup script
|
||||
(<code>$HOME/.profile</code> for example).
|
||||
</span>
|
||||
<span class="testWindows">
|
||||
On Windows, follow the <a href="#windows_env">instructions above</a> to set the
|
||||
<code>GOPATH</code> environment variable on your system.
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Next, make the directory <code>src/hello</code> inside your workspace,
|
||||
and in that directory create a file named <code>hello.go</code> that looks like:
|
||||
Next, make the directories <code>src/github.com/user/hello</code> inside your
|
||||
workspace (if you use GitHub, substitute your user name for <code>user</code>),
|
||||
and inside the <code>hello</code> directory create a file named <code>hello.go</code>
|
||||
with the following contents:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
@@ -241,33 +263,30 @@ func main() {
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Then build it with the <code>go</code> tool:
|
||||
Then compile it with the <code>go</code> tool:
|
||||
</p>
|
||||
|
||||
<pre class="testUnix">
|
||||
$ <b>cd $HOME/go/src/hello</b>
|
||||
$ <b>go build</b>
|
||||
$ <b>go install github.com/user/hello</b>
|
||||
</pre>
|
||||
|
||||
<pre class="testWindows">
|
||||
C:\> <b>cd %USERPROFILE%\go\src\hello</b>
|
||||
C:\Users\Gopher\go\src\hello> <b>go build</b>
|
||||
<pre class="testWindows" style="display: none">
|
||||
C:\> <b>go install github.com/user/hello</b>
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The command above will build an executable named
|
||||
<code class="testUnix">hello</code><code class="testWindows">hello.exe</code>
|
||||
in the directory alongside your source code.
|
||||
Execute it to see the greeting:
|
||||
The command above will put an executable command named <code>hello</code>
|
||||
(or <code>hello.exe</code>) inside the <code>bin</code> directory of your workspace.
|
||||
Execute the command to see the greeting:
|
||||
</p>
|
||||
|
||||
<pre class="testUnix">
|
||||
$ <b>./hello</b>
|
||||
$ <b>$GOPATH/bin/hello</b>
|
||||
hello, world
|
||||
</pre>
|
||||
|
||||
<pre class="testWindows">
|
||||
C:\Users\Gopher\go\src\hello> <b>hello</b>
|
||||
<pre class="testWindows" style="display: none">
|
||||
C:\> <b>%GOPATH%\bin\hello</b>
|
||||
hello, world
|
||||
</pre>
|
||||
|
||||
@@ -275,12 +294,6 @@ hello, world
|
||||
If you see the "hello, world" message then your Go installation is working.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You can run <code>go</code> <code>install</code> to install the binary into
|
||||
your workspace's <code>bin</code> directory
|
||||
or <code>go</code> <code>clean</code> to remove it.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Before rushing off to write Go code please read the
|
||||
<a href="/doc/code.html">How to Write Go Code</a> document,
|
||||
@@ -312,10 +325,16 @@ environment variables under Windows</a>.
|
||||
<h2 id="help">Getting help</h2>
|
||||
|
||||
<p>
|
||||
For help, see the <a href="/help/">list of Go mailing lists, forums, and places to chat</a>.
|
||||
For real-time help, ask the helpful gophers in <code>#go-nuts</code> on the
|
||||
<a href="http://freenode.net/">Freenode</a> IRC server.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Report bugs either by running “<b><code>go</code> <code>bug</code></b>”, or
|
||||
manually at the <a href="https://golang.org/issue">Go issue tracker</a>.
|
||||
The official mailing list for discussion of the Go language is
|
||||
<a href="//groups.google.com/group/golang-nuts">Go Nuts</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Report bugs using the
|
||||
<a href="//golang.org/issue">Go issue tracker</a>.
|
||||
</p>
|
||||
|
||||
@@ -28,7 +28,7 @@ func Encode() {
|
||||
|
||||
expected := []byte(`{"Name":"Alice","Body":"Hello","Time":1294706395881547000}`)
|
||||
if !reflect.DeepEqual(b, expected) {
|
||||
log.Panicf("Error marshaling %q, expected %q, got %q.", m, expected, b)
|
||||
log.Panicf("Error marshalling %q, expected %q, got %q.", m, expected, b)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func Decode() {
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(m, expected) {
|
||||
log.Panicf("Error unmarshaling %q, expected %q, got %q.", b, expected, m)
|
||||
log.Panicf("Error unmarshalling %q, expected %q, got %q.", b, expected, m)
|
||||
}
|
||||
|
||||
m = Message{
|
||||
@@ -77,7 +77,7 @@ func PartialDecode() {
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(expected, m) {
|
||||
log.Panicf("Error unmarshaling %q, expected %q, got %q.", b, expected, m)
|
||||
log.Panicf("Error unmarshalling %q, expected %q, got %q.", b, expected, m)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ func Decode() {
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(f, expected) {
|
||||
log.Panicf("Error unmarshaling %q, expected %q, got %q", b, expected, f)
|
||||
log.Panicf("Error unmarshalling %q, expected %q, got %q", b, expected, f)
|
||||
}
|
||||
|
||||
f = map[string]interface{}{
|
||||
|
||||
@@ -36,7 +36,7 @@ func Decode() {
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(expected, m) {
|
||||
log.Panicf("Error unmarshaling %q, expected %q, got %q", b, expected, m)
|
||||
log.Panicf("Error unmarshalling %q, expected %q, got %q", b, expected, m)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
BIN
favicon.ico
BIN
favicon.ico
Binary file not shown.
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -8,8 +8,8 @@
|
||||
# Consult http://www.iana.org/time-zones for the latest versions.
|
||||
|
||||
# Versions to use.
|
||||
CODE=2017b
|
||||
DATA=2017b
|
||||
CODE=2016f
|
||||
DATA=2016f
|
||||
|
||||
set -e
|
||||
rm -rf work
|
||||
@@ -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.
@@ -24,16 +24,7 @@ func run(args ...string) string {
|
||||
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 {
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// Copyright 2016 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 16591: Test that we detect an invalid call that was being
|
||||
// hidden by a type conversion inserted by cgo checking.
|
||||
|
||||
package p
|
||||
|
||||
// void f(int** p) { }
|
||||
import "C"
|
||||
|
||||
type x *C.int
|
||||
|
||||
func F(p *x) {
|
||||
C.f(p) // ERROR HERE
|
||||
}
|
||||
@@ -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() // line 16
|
||||
C.pi // line 17
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package main
|
||||
|
||||
import "C"
|
||||
|
||||
func main() {
|
||||
_ = C.malloc // ERROR HERE
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
// Test that C.malloc does not return nil.
|
||||
|
||||
package main
|
||||
|
||||
// #include <stdlib.h>
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var size C.size_t
|
||||
size--
|
||||
|
||||
// The Dragonfly libc succeeds when asked to allocate
|
||||
// 0xffffffffffffffff bytes, so pass a different value that
|
||||
// causes it to fail.
|
||||
if runtime.GOOS == "dragonfly" {
|
||||
size = C.size_t(0x7fffffff << (32 * (^uintptr(0) >> 63)))
|
||||
}
|
||||
|
||||
p := C.malloc(size)
|
||||
if p == nil {
|
||||
fmt.Println("malloc: C.malloc returned nil")
|
||||
// Just exit normally--the test script expects this
|
||||
// program to crash, so exiting normally indicates failure.
|
||||
}
|
||||
}
|
||||
@@ -322,27 +322,6 @@ var ptrTests = []ptrTest{
|
||||
body: `p := &C.s{}; defer C.f(p); p.p = new(C.int)`,
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
// Check a pointer to a union if the union has any
|
||||
// pointer fields.
|
||||
name: "union1",
|
||||
c: `typedef union { char **p; unsigned long i; } u; void f(u *pu) {}`,
|
||||
imports: []string{"unsafe"},
|
||||
body: `var b C.char; p := &b; C.f((*C.u)(unsafe.Pointer(&p)))`,
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
// Don't check a pointer to a union if the union does
|
||||
// not have any pointer fields.
|
||||
// Like ptrdata1 above, the uintptr represents an
|
||||
// integer that happens to have the same
|
||||
// representation as a pointer.
|
||||
name: "union2",
|
||||
c: `typedef union { unsigned long i; } u; void f(u *pu) {}`,
|
||||
imports: []string{"unsafe"},
|
||||
body: `var b C.char; p := &b; C.f((*C.u)(unsafe.Pointer(&p)))`,
|
||||
fail: false,
|
||||
},
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -17,7 +17,7 @@ check() {
|
||||
expect() {
|
||||
file=$1
|
||||
shift
|
||||
if go build -gcflags=-C $file >errs 2>&1; then
|
||||
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
|
||||
@@ -46,9 +46,6 @@ 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
|
||||
check issue18889.go
|
||||
expect issue18452.go issue18452.go:16 issue18452.go:17
|
||||
|
||||
if ! go build issue14669.go; then
|
||||
exit 1
|
||||
@@ -61,15 +58,5 @@ 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
|
||||
|
||||
|
||||
@@ -7,11 +7,6 @@
|
||||
package cgotest
|
||||
|
||||
// #include <stdlib.h>
|
||||
//
|
||||
// // Test for issue 17723.
|
||||
// typedef char *cstring_pointer;
|
||||
// static void cstring_pointer_fun(cstring_pointer dummy) { }
|
||||
//
|
||||
// const char *api_hello = "hello!";
|
||||
import "C"
|
||||
import "unsafe"
|
||||
@@ -26,5 +21,4 @@ func testAPI() {
|
||||
var b []byte
|
||||
b = C.GoBytes(unsafe.Pointer(C.api_hello), C.int(6))
|
||||
_, _ = s, b
|
||||
C.cstring_pointer_fun(nil)
|
||||
}
|
||||
|
||||
@@ -162,6 +162,3 @@ func testUnsignedInt(t *testing.T) {
|
||||
func sliceOperands(array [2000]int) {
|
||||
_ = array[C.KILO:C.KILO:C.KILO] // no type error
|
||||
}
|
||||
|
||||
// set in cgo_thread_lock.go init
|
||||
var testThreadLockFunc = func(*testing.T) {}
|
||||
|
||||
@@ -186,7 +186,6 @@ func testCallbackCallers(t *testing.T) {
|
||||
"runtime.asmcgocall",
|
||||
"runtime.cgocall",
|
||||
"test._Cfunc_callback",
|
||||
"test.nestedCall.func1",
|
||||
"test.nestedCall",
|
||||
"test.testCallbackCallers",
|
||||
"test.TestCallbackCallers",
|
||||
|
||||
@@ -70,15 +70,5 @@ func Test12030(t *testing.T) { test12030(t) }
|
||||
func TestGCC68255(t *testing.T) { testGCC68255(t) }
|
||||
func TestCallGoWithString(t *testing.T) { testCallGoWithString(t) }
|
||||
func Test14838(t *testing.T) { test14838(t) }
|
||||
func Test8756(t *testing.T) { test8756(t) }
|
||||
func Test17065(t *testing.T) { test17065(t) }
|
||||
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 BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
// +build linux,freebsd,openbsd
|
||||
|
||||
package cgotest
|
||||
|
||||
/*
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
void Gosched(void);
|
||||
static int Ctid(void) { Gosched(); return syscall(SYS_gettid); }
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
//export Gosched
|
||||
func Gosched() {
|
||||
runtime.Gosched()
|
||||
}
|
||||
|
||||
func init() {
|
||||
testThreadLockFunc = testThreadLock
|
||||
}
|
||||
|
||||
func testThreadLock(t *testing.T) {
|
||||
stop := make(chan int)
|
||||
go func() {
|
||||
// We need the G continue running,
|
||||
// so the M has a chance to run this G.
|
||||
for {
|
||||
select {
|
||||
case <-stop:
|
||||
return
|
||||
case <-time.After(time.Millisecond * 100):
|
||||
}
|
||||
}
|
||||
}()
|
||||
defer close(stop)
|
||||
|
||||
for i := 0; i < 1000; i++ {
|
||||
if C.int(syscall.Gettid()) != C.Ctid() {
|
||||
t.Fatalf("cgo has not locked OS thread")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,3 @@ import "testing"
|
||||
|
||||
func TestSigaltstack(t *testing.T) { testSigaltstack(t) }
|
||||
func TestSigprocmask(t *testing.T) { testSigprocmask(t) }
|
||||
func Test18146(t *testing.T) { test18146(t) }
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
// Test a constant in conjunction with pointer checking.
|
||||
|
||||
package cgotest
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
|
||||
#define CheckConstVal 0
|
||||
|
||||
typedef struct {
|
||||
int *p;
|
||||
} CheckConstStruct;
|
||||
|
||||
static void CheckConstFunc(CheckConstStruct *p, int e) {
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func testCheckConst(t *testing.T) {
|
||||
// The test is that this compiles successfully.
|
||||
p := C.malloc(C.size_t(unsafe.Sizeof(C.int(0))))
|
||||
defer C.free(p)
|
||||
C.CheckConstFunc(&C.CheckConstStruct{(*C.int)(p)}, C.CheckConstVal)
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// Copyright 2016 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
|
||||
|
||||
/*
|
||||
struct {
|
||||
float x;
|
||||
_Complex float y;
|
||||
} cplxAlign = { 3.14, 2.17 };
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestComplexAlign(t *testing.T) {
|
||||
if C.cplxAlign.x != 3.14 {
|
||||
t.Errorf("got %v, expected 3.14", C.cplxAlign.x)
|
||||
}
|
||||
if C.cplxAlign.y != 2.17 {
|
||||
t.Errorf("got %v, expected 2.17", C.cplxAlign.y)
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
// Copyright 2016 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
|
||||
|
||||
/*
|
||||
// Test that C symbols larger than a page play nicely with the race detector.
|
||||
// See issue 17065.
|
||||
|
||||
int ii[65537];
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var sink C.int
|
||||
|
||||
func test17065(t *testing.T) {
|
||||
if runtime.GOOS == "darwin" {
|
||||
t.Skip("broken on darwin; issue 17065")
|
||||
}
|
||||
for i := range C.ii {
|
||||
sink = C.ii[i]
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
// Copyright 2016 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 17537. The void* cast introduced by cgo to avoid problems
|
||||
// with const/volatile qualifiers breaks C preprocessor macros that
|
||||
// emulate functions.
|
||||
|
||||
package cgotest
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct {
|
||||
int i;
|
||||
} S17537;
|
||||
|
||||
int I17537(S17537 *p);
|
||||
|
||||
#define I17537(p) ((p)->i)
|
||||
|
||||
// Calling this function used to fail without the cast.
|
||||
const int F17537(const char **p) {
|
||||
return **p;
|
||||
}
|
||||
|
||||
// Calling this function used to trigger an error from the C compiler
|
||||
// (issue 18298).
|
||||
void F18298(const void *const *p) {
|
||||
}
|
||||
|
||||
// Test that conversions between typedefs work as they used to.
|
||||
typedef const void *T18298_1;
|
||||
struct S18298 { int i; };
|
||||
typedef const struct S18298 *T18298_2;
|
||||
void G18298(T18298_1 t) {
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import "testing"
|
||||
|
||||
func test17537(t *testing.T) {
|
||||
v := C.S17537{i: 17537}
|
||||
if got, want := C.I17537(&v), C.int(17537); got != want {
|
||||
t.Errorf("got %d, want %d", got, want)
|
||||
}
|
||||
|
||||
p := (*C.char)(C.malloc(1))
|
||||
*p = 17
|
||||
if got, want := C.F17537(&p), C.int(17); got != want {
|
||||
t.Errorf("got %d, want %d", got, want)
|
||||
}
|
||||
|
||||
C.F18298(nil)
|
||||
var v18298 C.T18298_2
|
||||
C.G18298(C.T18298_1(v18298))
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright 2016 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 18126: cgo check of void function returning errno.
|
||||
|
||||
package cgotest
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
|
||||
void Issue18126C(void **p) {
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func test18126(t *testing.T) {
|
||||
p := C.malloc(1)
|
||||
_, err := C.Issue18126C(&p)
|
||||
C.free(p)
|
||||
_ = err
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
// +build !windows
|
||||
|
||||
// Issue 18146: pthread_create failure during syscall.Exec.
|
||||
|
||||
package cgotest
|
||||
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func test18146(t *testing.T) {
|
||||
if runtime.GOOS == "darwin" {
|
||||
t.Skipf("skipping flaky test on %s; see golang.org/issue/18202", runtime.GOOS)
|
||||
}
|
||||
|
||||
if runtime.GOARCH == "mips" || runtime.GOARCH == "mips64" {
|
||||
t.Skipf("skipping on %s", runtime.GOARCH)
|
||||
}
|
||||
|
||||
attempts := 1000
|
||||
threads := 4
|
||||
|
||||
if testing.Short() {
|
||||
attempts = 100
|
||||
}
|
||||
|
||||
// Restrict the number of attempts based on RLIMIT_NPROC.
|
||||
// Tediously, RLIMIT_NPROC was left out of the syscall package,
|
||||
// probably because it is not in POSIX.1, so we define it here.
|
||||
// It is not defined on Solaris.
|
||||
var nproc int
|
||||
setNproc := true
|
||||
switch runtime.GOOS {
|
||||
default:
|
||||
setNproc = false
|
||||
case "linux":
|
||||
nproc = 6
|
||||
case "darwin", "dragonfly", "freebsd", "netbsd", "openbsd":
|
||||
nproc = 7
|
||||
}
|
||||
if setNproc {
|
||||
var rlim syscall.Rlimit
|
||||
if syscall.Getrlimit(nproc, &rlim) == nil {
|
||||
max := int(rlim.Cur) / (threads + 5)
|
||||
if attempts > max {
|
||||
t.Logf("lowering attempts from %d to %d for RLIMIT_NPROC", attempts, max)
|
||||
attempts = max
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if os.Getenv("test18146") == "exec" {
|
||||
runtime.GOMAXPROCS(1)
|
||||
for n := threads; n > 0; n-- {
|
||||
go func() {
|
||||
for {
|
||||
_ = md5.Sum([]byte("Hello, !"))
|
||||
}
|
||||
}()
|
||||
}
|
||||
runtime.GOMAXPROCS(threads)
|
||||
argv := append(os.Args, "-test.run=NoSuchTestExists")
|
||||
if err := syscall.Exec(os.Args[0], argv, os.Environ()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
var cmds []*exec.Cmd
|
||||
defer func() {
|
||||
for _, cmd := range cmds {
|
||||
cmd.Process.Kill()
|
||||
}
|
||||
}()
|
||||
|
||||
args := append(append([]string(nil), os.Args[1:]...), "-test.run=Test18146")
|
||||
for n := attempts; n > 0; n-- {
|
||||
cmd := exec.Command(os.Args[0], args...)
|
||||
cmd.Env = append(os.Environ(), "test18146=exec")
|
||||
buf := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = buf
|
||||
cmd.Stderr = buf
|
||||
if err := cmd.Start(); err != nil {
|
||||
// We are starting so many processes that on
|
||||
// some systems (problem seen on Darwin,
|
||||
// Dragonfly, OpenBSD) the fork call will fail
|
||||
// with EAGAIN.
|
||||
if pe, ok := err.(*os.PathError); ok {
|
||||
err = pe.Err
|
||||
}
|
||||
if se, ok := err.(syscall.Errno); ok && (se == syscall.EAGAIN || se == syscall.EMFILE) {
|
||||
time.Sleep(time.Millisecond)
|
||||
continue
|
||||
}
|
||||
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
cmds = append(cmds, cmd)
|
||||
}
|
||||
|
||||
failures := 0
|
||||
for _, cmd := range cmds {
|
||||
err := cmd.Wait()
|
||||
if err == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
t.Errorf("syscall.Exec failed: %v\n%s", err, cmd.Stdout)
|
||||
failures++
|
||||
}
|
||||
|
||||
if failures > 0 {
|
||||
t.Logf("Failed %v of %v attempts.", failures, len(cmds))
|
||||
}
|
||||
}
|
||||
@@ -1,28 +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)
|
||||
*/
|
||||
import "C"
|
||||
import "testing"
|
||||
|
||||
func test18720(t *testing.T) {
|
||||
if C.HELLO_WORLD != "hello\000world" {
|
||||
t.Fatalf(`expected "hello\000world", but got %q`, C.HELLO_WORLD)
|
||||
}
|
||||
|
||||
// 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))
|
||||
}
|
||||
}
|
||||
@@ -74,15 +74,18 @@ func testNaming(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
if c := C.myfloat_def; c != 1.5 {
|
||||
t.Errorf("C.myint_def = %v, want 1.5", c)
|
||||
}
|
||||
{
|
||||
const c = C.myfloat_def
|
||||
if c != 1.5 {
|
||||
t.Errorf("C.myint as const = %v, want 1.5", c)
|
||||
// This would be nice, but it has never worked.
|
||||
/*
|
||||
if c := C.myfloat_def; c != 1.5 {
|
||||
t.Errorf("C.myint_def = %v, want 1.5", c)
|
||||
}
|
||||
}
|
||||
{
|
||||
const c = C.myfloat_def
|
||||
if c != 1.5 {
|
||||
t.Errorf("C.myint as const = %v, want 1.5", c)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if s := C.mystring_def; s != "hello" {
|
||||
t.Errorf("C.mystring_def = %q, want %q", s, "hello")
|
||||
|
||||
@@ -88,20 +88,9 @@ func issue7978wait(store uint32, wait uint32) {
|
||||
|
||||
//export issue7978cb
|
||||
func issue7978cb() {
|
||||
// Force a stack growth from the callback to put extra
|
||||
// pressure on the runtime. See issue #17785.
|
||||
growStack(64)
|
||||
issue7978wait(3, 4)
|
||||
}
|
||||
|
||||
func growStack(n int) int {
|
||||
var buf [128]int
|
||||
if n == 0 {
|
||||
return 0
|
||||
}
|
||||
return buf[growStack(n-1)]
|
||||
}
|
||||
|
||||
func issue7978go() {
|
||||
C.issue7978c((*C.uint32_t)(&issue7978sync))
|
||||
issue7978wait(7, 8)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package cgotest
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -lm
|
||||
#include <math.h>
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"./issue8756"
|
||||
)
|
||||
|
||||
func test8756(t *testing.T) {
|
||||
issue8756.Pow()
|
||||
C.pow(1, 2)
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package issue8756
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -lm
|
||||
#include <math.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func Pow() {
|
||||
C.pow(1, 2)
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
// +build mips mipsle
|
||||
// +build !gccgo
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
TEXT ·RewindAndSetgid(SB),NOSPLIT,$-4-0
|
||||
// Rewind stack pointer so anything that happens on the stack
|
||||
// will clobber the test pattern created by the caller
|
||||
ADDU $(1024*8), R29
|
||||
|
||||
// Ask signaller to setgid
|
||||
MOVW $1, R1
|
||||
SYNC
|
||||
MOVW R1, ·Baton(SB)
|
||||
SYNC
|
||||
|
||||
// Wait for setgid completion
|
||||
loop:
|
||||
SYNC
|
||||
MOVW ·Baton(SB), R1
|
||||
OR R2, R2, R2 // hint that we're in a spin loop
|
||||
BNE R1, loop
|
||||
SYNC
|
||||
|
||||
// Restore stack
|
||||
ADDU $(-1024*8), R29
|
||||
RET
|
||||
@@ -17,7 +17,7 @@ package cgotest
|
||||
static stack_t oss;
|
||||
static char signalStack[SIGSTKSZ];
|
||||
|
||||
static void changeSignalStack(void) {
|
||||
static void changeSignalStack() {
|
||||
stack_t ss;
|
||||
memset(&ss, 0, sizeof ss);
|
||||
ss.ss_sp = signalStack;
|
||||
@@ -29,7 +29,7 @@ static void changeSignalStack(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static void restoreSignalStack(void) {
|
||||
static void restoreSignalStack() {
|
||||
#if (defined(__x86_64__) || defined(__i386__)) && defined(__APPLE__)
|
||||
// The Darwin C library enforces a minimum that the kernel does not.
|
||||
// This is OK since we allocated this much space in mpreinit,
|
||||
@@ -42,7 +42,7 @@ static void restoreSignalStack(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static int zero(void) {
|
||||
static int zero() {
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,6 @@ package carchive_test
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"debug/elf"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@@ -35,9 +34,13 @@ var GOOS, GOARCH string
|
||||
var libgodir string
|
||||
|
||||
func init() {
|
||||
bin = []string{"./testp"}
|
||||
GOOS = goEnv("GOOS")
|
||||
GOARCH = goEnv("GOARCH")
|
||||
bin = cmdToRun("./testp")
|
||||
execScript := "go_" + GOOS + "_" + GOARCH + "_exec"
|
||||
if executor, err := exec.LookPath(execScript); err == nil {
|
||||
bin = []string{executor, "./testp"}
|
||||
}
|
||||
|
||||
ccOut := goEnv("CC")
|
||||
cc = []string{string(ccOut)}
|
||||
@@ -81,13 +84,8 @@ func init() {
|
||||
cc = append(cc, []string{"-framework", "CoreFoundation", "-framework", "Foundation"}...)
|
||||
}
|
||||
libgodir = GOOS + "_" + GOARCH
|
||||
switch GOOS {
|
||||
case "darwin":
|
||||
if GOARCH == "arm" || GOARCH == "arm64" {
|
||||
libgodir += "_shared"
|
||||
}
|
||||
case "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "solaris":
|
||||
libgodir += "_shared"
|
||||
if GOOS == "darwin" && (GOARCH == "arm" || GOARCH == "arm64") {
|
||||
libgodir = GOOS + "_" + GOARCH + "_shared"
|
||||
}
|
||||
cc = append(cc, "-I", filepath.Join("pkg", libgodir))
|
||||
|
||||
@@ -115,71 +113,88 @@ func init() {
|
||||
func goEnv(key string) string {
|
||||
out, err := exec.Command("go", "env", key).Output()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "go env %s failed:\n%s\n", key, err)
|
||||
if ee, ok := err.(*exec.ExitError); ok {
|
||||
fmt.Fprintf(os.Stderr, "%s", ee.Stderr)
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "go env %s failed:\n%s", key, err)
|
||||
fmt.Fprintf(os.Stderr, "%s", err.(*exec.ExitError).Stderr)
|
||||
os.Exit(2)
|
||||
}
|
||||
return strings.TrimSpace(string(out))
|
||||
}
|
||||
|
||||
func cmdToRun(name string) []string {
|
||||
execScript := "go_" + goEnv("GOOS") + "_" + goEnv("GOARCH") + "_exec"
|
||||
executor, err := exec.LookPath(execScript)
|
||||
if err != nil {
|
||||
return []string{name}
|
||||
}
|
||||
return []string{executor, name}
|
||||
}
|
||||
|
||||
func testInstall(t *testing.T, exe, libgoa, libgoh string, buildcmd ...string) {
|
||||
cmd := exec.Command(buildcmd[0], buildcmd[1:]...)
|
||||
cmd.Env = gopathEnv
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Logf("%s", out)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() {
|
||||
os.Remove(libgoa)
|
||||
os.Remove(libgoh)
|
||||
}()
|
||||
|
||||
ccArgs := append(cc, "-o", exe, "main.c")
|
||||
func compilemain(t *testing.T, libgo string) {
|
||||
ccArgs := append(cc, "-o", "testp"+exeSuffix, "main.c")
|
||||
if GOOS == "windows" {
|
||||
ccArgs = append(ccArgs, "main_windows.c", libgoa, "-lntdll", "-lws2_32", "-lwinmm")
|
||||
ccArgs = append(ccArgs, "main_windows.c", libgo, "-lntdll", "-lws2_32", "-lwinmm")
|
||||
} else {
|
||||
ccArgs = append(ccArgs, "main_unix.c", libgoa)
|
||||
ccArgs = append(ccArgs, "main_unix.c", libgo)
|
||||
}
|
||||
t.Log(ccArgs)
|
||||
if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil {
|
||||
t.Logf("%s", out)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(exe)
|
||||
|
||||
binArgs := append(cmdToRun(exe), "arg1", "arg2")
|
||||
if out, err := exec.Command(binArgs[0], binArgs[1:]...).CombinedOutput(); err != nil {
|
||||
if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil {
|
||||
t.Logf("%s", out)
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInstall(t *testing.T) {
|
||||
defer os.RemoveAll("pkg")
|
||||
defer func() {
|
||||
os.Remove("libgo.a")
|
||||
os.Remove("libgo.h")
|
||||
os.Remove("testp")
|
||||
os.RemoveAll("pkg")
|
||||
}()
|
||||
|
||||
testInstall(t, "./testp1"+exeSuffix,
|
||||
filepath.Join("pkg", libgodir, "libgo.a"),
|
||||
filepath.Join("pkg", libgodir, "libgo.h"),
|
||||
"go", "install", "-buildmode=c-archive", "libgo")
|
||||
cmd := exec.Command("go", "install", "-buildmode=c-archive", "libgo")
|
||||
cmd.Env = gopathEnv
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Logf("%s", out)
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
compilemain(t, filepath.Join("pkg", libgodir, "libgo.a"))
|
||||
|
||||
binArgs := append(bin, "arg1", "arg2")
|
||||
if out, err := exec.Command(binArgs[0], binArgs[1:]...).CombinedOutput(); err != nil {
|
||||
t.Logf("%s", out)
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
os.Remove("libgo.a")
|
||||
os.Remove("libgo.h")
|
||||
os.Remove("testp")
|
||||
|
||||
// Test building libgo other than installing it.
|
||||
// Header files are now present.
|
||||
testInstall(t, "./testp2"+exeSuffix, "libgo.a", "libgo.h",
|
||||
"go", "build", "-buildmode=c-archive", filepath.Join("src", "libgo", "libgo.go"))
|
||||
cmd = exec.Command("go", "build", "-buildmode=c-archive", filepath.Join("src", "libgo", "libgo.go"))
|
||||
cmd.Env = gopathEnv
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Logf("%s", out)
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
testInstall(t, "./testp3"+exeSuffix, "libgo.a", "libgo.h",
|
||||
"go", "build", "-buildmode=c-archive", "-o", "libgo.a", "libgo")
|
||||
compilemain(t, "libgo.a")
|
||||
|
||||
if out, err := exec.Command(binArgs[0], binArgs[1:]...).CombinedOutput(); err != nil {
|
||||
t.Logf("%s", out)
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
os.Remove("libgo.a")
|
||||
os.Remove("libgo.h")
|
||||
os.Remove("testp")
|
||||
|
||||
cmd = exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo.a", "libgo")
|
||||
cmd.Env = gopathEnv
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Logf("%s", out)
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
compilemain(t, "libgo.a")
|
||||
|
||||
if out, err := exec.Command(binArgs[0], binArgs[1:]...).CombinedOutput(); err != nil {
|
||||
t.Logf("%s", out)
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEarlySignalHandler(t *testing.T) {
|
||||
@@ -220,7 +235,15 @@ func TestEarlySignalHandler(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSignalForwarding(t *testing.T) {
|
||||
checkSignalForwardingTest(t)
|
||||
switch GOOS {
|
||||
case "darwin":
|
||||
switch GOARCH {
|
||||
case "arm", "arm64":
|
||||
t.Skipf("skipping on %s/%s; see https://golang.org/issue/13701", GOOS, GOARCH)
|
||||
}
|
||||
case "windows":
|
||||
t.Skip("skipping signal test on Windows")
|
||||
}
|
||||
|
||||
defer func() {
|
||||
os.Remove("libgo2.a")
|
||||
@@ -245,19 +268,32 @@ func TestSignalForwarding(t *testing.T) {
|
||||
cmd = exec.Command(bin[0], append(bin[1:], "1")...)
|
||||
|
||||
out, err := cmd.CombinedOutput()
|
||||
t.Logf("%s", out)
|
||||
expectSignal(t, err, syscall.SIGSEGV)
|
||||
|
||||
// Test SIGPIPE forwarding
|
||||
cmd = exec.Command(bin[0], append(bin[1:], "3")...)
|
||||
|
||||
out, err = cmd.CombinedOutput()
|
||||
t.Logf("%s", out)
|
||||
expectSignal(t, err, syscall.SIGPIPE)
|
||||
if err == nil {
|
||||
t.Logf("%s", out)
|
||||
t.Error("test program succeeded unexpectedly")
|
||||
} else if ee, ok := err.(*exec.ExitError); !ok {
|
||||
t.Logf("%s", out)
|
||||
t.Errorf("error (%v) has type %T; expected exec.ExitError", err, err)
|
||||
} else if ws, ok := ee.Sys().(syscall.WaitStatus); !ok {
|
||||
t.Logf("%s", out)
|
||||
t.Errorf("error.Sys (%v) has type %T; expected syscall.WaitStatus", ee.Sys(), ee.Sys())
|
||||
} else if !ws.Signaled() || ws.Signal() != syscall.SIGSEGV {
|
||||
t.Logf("%s", out)
|
||||
t.Errorf("got %v; expected SIGSEGV", ee)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSignalForwardingExternal(t *testing.T) {
|
||||
checkSignalForwardingTest(t)
|
||||
switch GOOS {
|
||||
case "darwin":
|
||||
switch GOARCH {
|
||||
case "arm", "arm64":
|
||||
t.Skipf("skipping on %s/%s; see https://golang.org/issue/13701", GOOS, GOARCH)
|
||||
}
|
||||
case "windows":
|
||||
t.Skip("skipping signal test on Windows")
|
||||
}
|
||||
|
||||
defer func() {
|
||||
os.Remove("libgo2.a")
|
||||
@@ -325,7 +361,14 @@ func TestSignalForwardingExternal(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
|
||||
if expectSignal(t, err, syscall.SIGSEGV) {
|
||||
if ee, ok := err.(*exec.ExitError); !ok {
|
||||
t.Errorf("error (%v) has type %T; expected exec.ExitError", err, err)
|
||||
} else if ws, ok := ee.Sys().(syscall.WaitStatus); !ok {
|
||||
t.Errorf("error.Sys (%v) has type %T; expected syscall.WaitStatus", ee.Sys(), ee.Sys())
|
||||
} else if !ws.Signaled() || ws.Signal() != syscall.SIGSEGV {
|
||||
t.Errorf("got %v; expected SIGSEGV", ee)
|
||||
} else {
|
||||
// We got the error we expected.
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -333,38 +376,6 @@ func TestSignalForwardingExternal(t *testing.T) {
|
||||
t.Errorf("program succeeded unexpectedly %d times", tries)
|
||||
}
|
||||
|
||||
// checkSignalForwardingTest calls t.Skip if the SignalForwarding test
|
||||
// doesn't work on this platform.
|
||||
func checkSignalForwardingTest(t *testing.T) {
|
||||
switch GOOS {
|
||||
case "darwin":
|
||||
switch GOARCH {
|
||||
case "arm", "arm64":
|
||||
t.Skipf("skipping on %s/%s; see https://golang.org/issue/13701", GOOS, GOARCH)
|
||||
}
|
||||
case "windows":
|
||||
t.Skip("skipping signal test on Windows")
|
||||
}
|
||||
}
|
||||
|
||||
// expectSignal checks that err, the exit status of a test program,
|
||||
// shows a failure due to a specific signal. Returns whether we found
|
||||
// the expected signal.
|
||||
func expectSignal(t *testing.T, err error, sig syscall.Signal) bool {
|
||||
if err == nil {
|
||||
t.Error("test program succeeded unexpectedly")
|
||||
} else if ee, ok := err.(*exec.ExitError); !ok {
|
||||
t.Errorf("error (%v) has type %T; expected exec.ExitError", err, err)
|
||||
} else if ws, ok := ee.Sys().(syscall.WaitStatus); !ok {
|
||||
t.Errorf("error.Sys (%v) has type %T; expected syscall.WaitStatus", ee.Sys(), ee.Sys())
|
||||
} else if !ws.Signaled() || ws.Signal() != sig {
|
||||
t.Errorf("got %v; expected signal %v", ee, sig)
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func TestOsSignal(t *testing.T) {
|
||||
switch GOOS {
|
||||
case "windows":
|
||||
@@ -476,147 +487,3 @@ func TestExtar(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPIE(t *testing.T) {
|
||||
switch GOOS {
|
||||
case "windows", "darwin", "plan9":
|
||||
t.Skipf("skipping PIE test on %s", GOOS)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
os.Remove("testp" + exeSuffix)
|
||||
os.RemoveAll("pkg")
|
||||
}()
|
||||
|
||||
cmd := exec.Command("go", "install", "-buildmode=c-archive", "libgo")
|
||||
cmd.Env = gopathEnv
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Logf("%s", out)
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ccArgs := append(cc, "-fPIE", "-pie", "-o", "testp"+exeSuffix, "main.c", "main_unix.c", filepath.Join("pkg", libgodir, "libgo.a"))
|
||||
if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil {
|
||||
t.Logf("%s", out)
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
binArgs := append(bin, "arg1", "arg2")
|
||||
if out, err := exec.Command(binArgs[0], binArgs[1:]...).CombinedOutput(); err != nil {
|
||||
t.Logf("%s", out)
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
f, err := elf.Open("testp" + exeSuffix)
|
||||
if err != nil {
|
||||
t.Fatal("elf.Open failed: ", err)
|
||||
}
|
||||
defer f.Close()
|
||||
if hasDynTag(t, f, elf.DT_TEXTREL) {
|
||||
t.Errorf("%s has DT_TEXTREL flag", "testp"+exeSuffix)
|
||||
}
|
||||
}
|
||||
|
||||
func hasDynTag(t *testing.T, f *elf.File, tag elf.DynTag) bool {
|
||||
ds := f.SectionByType(elf.SHT_DYNAMIC)
|
||||
if ds == nil {
|
||||
t.Error("no SHT_DYNAMIC section")
|
||||
return false
|
||||
}
|
||||
d, err := ds.Data()
|
||||
if err != nil {
|
||||
t.Errorf("can't read SHT_DYNAMIC contents: %v", err)
|
||||
return false
|
||||
}
|
||||
for len(d) > 0 {
|
||||
var t elf.DynTag
|
||||
switch f.Class {
|
||||
case elf.ELFCLASS32:
|
||||
t = elf.DynTag(f.ByteOrder.Uint32(d[:4]))
|
||||
d = d[8:]
|
||||
case elf.ELFCLASS64:
|
||||
t = elf.DynTag(f.ByteOrder.Uint64(d[:8]))
|
||||
d = d[16:]
|
||||
}
|
||||
if t == tag {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func TestSIGPROF(t *testing.T) {
|
||||
switch GOOS {
|
||||
case "windows", "plan9":
|
||||
t.Skipf("skipping SIGPROF test on %s", GOOS)
|
||||
}
|
||||
|
||||
t.Parallel()
|
||||
|
||||
defer func() {
|
||||
os.Remove("testp6" + exeSuffix)
|
||||
os.Remove("libgo6.a")
|
||||
os.Remove("libgo6.h")
|
||||
}()
|
||||
|
||||
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo6.a", "libgo6")
|
||||
cmd.Env = gopathEnv
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Logf("%s", out)
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ccArgs := append(cc, "-o", "testp6"+exeSuffix, "main6.c", "libgo6.a")
|
||||
if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil {
|
||||
t.Logf("%s", out)
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
argv := cmdToRun("./testp6")
|
||||
cmd = exec.Command(argv[0], argv[1:]...)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Logf("%s", out)
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestCompileWithoutShared tests that if we compile code without the
|
||||
// -shared option, we can put it into an archive. When we use the go
|
||||
// tool with -buildmode=c-archive, it passes -shared to the compiler,
|
||||
// so we override that. The go tool doesn't work this way, but Bazel
|
||||
// will likely do it in the future. And it ought to work. This test
|
||||
// was added because at one time it did not work on PPC GNU/Linux.
|
||||
func TestCompileWithoutShared(t *testing.T) {
|
||||
// For simplicity, reuse the signal forwarding test.
|
||||
checkSignalForwardingTest(t)
|
||||
|
||||
defer func() {
|
||||
os.Remove("libgo2.a")
|
||||
os.Remove("libgo2.h")
|
||||
}()
|
||||
|
||||
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-gcflags=-shared=false", "-o", "libgo2.a", "libgo2")
|
||||
cmd.Env = gopathEnv
|
||||
t.Log(cmd.Args)
|
||||
out, err := cmd.CombinedOutput()
|
||||
t.Logf("%s", out)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
exe := "./testnoshared" + exeSuffix
|
||||
ccArgs := append(cc, "-o", exe, "main5.c", "libgo2.a")
|
||||
t.Log(ccArgs)
|
||||
out, err = exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput()
|
||||
t.Logf("%s", out)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(exe)
|
||||
|
||||
binArgs := append(cmdToRun(exe), "3")
|
||||
t.Log(binArgs)
|
||||
out, err = exec.Command(binArgs[0], binArgs[1:]...).CombinedOutput()
|
||||
t.Logf("%s", out)
|
||||
expectSignal(t, err, syscall.SIGPIPE)
|
||||
}
|
||||
|
||||
@@ -7,17 +7,14 @@
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <sched.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "libgo2.h"
|
||||
|
||||
@@ -27,7 +24,6 @@ static void die(const char* msg) {
|
||||
}
|
||||
|
||||
static volatile sig_atomic_t sigioSeen;
|
||||
static volatile sig_atomic_t sigpipeSeen;
|
||||
|
||||
// Use up some stack space.
|
||||
static void recur(int i, char *p) {
|
||||
@@ -39,10 +35,6 @@ static void recur(int i, char *p) {
|
||||
}
|
||||
}
|
||||
|
||||
static void pipeHandler(int signo, siginfo_t* info, void* ctxt) {
|
||||
sigpipeSeen = 1;
|
||||
}
|
||||
|
||||
// Signal handler that uses up more stack space than a goroutine will have.
|
||||
static void ioHandler(int signo, siginfo_t* info, void* ctxt) {
|
||||
char a[1024];
|
||||
@@ -54,22 +46,11 @@ static void ioHandler(int signo, siginfo_t* info, void* ctxt) {
|
||||
static jmp_buf jmp;
|
||||
static char* nullPointer;
|
||||
|
||||
// An arbitrary function which requires proper stack alignment; see
|
||||
// http://golang.org/issue/17641.
|
||||
static void callWithVarargs(void* dummy, ...) {
|
||||
va_list args;
|
||||
va_start(args, dummy);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
// Signal handler for SIGSEGV on a C thread.
|
||||
static void segvHandler(int signo, siginfo_t* info, void* ctxt) {
|
||||
sigset_t mask;
|
||||
int i;
|
||||
|
||||
// Call an arbitrary function that requires the stack to be properly aligned.
|
||||
callWithVarargs("dummy arg", 3.1415);
|
||||
|
||||
if (sigemptyset(&mask) < 0) {
|
||||
die("sigemptyset");
|
||||
}
|
||||
@@ -112,17 +93,12 @@ static void init() {
|
||||
die("sigaction");
|
||||
}
|
||||
|
||||
sa.sa_sigaction = pipeHandler;
|
||||
if (sigaction(SIGPIPE, &sa, NULL) < 0) {
|
||||
die("sigaction");
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int verbose;
|
||||
sigset_t mask;
|
||||
int i;
|
||||
struct timespec ts;
|
||||
|
||||
verbose = argc > 1;
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
@@ -172,35 +148,12 @@ int main(int argc, char** argv) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (!sigioSeen) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
fprintf(stderr, "looping too long waiting for SIGIO\n");
|
||||
exit(EXIT_FAILURE);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
printf("provoking SIGPIPE\n");
|
||||
}
|
||||
|
||||
GoRaiseSIGPIPE();
|
||||
|
||||
if (verbose) {
|
||||
printf("waiting for sigpipeSeen\n");
|
||||
}
|
||||
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (!sigpipeSeen) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
fprintf(stderr, "looping too long waiting for SIGPIPE\n");
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libgo3.h"
|
||||
|
||||
@@ -26,48 +24,14 @@ static void ioHandler(int signo, siginfo_t* info, void* ctxt) {
|
||||
sigioSeen = 1;
|
||||
}
|
||||
|
||||
// Set up the SIGPIPE signal handler in a high priority constructor, so
|
||||
// that it is installed before the Go code starts.
|
||||
|
||||
static void pipeHandler(int signo, siginfo_t* info, void* ctxt) {
|
||||
const char *s = "unexpected SIGPIPE\n";
|
||||
write(2, s, strlen(s));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void init(void) __attribute__ ((constructor (200)));
|
||||
|
||||
static void init() {
|
||||
struct sigaction sa;
|
||||
|
||||
memset(&sa, 0, sizeof sa);
|
||||
sa.sa_sigaction = pipeHandler;
|
||||
if (sigemptyset(&sa.sa_mask) < 0) {
|
||||
die("sigemptyset");
|
||||
}
|
||||
sa.sa_flags = SA_SIGINFO;
|
||||
if (sigaction(SIGPIPE, &sa, NULL) < 0) {
|
||||
die("sigaction");
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int verbose;
|
||||
struct sigaction sa;
|
||||
int i;
|
||||
struct timespec ts;
|
||||
|
||||
verbose = argc > 2;
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
|
||||
if (verbose) {
|
||||
printf("raising SIGPIPE\n");
|
||||
}
|
||||
|
||||
// Test that the Go runtime handles SIGPIPE, even if we installed
|
||||
// a non-default SIGPIPE handler before the runtime initializes.
|
||||
ProvokeSIGPIPE();
|
||||
|
||||
if (verbose) {
|
||||
printf("calling sigaction\n");
|
||||
}
|
||||
@@ -100,11 +64,11 @@ int main(int argc, char** argv) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (!sigioSeen) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -174,11 +138,11 @@ int main(int argc, char** argv) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (!sigioSeen) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sched.h>
|
||||
#include <pthread.h>
|
||||
|
||||
@@ -49,7 +48,6 @@ static void* thread1(void* arg __attribute__ ((unused))) {
|
||||
stack_t ss;
|
||||
int i;
|
||||
stack_t nss;
|
||||
struct timespec ts;
|
||||
|
||||
// Set up an alternate signal stack for this thread.
|
||||
memset(&ss, 0, sizeof ss);
|
||||
@@ -75,11 +73,11 @@ static void* thread1(void* arg __attribute__ ((unused))) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (SIGIOCount() == 0) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -107,7 +105,6 @@ static void* thread2(void* arg __attribute__ ((unused))) {
|
||||
int i;
|
||||
int oldcount;
|
||||
pthread_t tid;
|
||||
struct timespec ts;
|
||||
stack_t nss;
|
||||
|
||||
// Set up an alternate signal stack for this thread.
|
||||
@@ -132,11 +129,11 @@ static void* thread2(void* arg __attribute__ ((unused))) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (SIGIOCount() == oldcount) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -68,24 +68,6 @@ int main(int argc, char** argv) {
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
if (verbose) {
|
||||
printf("attempting SIGPIPE\n");
|
||||
}
|
||||
|
||||
int fd[2];
|
||||
if (pipe(fd) != 0) {
|
||||
printf("pipe(2) failed\n");
|
||||
return 0;
|
||||
}
|
||||
// Close the reading end.
|
||||
close(fd[0]);
|
||||
// Expect that write(2) fails (EPIPE)
|
||||
if (write(fd[1], "some data", 9) != -1) {
|
||||
printf("write(2) unexpectedly succeeded\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
default:
|
||||
printf("Unknown test: %d\n", test);
|
||||
return 0;
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
// Test that using the Go profiler in a C program does not crash.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "libgo6.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
struct timeval tvstart, tvnow;
|
||||
int diff;
|
||||
|
||||
gettimeofday(&tvstart, NULL);
|
||||
|
||||
go_start_profile();
|
||||
|
||||
// Busy wait so we have something to profile.
|
||||
// If we just sleep the profiling signal will never fire.
|
||||
while (1) {
|
||||
gettimeofday(&tvnow, NULL);
|
||||
diff = (tvnow.tv_sec - tvstart.tv_sec) * 1000 * 1000 + (tvnow.tv_usec - tvstart.tv_usec);
|
||||
|
||||
// Profile frequency is 100Hz so we should definitely
|
||||
// get a signal in 50 milliseconds.
|
||||
if (diff > 50 * 1000)
|
||||
break;
|
||||
}
|
||||
|
||||
go_stop_profile();
|
||||
return 0;
|
||||
}
|
||||
@@ -4,30 +4,6 @@
|
||||
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Raise SIGPIPE.
|
||||
static void CRaiseSIGPIPE() {
|
||||
int fds[2];
|
||||
|
||||
if (pipe(fds) == -1) {
|
||||
perror("pipe");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// Close the reader end
|
||||
close(fds[0]);
|
||||
// Write to the writer end to provoke a SIGPIPE
|
||||
if (write(fds[1], "some data", 9) != -1) {
|
||||
fprintf(stderr, "write to a closed pipe succeeded\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
close(fds[1]);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
@@ -70,11 +46,5 @@ func TestSEGV() {
|
||||
func Noop() {
|
||||
}
|
||||
|
||||
// Raise SIGPIPE.
|
||||
//export GoRaiseSIGPIPE
|
||||
func GoRaiseSIGPIPE() {
|
||||
C.CRaiseSIGPIPE()
|
||||
}
|
||||
|
||||
func main() {
|
||||
}
|
||||
|
||||
@@ -40,17 +40,5 @@ func SawSIGIO() C.int {
|
||||
}
|
||||
}
|
||||
|
||||
// ProvokeSIGPIPE provokes a kernel-initiated SIGPIPE.
|
||||
//export ProvokeSIGPIPE
|
||||
func ProvokeSIGPIPE() {
|
||||
r, w, err := os.Pipe()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
r.Close()
|
||||
defer w.Close()
|
||||
w.Write([]byte("some data"))
|
||||
}
|
||||
|
||||
func main() {
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
// Copyright 2016 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
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"runtime/pprof"
|
||||
)
|
||||
|
||||
import "C"
|
||||
|
||||
//export go_start_profile
|
||||
func go_start_profile() {
|
||||
pprof.StartCPUProfile(ioutil.Discard)
|
||||
}
|
||||
|
||||
//export go_stop_profile
|
||||
func go_stop_profile() {
|
||||
pprof.StopCPUProfile()
|
||||
}
|
||||
|
||||
func main() {
|
||||
}
|
||||
@@ -12,7 +12,6 @@
|
||||
// int8_t DidInitRun();
|
||||
// int8_t DidMainRun();
|
||||
// int32_t FromPkg();
|
||||
// uint32_t Divu(uint32_t, uint32_t);
|
||||
int main(void) {
|
||||
int8_t ran_init = DidInitRun();
|
||||
if (!ran_init) {
|
||||
@@ -31,11 +30,6 @@ int main(void) {
|
||||
fprintf(stderr, "ERROR: FromPkg=%d, want %d\n", from_pkg, 1024);
|
||||
return 1;
|
||||
}
|
||||
uint32_t divu = Divu(2264, 31);
|
||||
if (divu != 73) {
|
||||
fprintf(stderr, "ERROR: Divu(2264, 31)=%d, want %d\n", divu, 73);
|
||||
return 1;
|
||||
}
|
||||
// test.bash looks for "PASS" to ensure this program has reached the end.
|
||||
printf("PASS\n");
|
||||
return 0;
|
||||
|
||||
@@ -21,7 +21,7 @@ int main(void) {
|
||||
|
||||
// The descriptor will be initialized in a thread, so we have to
|
||||
// give a chance to get opened.
|
||||
for (i = 0; i < 1000; i++) {
|
||||
for (i = 0; i < 100; i++) {
|
||||
n = read(fd, buf, sizeof buf);
|
||||
if (n >= 0)
|
||||
break;
|
||||
|
||||
@@ -77,7 +77,6 @@ int main(int argc, char** argv) {
|
||||
void (*fn)(void);
|
||||
sigset_t mask;
|
||||
int i;
|
||||
struct timespec ts;
|
||||
|
||||
verbose = argc > 2;
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
@@ -167,11 +166,11 @@ int main(int argc, char** argv) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (!sigioSeen) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sched.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
@@ -32,7 +31,6 @@ int main(int argc, char** argv) {
|
||||
void (*fn1)(void);
|
||||
int (*sawSIGIO)(void);
|
||||
int i;
|
||||
struct timespec ts;
|
||||
|
||||
verbose = argc > 2;
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
@@ -79,11 +77,11 @@ int main(int argc, char** argv) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (!sigioSeen) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -184,11 +182,11 @@ int main(int argc, char** argv) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (!sigioSeen) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -8,5 +8,3 @@ import "C"
|
||||
|
||||
//export FromPkg
|
||||
func FromPkg() int32 { return 1024 }
|
||||
//export Divu
|
||||
func Divu(a, b uint32) uint32 { return a / b }
|
||||
|
||||
@@ -27,7 +27,7 @@ fi
|
||||
# Directory where cgo headers and outputs will be installed.
|
||||
# The installation directory format varies depending on the platform.
|
||||
installdir=pkg/${goos}_${goarch}_testcshared_shared
|
||||
if [ "${goos}" = "darwin" ]; then
|
||||
if [ "${goos}" == "darwin" ]; then
|
||||
installdir=pkg/${goos}_${goarch}_testcshared
|
||||
fi
|
||||
|
||||
@@ -40,13 +40,13 @@ function cleanup() {
|
||||
rm -f testp testp2 testp3 testp4 testp5
|
||||
rm -rf pkg "${goroot}/${installdir}"
|
||||
|
||||
if [ "$goos" = "android" ]; then
|
||||
if [ "$goos" == "android" ]; then
|
||||
adb shell rm -rf "$androidpath"
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
if [ "$goos" = "android" ]; then
|
||||
if [ "$goos" == "android" ]; then
|
||||
adb shell mkdir -p "$androidpath"
|
||||
fi
|
||||
|
||||
@@ -69,7 +69,7 @@ function run() {
|
||||
|
||||
function binpush() {
|
||||
bin=${1}
|
||||
if [ "$goos" = "android" ]; then
|
||||
if [ "$goos" == "android" ]; then
|
||||
adb push "$bin" "${androidpath}/${bin}" 2>/dev/null
|
||||
fi
|
||||
}
|
||||
@@ -79,7 +79,7 @@ rm -rf pkg
|
||||
suffix="-installsuffix testcshared"
|
||||
|
||||
libext="so"
|
||||
if [ "$goos" = "darwin" ]; then
|
||||
if [ "$goos" == "darwin" ]; then
|
||||
libext="dylib"
|
||||
fi
|
||||
|
||||
@@ -89,7 +89,7 @@ GOPATH=$(pwd) go install -buildmode=c-shared $suffix libgo
|
||||
GOPATH=$(pwd) go build -buildmode=c-shared $suffix -o libgo.$libext src/libgo/libgo.go
|
||||
binpush libgo.$libext
|
||||
|
||||
if [ "$goos" = "linux" ] || [ "$goos" = "android" ] ; then
|
||||
if [ "$goos" == "linux" ] || [ "$goos" == "android" ] ; then
|
||||
if readelf -d libgo.$libext | grep TEXTREL >/dev/null; then
|
||||
echo "libgo.$libext has TEXTREL set"
|
||||
exit 1
|
||||
@@ -97,15 +97,15 @@ if [ "$goos" = "linux" ] || [ "$goos" = "android" ] ; then
|
||||
fi
|
||||
|
||||
GOGCCFLAGS=$(go env GOGCCFLAGS)
|
||||
if [ "$goos" = "android" ]; then
|
||||
GOGCCFLAGS="${GOGCCFLAGS} -pie -fuse-ld=gold"
|
||||
if [ "$goos" == "android" ]; then
|
||||
GOGCCFLAGS="${GOGCCFLAGS} -pie"
|
||||
fi
|
||||
|
||||
status=0
|
||||
|
||||
# test0: exported symbols in shared lib are accessible.
|
||||
# TODO(iant): using _shared here shouldn't really be necessary.
|
||||
$(go env CC) ${GOGCCFLAGS} -I ${installdir} -o testp main0.c ./libgo.$libext
|
||||
$(go env CC) ${GOGCCFLAGS} -I ${installdir} -o testp main0.c libgo.$libext
|
||||
binpush testp
|
||||
|
||||
output=$(run LD_LIBRARY_PATH=. ./testp)
|
||||
@@ -127,7 +127,7 @@ fi
|
||||
GOPATH=$(pwd) go build -buildmode=c-shared $suffix -o libgo2.$libext libgo2
|
||||
binpush libgo2.$libext
|
||||
linkflags="-Wl,--no-as-needed"
|
||||
if [ "$goos" = "darwin" ]; then
|
||||
if [ "$goos" == "darwin" ]; then
|
||||
linkflags=""
|
||||
fi
|
||||
$(go env CC) ${GOGCCFLAGS} -o testp2 main2.c $linkflags libgo2.$libext
|
||||
@@ -139,7 +139,7 @@ if [ "$output" != "PASS" ]; then
|
||||
fi
|
||||
|
||||
# test3: tests main.main is exported on android.
|
||||
if [ "$goos" = "android" ]; then
|
||||
if [ "$goos" == "android" ]; then
|
||||
$(go env CC) ${GOGCCFLAGS} -o testp3 main3.c -ldl
|
||||
binpush testp3
|
||||
output=$(run ./testp ./libgo.so)
|
||||
@@ -179,13 +179,6 @@ if test "$output" != "PASS"; then
|
||||
status=1
|
||||
fi
|
||||
|
||||
if test "$libext" = "dylib"; then
|
||||
# make sure dylibs are well-formed
|
||||
if ! otool -l libgo*.dylib >/dev/null; then
|
||||
status=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $status = 0; then
|
||||
echo "ok"
|
||||
fi
|
||||
|
||||
@@ -12,7 +12,7 @@ FILE_PREFIXES="anonunion issue8478"
|
||||
RM=
|
||||
for FP in $FILE_PREFIXES
|
||||
do
|
||||
go tool cgo -godefs -srcdir . ${FP}.go > ${FP}_defs.go
|
||||
go tool cgo -godefs ${FP}.go > ${FP}_defs.go
|
||||
RM="${RM} ${FP}_defs.go"
|
||||
done
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
// Copyright 2016 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 common
|
||||
|
||||
var X int
|
||||
|
||||
func init() {
|
||||
X = 4
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
// Copyright 2016 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
|
||||
|
||||
// // No C code required.
|
||||
import "C"
|
||||
|
||||
// The common package imported here does not match the common package
|
||||
// imported by plugin1. A program that attempts to load plugin1 and
|
||||
// plugin-mismatch should produce an error.
|
||||
import "common"
|
||||
|
||||
func ReadCommonX() int {
|
||||
return common.X
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// Copyright 2016 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 common
|
||||
|
||||
var X int
|
||||
|
||||
func init() {
|
||||
X = 3
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
// Copyright 2016 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
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"plugin"
|
||||
"strings"
|
||||
|
||||
"common"
|
||||
)
|
||||
|
||||
func init() {
|
||||
common.X *= 5
|
||||
}
|
||||
|
||||
// testUnnamed tests that two plugins built with .go files passed on
|
||||
// the command line do not have overlapping symbols. That is,
|
||||
// unnamed1.so/FuncInt and unnamed2.so/FuncInt should be distinct functions.
|
||||
func testUnnamed() {
|
||||
p, err := plugin.Open("unnamed1.so")
|
||||
if err != nil {
|
||||
log.Fatalf(`plugin.Open("unnamed1.so"): %v`, err)
|
||||
}
|
||||
fn, err := p.Lookup("FuncInt")
|
||||
if err != nil {
|
||||
log.Fatalf(`unnamed1.so: Lookup("FuncInt") failed: %v`, err)
|
||||
}
|
||||
if got, want := fn.(func() int)(), 1; got != want {
|
||||
log.Fatalf("unnamed1.so: FuncInt()=%d, want %d", got, want)
|
||||
}
|
||||
|
||||
p, err = plugin.Open("unnamed2.so")
|
||||
if err != nil {
|
||||
log.Fatalf(`plugin.Open("unnamed2.so"): %v`, err)
|
||||
}
|
||||
fn, err = p.Lookup("FuncInt")
|
||||
if err != nil {
|
||||
log.Fatalf(`unnamed2.so: Lookup("FuncInt") failed: %v`, err)
|
||||
}
|
||||
if got, want := fn.(func() int)(), 2; got != want {
|
||||
log.Fatalf("unnamed2.so: FuncInt()=%d, want %d", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
if got, want := common.X, 3*5; got != want {
|
||||
log.Fatalf("before plugin load common.X=%d, want %d", got, want)
|
||||
}
|
||||
|
||||
p, err := plugin.Open("plugin1.so")
|
||||
if err != nil {
|
||||
log.Fatalf("plugin.Open failed: %v", err)
|
||||
}
|
||||
|
||||
const wantX = 3 * 5 * 7
|
||||
if got := common.X; got != wantX {
|
||||
log.Fatalf("after plugin load common.X=%d, want %d", got, wantX)
|
||||
}
|
||||
|
||||
seven, err := p.Lookup("Seven")
|
||||
if err != nil {
|
||||
log.Fatalf(`Lookup("Seven") failed: %v`, err)
|
||||
}
|
||||
if got, want := *seven.(*int), 7; got != want {
|
||||
log.Fatalf("plugin1.Seven=%d, want %d", got, want)
|
||||
}
|
||||
|
||||
readFunc, err := p.Lookup("ReadCommonX")
|
||||
if err != nil {
|
||||
log.Fatalf(`plugin1.Lookup("ReadCommonX") failed: %v`, err)
|
||||
}
|
||||
if got := readFunc.(func() int)(); got != wantX {
|
||||
log.Fatalf("plugin1.ReadCommonX()=%d, want %d", got, wantX)
|
||||
}
|
||||
|
||||
// sub/plugin1.so is a different plugin with the same name as
|
||||
// the already loaded plugin. It also depends on common. Test
|
||||
// that we can load the different plugin, it is actually
|
||||
// different, and that it sees the same common package.
|
||||
subpPath, err := filepath.Abs("sub/plugin1.so")
|
||||
if err != nil {
|
||||
log.Fatalf("filepath.Abs(%q) failed: %v", subpPath, err)
|
||||
}
|
||||
subp, err := plugin.Open(subpPath)
|
||||
if err != nil {
|
||||
log.Fatalf("plugin.Open(%q) failed: %v", subpPath, err)
|
||||
}
|
||||
|
||||
funcVar, err := subp.Lookup("FuncVar")
|
||||
if err != nil {
|
||||
log.Fatalf(`sub/plugin1.Lookup("FuncVar") failed: %v`, err)
|
||||
}
|
||||
called := false
|
||||
*funcVar.(*func()) = func() {
|
||||
called = true
|
||||
}
|
||||
|
||||
readFunc, err = subp.Lookup("ReadCommonX")
|
||||
if err != nil {
|
||||
log.Fatalf(`sub/plugin1.Lookup("ReadCommonX") failed: %v`, err)
|
||||
}
|
||||
if got := readFunc.(func() int)(); got != wantX {
|
||||
log.Fatalf("sub/plugin1.ReadCommonX()=%d, want %d", got, wantX)
|
||||
}
|
||||
if !called {
|
||||
log.Fatal("calling ReadCommonX did not call FuncVar")
|
||||
}
|
||||
|
||||
subf, err := subp.Lookup("F")
|
||||
if err != nil {
|
||||
log.Fatalf(`sub/plugin1.Lookup("F") failed: %v`, err)
|
||||
}
|
||||
if gotf := subf.(func() int)(); gotf != 17 {
|
||||
log.Fatalf(`sub/plugin1.F()=%d, want 17`, gotf)
|
||||
}
|
||||
f, err := p.Lookup("F")
|
||||
if err != nil {
|
||||
log.Fatalf(`plugin1.Lookup("F") failed: %v`, err)
|
||||
}
|
||||
if gotf := f.(func() int)(); gotf != 3 {
|
||||
log.Fatalf(`plugin1.F()=%d, want 17`, gotf)
|
||||
}
|
||||
|
||||
// plugin2 has no exported symbols, only an init function.
|
||||
if _, err := plugin.Open("plugin2.so"); err != nil {
|
||||
log.Fatalf("plugin.Open failed: %v", err)
|
||||
}
|
||||
if got, want := common.X, 2; got != want {
|
||||
log.Fatalf("after loading plugin2, common.X=%d, want %d", got, want)
|
||||
}
|
||||
|
||||
_, err = plugin.Open("plugin-mismatch.so")
|
||||
if err == nil {
|
||||
log.Fatal(`plugin.Open("plugin-mismatch.so"): should have failed`)
|
||||
}
|
||||
if s := err.Error(); !strings.Contains(s, "different version") {
|
||||
log.Fatalf(`plugin.Open("plugin-mismatch.so"): error does not mention "different version": %v`, s)
|
||||
}
|
||||
|
||||
testUnnamed()
|
||||
|
||||
fmt.Println("PASS")
|
||||
}
|
||||
@@ -1,46 +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
|
||||
|
||||
import (
|
||||
"iface_i"
|
||||
"log"
|
||||
"plugin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
a, err := plugin.Open("iface_a.so")
|
||||
if err != nil {
|
||||
log.Fatalf(`plugin.Open("iface_a.so"): %v`, err)
|
||||
}
|
||||
b, err := plugin.Open("iface_b.so")
|
||||
if err != nil {
|
||||
log.Fatalf(`plugin.Open("iface_b.so"): %v`, err)
|
||||
}
|
||||
|
||||
af, err := a.Lookup("F")
|
||||
if err != nil {
|
||||
log.Fatalf(`a.Lookup("F") failed: %v`, err)
|
||||
}
|
||||
bf, err := b.Lookup("F")
|
||||
if err != nil {
|
||||
log.Fatalf(`b.Lookup("F") failed: %v`, err)
|
||||
}
|
||||
if af.(func() interface{})() != bf.(func() interface{})() {
|
||||
panic("empty interfaces not equal")
|
||||
}
|
||||
|
||||
ag, err := a.Lookup("G")
|
||||
if err != nil {
|
||||
log.Fatalf(`a.Lookup("G") failed: %v`, err)
|
||||
}
|
||||
bg, err := b.Lookup("G")
|
||||
if err != nil {
|
||||
log.Fatalf(`b.Lookup("G") failed: %v`, err)
|
||||
}
|
||||
if ag.(func() iface_i.I)() != bg.(func() iface_i.I)() {
|
||||
panic("nonempty interfaces not equal")
|
||||
}
|
||||
}
|
||||
@@ -1,17 +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
|
||||
|
||||
import "iface_i"
|
||||
|
||||
//go:noinline
|
||||
func F() interface{} {
|
||||
return (*iface_i.T)(nil)
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func G() iface_i.I {
|
||||
return (*iface_i.T)(nil)
|
||||
}
|
||||
@@ -1,17 +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
|
||||
|
||||
import "iface_i"
|
||||
|
||||
//go:noinline
|
||||
func F() interface{} {
|
||||
return (*iface_i.T)(nil)
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func G() iface_i.I {
|
||||
return (*iface_i.T)(nil)
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user