mirror of
https://github.com/golang/go.git
synced 2026-01-30 15:42:04 +03:00
Compare commits
143 Commits
dev.inline
...
go1.20.9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68f9a6e2ad | ||
|
|
31d5b604ac | ||
|
|
83dce45959 | ||
|
|
08c544db98 | ||
|
|
071f03a8e5 | ||
|
|
d5b8518043 | ||
|
|
2070531d2f | ||
|
|
023b542edf | ||
|
|
612da32fb5 | ||
|
|
f0b8768dbc | ||
|
|
b463668275 | ||
|
|
974a3c9af7 | ||
|
|
14e3c7338d | ||
|
|
095cfba86b | ||
|
|
1a91bb94b0 | ||
|
|
ede3e278ae | ||
|
|
201f8b40dc | ||
|
|
adb775e309 | ||
|
|
659f2a2207 | ||
|
|
10d85fa0f6 | ||
|
|
bd3a1f24e7 | ||
|
|
6211a024b4 | ||
|
|
2c358ffe97 | ||
|
|
312920c00a | ||
|
|
4db13d762b | ||
|
|
08a58dd8b6 | ||
|
|
65092835c5 | ||
|
|
bca817594c | ||
|
|
b8e67d1ddd | ||
|
|
3db4f8146c | ||
|
|
6b45fb7b73 | ||
|
|
be30960e58 | ||
|
|
b59efe6c34 | ||
|
|
c32f1afb41 | ||
|
|
c7b145655b | ||
|
|
03063101a2 | ||
|
|
d51e322a3f | ||
|
|
49594244d3 | ||
|
|
4719048211 | ||
|
|
6c606fc191 | ||
|
|
63ad2b5811 | ||
|
|
95f377daad | ||
|
|
a7a48fad7e | ||
|
|
f5172dcd38 | ||
|
|
8b3acefcbe | ||
|
|
1008486a9f | ||
|
|
e827d41c0a | ||
|
|
c0ed873cd8 | ||
|
|
356a419e2f | ||
|
|
fa60c381ed | ||
|
|
36144ba429 | ||
|
|
5036ba77eb | ||
|
|
b249ec5655 | ||
|
|
4b95fc1e6c | ||
|
|
31a1e19a59 | ||
|
|
450c8021a5 | ||
|
|
22741120ee | ||
|
|
9270e3be8f | ||
|
|
600636e931 | ||
|
|
afbe101950 | ||
|
|
324c3ace2d | ||
|
|
337dd75343 | ||
|
|
4a28cad666 | ||
|
|
090590fdcc | ||
|
|
25b4f40625 | ||
|
|
484535e67b | ||
|
|
813a811d33 | ||
|
|
ee42d468f5 | ||
|
|
446493f5b8 | ||
|
|
0684cecad5 | ||
|
|
ecf7e00db8 | ||
|
|
1dbbac7d79 | ||
|
|
99001c460e | ||
|
|
dcc9bdf380 | ||
|
|
5c7c20e262 | ||
|
|
7c47a6b157 | ||
|
|
20374d1d75 | ||
|
|
e7c4b07ecf | ||
|
|
bf8c7c575c | ||
|
|
ec18f62df5 | ||
|
|
ea6b5a64dd | ||
|
|
3991f6c41c | ||
|
|
9a164d1c41 | ||
|
|
8dce4ca8df | ||
|
|
94c02a3cc4 | ||
|
|
65fa8a6931 | ||
|
|
b52a6963bf | ||
|
|
3ff6dbdf5b | ||
|
|
fa42da156a | ||
|
|
5c7cc468a8 | ||
|
|
b852f39511 | ||
|
|
4df95d5145 | ||
|
|
aee9a19c55 | ||
|
|
26eeaec89c | ||
|
|
9629fa1874 | ||
|
|
3243f93747 | ||
|
|
d2d0ee2049 | ||
|
|
230765a11a | ||
|
|
bdd86bda09 | ||
|
|
aef8a8cd42 | ||
|
|
ef793801f8 | ||
|
|
aaace6dda7 | ||
|
|
0f4483cfdc | ||
|
|
1362737f50 | ||
|
|
602eeaab38 | ||
|
|
ac556f35a2 | ||
|
|
1acd39cc92 | ||
|
|
7b398b1ff7 | ||
|
|
2d01f3695b | ||
|
|
965e9ba0fb | ||
|
|
85ded85b78 | ||
|
|
828b05cc64 | ||
|
|
202a1a5706 | ||
|
|
8e02cffd8e | ||
|
|
5286ac4ed8 | ||
|
|
53b43607d9 | ||
|
|
bdf07c2e16 | ||
|
|
3a04b6e12e | ||
|
|
00f5d3001a | ||
|
|
7628627cb2 | ||
|
|
1fa2deb1b1 | ||
|
|
a943fd0ccc | ||
|
|
fbba58a0a4 | ||
|
|
9987cb6cf3 | ||
|
|
90b06002c4 | ||
|
|
487be3f90b | ||
|
|
7302f83d87 | ||
|
|
de4748c47c | ||
|
|
52bd3b186b | ||
|
|
be7e4fee4b | ||
|
|
b68d699aa7 | ||
|
|
10124c2631 | ||
|
|
5adb0ca8e9 | ||
|
|
8b34676710 | ||
|
|
d7c6da8bac | ||
|
|
9eed826bf9 | ||
|
|
670ce9b8a8 | ||
|
|
b3160e8bce | ||
|
|
9efc2e7f95 | ||
|
|
32593a9192 | ||
|
|
eb598248ba | ||
|
|
9f02342144 | ||
|
|
0480336414 |
2
.github/SUPPORT.md
vendored
2
.github/SUPPORT.md
vendored
@@ -1,5 +1,5 @@
|
||||
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://go.dev/s/proposal-process).
|
||||
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:
|
||||
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -33,13 +33,13 @@ _testmain.go
|
||||
/src/cmd/cgo/zdefaultcc.go
|
||||
/src/cmd/dist/dist
|
||||
/src/cmd/go/internal/cfg/zdefaultcc.go
|
||||
/src/cmd/go/internal/cfg/zosarch.go
|
||||
/src/cmd/internal/objabi/zbootstrap.go
|
||||
/src/go/build/zcgo.go
|
||||
/src/go/doc/headscan
|
||||
/src/internal/buildcfg/zbootstrap.go
|
||||
/src/runtime/internal/sys/zversion.go
|
||||
/src/unicode/maketables
|
||||
/src/time/tzdata/zzipdata.go
|
||||
/test.out
|
||||
/test/garbage/*.out
|
||||
/test/pass.out
|
||||
|
||||
@@ -24,7 +24,7 @@ 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://go.dev/s/proposal-process).
|
||||
For change proposals, see [Proposing Changes To Go](https://github.com/golang/proposal/).
|
||||
|
||||
## Contributing code
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
pkg crypto/tls, type ConnectionState struct, TLSUnique //deprecated
|
||||
pkg debug/elf, const R_PPC64_SECTOFF_LO_DS = 61
|
||||
pkg encoding/json, method (*RawMessage) MarshalJSON() ([]uint8, error)
|
||||
pkg math, const MaxFloat64 = 1.79769e+308 // 179769313486231570814527423731704356798100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
@@ -502,7 +501,6 @@ pkg text/template/parse, type Node interface { Copy, String, Type }
|
||||
pkg unicode, const Version = "10.0.0"
|
||||
pkg unicode, const Version = "11.0.0"
|
||||
pkg unicode, const Version = "12.0.0"
|
||||
pkg unicode, const Version = "13.0.0"
|
||||
pkg unicode, const Version = "6.2.0"
|
||||
pkg unicode, const Version = "6.3.0"
|
||||
pkg unicode, const Version = "7.0.0"
|
||||
@@ -576,25 +574,3 @@ pkg syscall (freebsd-arm-cgo), const SYS_MKNODAT = 498
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_STAT = 188
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_STAT ideal-int
|
||||
pkg syscall (freebsd-arm-cgo), const SYS_STATFS = 396
|
||||
pkg syscall (freebsd-arm64), const SYS_FSTAT = 189
|
||||
pkg syscall (freebsd-arm64), const SYS_FSTATAT = 493
|
||||
pkg syscall (freebsd-arm64), const SYS_FSTATFS = 397
|
||||
pkg syscall (freebsd-arm64), const SYS_GETDIRENTRIES = 196
|
||||
pkg syscall (freebsd-arm64), const SYS_GETFSSTAT = 395
|
||||
pkg syscall (freebsd-arm64), const SYS_LSTAT = 190
|
||||
pkg syscall (freebsd-arm64), const SYS_LSTAT ideal-int
|
||||
pkg syscall (freebsd-arm64), const SYS_MKNODAT = 498
|
||||
pkg syscall (freebsd-arm64), const SYS_STAT = 188
|
||||
pkg syscall (freebsd-arm64), const SYS_STAT ideal-int
|
||||
pkg syscall (freebsd-arm64), const SYS_STATFS = 396
|
||||
pkg syscall (freebsd-arm64-cgo), const SYS_FSTAT = 189
|
||||
pkg syscall (freebsd-arm64-cgo), const SYS_FSTATAT = 493
|
||||
pkg syscall (freebsd-arm64-cgo), const SYS_FSTATFS = 397
|
||||
pkg syscall (freebsd-arm64-cgo), const SYS_GETDIRENTRIES = 196
|
||||
pkg syscall (freebsd-arm64-cgo), const SYS_GETFSSTAT = 395
|
||||
pkg syscall (freebsd-arm64-cgo), const SYS_LSTAT = 190
|
||||
pkg syscall (freebsd-arm64-cgo), const SYS_LSTAT ideal-int
|
||||
pkg syscall (freebsd-arm64-cgo), const SYS_MKNODAT = 498
|
||||
pkg syscall (freebsd-arm64-cgo), const SYS_STAT = 188
|
||||
pkg syscall (freebsd-arm64-cgo), const SYS_STAT ideal-int
|
||||
pkg syscall (freebsd-arm64-cgo), const SYS_STATFS = 396
|
||||
|
||||
8717
api/go1.14.txt
8717
api/go1.14.txt
File diff suppressed because it is too large
Load Diff
@@ -93,12 +93,6 @@ pkg math (freebsd-arm), const MinInt = -2147483648
|
||||
pkg math (freebsd-arm-cgo), const MaxInt = 2147483647
|
||||
pkg math (freebsd-arm-cgo), const MaxUint = 4294967295
|
||||
pkg math (freebsd-arm-cgo), const MinInt = -2147483648
|
||||
pkg math (freebsd-arm64), const MaxInt = 9223372036854775807
|
||||
pkg math (freebsd-arm64), const MaxUint = 18446744073709551615
|
||||
pkg math (freebsd-arm64), const MinInt = -9223372036854775808
|
||||
pkg math (freebsd-arm64-cgo), const MaxInt = 9223372036854775807
|
||||
pkg math (freebsd-arm64-cgo), const MaxUint = 18446744073709551615
|
||||
pkg math (freebsd-arm64-cgo), const MinInt = -9223372036854775808
|
||||
pkg math (linux-386), const MaxInt = 2147483647
|
||||
pkg math (linux-386), const MaxUint = 4294967295
|
||||
pkg math (linux-386), const MinInt = -2147483648
|
||||
@@ -195,10 +189,6 @@ pkg runtime/cgo (freebsd-arm-cgo), func NewHandle(interface{}) Handle
|
||||
pkg runtime/cgo (freebsd-arm-cgo), method (Handle) Delete()
|
||||
pkg runtime/cgo (freebsd-arm-cgo), method (Handle) Value() interface{}
|
||||
pkg runtime/cgo (freebsd-arm-cgo), type Handle uintptr
|
||||
pkg runtime/cgo (freebsd-arm64-cgo), func NewHandle(interface{}) Handle
|
||||
pkg runtime/cgo (freebsd-arm64-cgo), method (Handle) Delete()
|
||||
pkg runtime/cgo (freebsd-arm64-cgo), method (Handle) Value() interface{}
|
||||
pkg runtime/cgo (freebsd-arm64-cgo), type Handle uintptr
|
||||
pkg runtime/cgo (linux-386-cgo), func NewHandle(interface{}) Handle
|
||||
pkg runtime/cgo (linux-386-cgo), method (Handle) Delete()
|
||||
pkg runtime/cgo (linux-386-cgo), method (Handle) Value() interface{}
|
||||
|
||||
@@ -189,8 +189,6 @@ pkg syscall (freebsd-amd64), type SysProcAttr struct, Pdeathsig Signal
|
||||
pkg syscall (freebsd-amd64-cgo), type SysProcAttr struct, Pdeathsig Signal
|
||||
pkg syscall (freebsd-arm), type SysProcAttr struct, Pdeathsig Signal
|
||||
pkg syscall (freebsd-arm-cgo), type SysProcAttr struct, Pdeathsig Signal
|
||||
pkg syscall (freebsd-arm64), type SysProcAttr struct, Pdeathsig Signal
|
||||
pkg syscall (freebsd-arm64-cgo), type SysProcAttr struct, Pdeathsig Signal
|
||||
pkg syscall (windows-386), func Syscall //deprecated
|
||||
pkg syscall (windows-386), func Syscall12 //deprecated
|
||||
pkg syscall (windows-386), func Syscall15 //deprecated
|
||||
|
||||
8737
api/go1.20.txt
8737
api/go1.20.txt
File diff suppressed because it is too large
Load Diff
421
api/go1.21.txt
421
api/go1.21.txt
@@ -1,421 +0,0 @@
|
||||
pkg bytes, func ContainsFunc([]uint8, func(int32) bool) bool #54386
|
||||
pkg bytes, method (*Buffer) AvailableBuffer() []uint8 #53685
|
||||
pkg bytes, method (*Buffer) Available() int #53685
|
||||
pkg cmp, func Compare[$0 Ordered]($0, $0) int #59488
|
||||
pkg cmp, func Less[$0 Ordered]($0, $0) bool #59488
|
||||
pkg cmp, type Ordered interface {} #59488
|
||||
pkg context, func AfterFunc(Context, func()) func() bool #57928
|
||||
pkg context, func WithDeadlineCause(Context, time.Time, error) (Context, CancelFunc) #56661
|
||||
pkg context, func WithoutCancel(Context) Context #40221
|
||||
pkg context, func WithTimeoutCause(Context, time.Duration, error) (Context, CancelFunc) #56661
|
||||
pkg crypto/elliptic, func GenerateKey //deprecated #52221
|
||||
pkg crypto/elliptic, func Marshal //deprecated #52221
|
||||
pkg crypto/elliptic, func Unmarshal //deprecated #52221
|
||||
pkg crypto/elliptic, method (*CurveParams) Add //deprecated #34648
|
||||
pkg crypto/elliptic, method (*CurveParams) Double //deprecated #34648
|
||||
pkg crypto/elliptic, method (*CurveParams) IsOnCurve //deprecated #34648
|
||||
pkg crypto/elliptic, method (*CurveParams) ScalarBaseMult //deprecated #34648
|
||||
pkg crypto/elliptic, method (*CurveParams) ScalarMult //deprecated #34648
|
||||
pkg crypto/elliptic, type Curve interface, Add //deprecated #52221
|
||||
pkg crypto/elliptic, type Curve interface, Double //deprecated #52221
|
||||
pkg crypto/elliptic, type Curve interface, IsOnCurve //deprecated #52221
|
||||
pkg crypto/elliptic, type Curve interface, ScalarBaseMult //deprecated #52221
|
||||
pkg crypto/elliptic, type Curve interface, ScalarMult //deprecated #52221
|
||||
pkg crypto/rsa, func GenerateMultiPrimeKey //deprecated #56921
|
||||
pkg crypto/rsa, type PrecomputedValues struct, CRTValues //deprecated #56921
|
||||
pkg crypto/tls, const QUICEncryptionLevelApplication = 3 #44886
|
||||
pkg crypto/tls, const QUICEncryptionLevelApplication QUICEncryptionLevel #44886
|
||||
pkg crypto/tls, const QUICEncryptionLevelEarly = 1 #60107
|
||||
pkg crypto/tls, const QUICEncryptionLevelEarly QUICEncryptionLevel #60107
|
||||
pkg crypto/tls, const QUICEncryptionLevelHandshake = 2 #44886
|
||||
pkg crypto/tls, const QUICEncryptionLevelHandshake QUICEncryptionLevel #44886
|
||||
pkg crypto/tls, const QUICEncryptionLevelInitial = 0 #44886
|
||||
pkg crypto/tls, const QUICEncryptionLevelInitial QUICEncryptionLevel #44886
|
||||
pkg crypto/tls, const QUICHandshakeDone = 7 #44886
|
||||
pkg crypto/tls, const QUICHandshakeDone QUICEventKind #44886
|
||||
pkg crypto/tls, const QUICNoEvent = 0 #44886
|
||||
pkg crypto/tls, const QUICNoEvent QUICEventKind #44886
|
||||
pkg crypto/tls, const QUICRejectedEarlyData = 6 #60107
|
||||
pkg crypto/tls, const QUICRejectedEarlyData QUICEventKind #60107
|
||||
pkg crypto/tls, const QUICSetReadSecret = 1 #44886
|
||||
pkg crypto/tls, const QUICSetReadSecret QUICEventKind #44886
|
||||
pkg crypto/tls, const QUICSetWriteSecret = 2 #44886
|
||||
pkg crypto/tls, const QUICSetWriteSecret QUICEventKind #44886
|
||||
pkg crypto/tls, const QUICTransportParameters = 4 #44886
|
||||
pkg crypto/tls, const QUICTransportParameters QUICEventKind #44886
|
||||
pkg crypto/tls, const QUICTransportParametersRequired = 5 #44886
|
||||
pkg crypto/tls, const QUICTransportParametersRequired QUICEventKind #44886
|
||||
pkg crypto/tls, const QUICWriteData = 3 #44886
|
||||
pkg crypto/tls, const QUICWriteData QUICEventKind #44886
|
||||
pkg crypto/tls, func NewResumptionState([]uint8, *SessionState) (*ClientSessionState, error) #60105
|
||||
pkg crypto/tls, func ParseSessionState([]uint8) (*SessionState, error) #60105
|
||||
pkg crypto/tls, func QUICClient(*QUICConfig) *QUICConn #44886
|
||||
pkg crypto/tls, func QUICServer(*QUICConfig) *QUICConn #44886
|
||||
pkg crypto/tls, func VersionName(uint16) string #46308
|
||||
pkg crypto/tls, method (AlertError) Error() string #44886
|
||||
pkg crypto/tls, method (*ClientSessionState) ResumptionState() ([]uint8, *SessionState, error) #60105
|
||||
pkg crypto/tls, method (*Config) DecryptTicket([]uint8, ConnectionState) (*SessionState, error) #60105
|
||||
pkg crypto/tls, method (*Config) EncryptTicket(ConnectionState, *SessionState) ([]uint8, error) #60105
|
||||
pkg crypto/tls, method (*QUICConn) Close() error #44886
|
||||
pkg crypto/tls, method (*QUICConn) ConnectionState() ConnectionState #44886
|
||||
pkg crypto/tls, method (*QUICConn) HandleData(QUICEncryptionLevel, []uint8) error #44886
|
||||
pkg crypto/tls, method (*QUICConn) NextEvent() QUICEvent #44886
|
||||
pkg crypto/tls, method (*QUICConn) SendSessionTicket(bool) error #60107
|
||||
pkg crypto/tls, method (*QUICConn) SetTransportParameters([]uint8) #44886
|
||||
pkg crypto/tls, method (*QUICConn) Start(context.Context) error #44886
|
||||
pkg crypto/tls, method (QUICEncryptionLevel) String() string #44886
|
||||
pkg crypto/tls, method (*SessionState) Bytes() ([]uint8, error) #60105
|
||||
pkg crypto/tls, type AlertError uint8 #44886
|
||||
pkg crypto/tls, type Config struct, UnwrapSession func([]uint8, ConnectionState) (*SessionState, error) #60105
|
||||
pkg crypto/tls, type Config struct, WrapSession func(ConnectionState, *SessionState) ([]uint8, error) #60105
|
||||
pkg crypto/tls, type QUICConfig struct #44886
|
||||
pkg crypto/tls, type QUICConfig struct, TLSConfig *Config #44886
|
||||
pkg crypto/tls, type QUICConn struct #44886
|
||||
pkg crypto/tls, type QUICEncryptionLevel int #44886
|
||||
pkg crypto/tls, type QUICEventKind int #44886
|
||||
pkg crypto/tls, type QUICEvent struct #44886
|
||||
pkg crypto/tls, type QUICEvent struct, Data []uint8 #44886
|
||||
pkg crypto/tls, type QUICEvent struct, Kind QUICEventKind #44886
|
||||
pkg crypto/tls, type QUICEvent struct, Level QUICEncryptionLevel #44886
|
||||
pkg crypto/tls, type QUICEvent struct, Suite uint16 #44886
|
||||
pkg crypto/tls, type SessionState struct #60105
|
||||
pkg crypto/tls, type SessionState struct, EarlyData bool #60107
|
||||
pkg crypto/tls, type SessionState struct, Extra [][]uint8 #60539
|
||||
pkg crypto/x509, type RevocationListEntry struct #53573
|
||||
pkg crypto/x509, type RevocationListEntry struct, Extensions []pkix.Extension #53573
|
||||
pkg crypto/x509, type RevocationListEntry struct, ExtraExtensions []pkix.Extension #53573
|
||||
pkg crypto/x509, type RevocationListEntry struct, Raw []uint8 #53573
|
||||
pkg crypto/x509, type RevocationListEntry struct, ReasonCode int #53573
|
||||
pkg crypto/x509, type RevocationListEntry struct, RevocationTime time.Time #53573
|
||||
pkg crypto/x509, type RevocationListEntry struct, SerialNumber *big.Int #53573
|
||||
pkg crypto/x509, type RevocationList struct, RevokedCertificateEntries []RevocationListEntry #53573
|
||||
pkg crypto/x509, type RevocationList struct, RevokedCertificates //deprecated #53573
|
||||
pkg debug/elf, const COMPRESS_ZSTD = 2 #55107
|
||||
pkg debug/elf, const COMPRESS_ZSTD CompressionType #55107
|
||||
pkg debug/elf, const DF_1_CONFALT = 8192 #56887
|
||||
pkg debug/elf, const DF_1_CONFALT DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_DIRECT = 256 #56887
|
||||
pkg debug/elf, const DF_1_DIRECT DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_DISPRELDNE = 32768 #56887
|
||||
pkg debug/elf, const DF_1_DISPRELDNE DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_DISPRELPND = 65536 #56887
|
||||
pkg debug/elf, const DF_1_DISPRELPND DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_EDITED = 2097152 #56887
|
||||
pkg debug/elf, const DF_1_EDITED DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_ENDFILTEE = 16384 #56887
|
||||
pkg debug/elf, const DF_1_ENDFILTEE DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_GLOBAL = 2 #56887
|
||||
pkg debug/elf, const DF_1_GLOBAL DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_GLOBAUDIT = 16777216 #56887
|
||||
pkg debug/elf, const DF_1_GLOBAUDIT DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_GROUP = 4 #56887
|
||||
pkg debug/elf, const DF_1_GROUP DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_IGNMULDEF = 262144 #56887
|
||||
pkg debug/elf, const DF_1_IGNMULDEF DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_INITFIRST = 32 #56887
|
||||
pkg debug/elf, const DF_1_INITFIRST DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_INTERPOSE = 1024 #56887
|
||||
pkg debug/elf, const DF_1_INTERPOSE DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_KMOD = 268435456 #56887
|
||||
pkg debug/elf, const DF_1_KMOD DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_LOADFLTR = 16 #56887
|
||||
pkg debug/elf, const DF_1_LOADFLTR DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_NOCOMMON = 1073741824 #56887
|
||||
pkg debug/elf, const DF_1_NOCOMMON DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_NODEFLIB = 2048 #56887
|
||||
pkg debug/elf, const DF_1_NODEFLIB DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_NODELETE = 8 #56887
|
||||
pkg debug/elf, const DF_1_NODELETE DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_NODIRECT = 131072 #56887
|
||||
pkg debug/elf, const DF_1_NODIRECT DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_NODUMP = 4096 #56887
|
||||
pkg debug/elf, const DF_1_NODUMP DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_NOHDR = 1048576 #56887
|
||||
pkg debug/elf, const DF_1_NOHDR DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_NOKSYMS = 524288 #56887
|
||||
pkg debug/elf, const DF_1_NOKSYMS DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_NOOPEN = 64 #56887
|
||||
pkg debug/elf, const DF_1_NOOPEN DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_NORELOC = 4194304 #56887
|
||||
pkg debug/elf, const DF_1_NORELOC DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_NOW = 1 #56887
|
||||
pkg debug/elf, const DF_1_NOW DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_ORIGIN = 128 #56887
|
||||
pkg debug/elf, const DF_1_ORIGIN DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_PIE = 134217728 #56887
|
||||
pkg debug/elf, const DF_1_PIE DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_SINGLETON = 33554432 #56887
|
||||
pkg debug/elf, const DF_1_SINGLETON DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_STUB = 67108864 #56887
|
||||
pkg debug/elf, const DF_1_STUB DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_SYMINTPOSE = 8388608 #56887
|
||||
pkg debug/elf, const DF_1_SYMINTPOSE DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_TRANS = 512 #56887
|
||||
pkg debug/elf, const DF_1_TRANS DynFlag1 #56887
|
||||
pkg debug/elf, const DF_1_WEAKFILTER = 536870912 #56887
|
||||
pkg debug/elf, const DF_1_WEAKFILTER DynFlag1 #56887
|
||||
pkg debug/elf, const R_PPC64_REL24_P9NOTOC = 124 #60348
|
||||
pkg debug/elf, const R_PPC64_REL24_P9NOTOC R_PPC64 #60348
|
||||
pkg debug/elf, method (DynFlag1) GoString() string #56887
|
||||
pkg debug/elf, method (DynFlag1) String() string #56887
|
||||
pkg debug/elf, method (*File) DynValue(DynTag) ([]uint64, error) #56892
|
||||
pkg debug/elf, type DynFlag1 uint32 #56887
|
||||
pkg encoding/binary, var NativeEndian nativeEndian #57237
|
||||
pkg errors, var ErrUnsupported error #41198
|
||||
pkg flag, func BoolFunc(string, string, func(string) error) #53747
|
||||
pkg flag, method (*FlagSet) BoolFunc(string, string, func(string) error) #53747
|
||||
pkg go/ast, func IsGenerated(*File) bool #28089
|
||||
pkg go/ast, type File struct, GoVersion string #59033
|
||||
pkg go/build/constraint, func GoVersion(Expr) string #59033
|
||||
pkg go/build, type Directive struct #56986
|
||||
pkg go/build, type Directive struct, Pos token.Position #56986
|
||||
pkg go/build, type Directive struct, Text string #56986
|
||||
pkg go/build, type Package struct, Directives []Directive #56986
|
||||
pkg go/build, type Package struct, TestDirectives []Directive #56986
|
||||
pkg go/build, type Package struct, XTestDirectives []Directive #56986
|
||||
pkg go/token, method (*File) Lines() []int #57708
|
||||
pkg go/types, method (*Package) GoVersion() string #61175
|
||||
pkg html/template, const ErrJSTemplate = 12 #59584
|
||||
pkg html/template, const ErrJSTemplate ErrorCode #59584
|
||||
pkg io/fs, func FormatDirEntry(DirEntry) string #54451
|
||||
pkg io/fs, func FormatFileInfo(FileInfo) string #54451
|
||||
pkg log/slog, const KindAny = 0 #56345
|
||||
pkg log/slog, const KindAny Kind #56345
|
||||
pkg log/slog, const KindBool = 1 #56345
|
||||
pkg log/slog, const KindBool Kind #56345
|
||||
pkg log/slog, const KindDuration = 2 #56345
|
||||
pkg log/slog, const KindDuration Kind #56345
|
||||
pkg log/slog, const KindFloat64 = 3 #56345
|
||||
pkg log/slog, const KindFloat64 Kind #56345
|
||||
pkg log/slog, const KindGroup = 8 #56345
|
||||
pkg log/slog, const KindGroup Kind #56345
|
||||
pkg log/slog, const KindInt64 = 4 #56345
|
||||
pkg log/slog, const KindInt64 Kind #56345
|
||||
pkg log/slog, const KindLogValuer = 9 #56345
|
||||
pkg log/slog, const KindLogValuer Kind #56345
|
||||
pkg log/slog, const KindString = 5 #56345
|
||||
pkg log/slog, const KindString Kind #56345
|
||||
pkg log/slog, const KindTime = 6 #56345
|
||||
pkg log/slog, const KindTime Kind #56345
|
||||
pkg log/slog, const KindUint64 = 7 #56345
|
||||
pkg log/slog, const KindUint64 Kind #56345
|
||||
pkg log/slog, const LevelDebug = -4 #56345
|
||||
pkg log/slog, const LevelDebug Level #56345
|
||||
pkg log/slog, const LevelError = 8 #56345
|
||||
pkg log/slog, const LevelError Level #56345
|
||||
pkg log/slog, const LevelInfo = 0 #56345
|
||||
pkg log/slog, const LevelInfo Level #56345
|
||||
pkg log/slog, const LevelKey ideal-string #56345
|
||||
pkg log/slog, const LevelKey = "level" #56345
|
||||
pkg log/slog, const LevelWarn = 4 #56345
|
||||
pkg log/slog, const LevelWarn Level #56345
|
||||
pkg log/slog, const MessageKey ideal-string #56345
|
||||
pkg log/slog, const MessageKey = "msg" #56345
|
||||
pkg log/slog, const SourceKey ideal-string #56345
|
||||
pkg log/slog, const SourceKey = "source" #56345
|
||||
pkg log/slog, const TimeKey ideal-string #56345
|
||||
pkg log/slog, const TimeKey = "time" #56345
|
||||
pkg log/slog, func Any(string, interface{}) Attr #56345
|
||||
pkg log/slog, func AnyValue(interface{}) Value #56345
|
||||
pkg log/slog, func Bool(string, bool) Attr #56345
|
||||
pkg log/slog, func BoolValue(bool) Value #56345
|
||||
pkg log/slog, func DebugCtx(context.Context, string, ...interface{}) #56345
|
||||
pkg log/slog, func Debug(string, ...interface{}) #56345
|
||||
pkg log/slog, func Default() *Logger #56345
|
||||
pkg log/slog, func Duration(string, time.Duration) Attr #56345
|
||||
pkg log/slog, func DurationValue(time.Duration) Value #56345
|
||||
pkg log/slog, func ErrorCtx(context.Context, string, ...interface{}) #56345
|
||||
pkg log/slog, func Error(string, ...interface{}) #56345
|
||||
pkg log/slog, func Float64(string, float64) Attr #56345
|
||||
pkg log/slog, func Float64Value(float64) Value #56345
|
||||
pkg log/slog, func Group(string, ...interface{}) Attr #59204
|
||||
pkg log/slog, func GroupValue(...Attr) Value #56345
|
||||
pkg log/slog, func InfoCtx(context.Context, string, ...interface{}) #56345
|
||||
pkg log/slog, func Info(string, ...interface{}) #56345
|
||||
pkg log/slog, func Int64(string, int64) Attr #56345
|
||||
pkg log/slog, func Int64Value(int64) Value #56345
|
||||
pkg log/slog, func Int(string, int) Attr #56345
|
||||
pkg log/slog, func IntValue(int) Value #56345
|
||||
pkg log/slog, func LogAttrs(context.Context, Level, string, ...Attr) #56345
|
||||
pkg log/slog, func Log(context.Context, Level, string, ...interface{}) #56345
|
||||
pkg log/slog, func New(Handler) *Logger #56345
|
||||
pkg log/slog, func NewJSONHandler(io.Writer, *HandlerOptions) *JSONHandler #59339
|
||||
pkg log/slog, func NewLogLogger(Handler, Level) *log.Logger #56345
|
||||
pkg log/slog, func NewRecord(time.Time, Level, string, uintptr) Record #56345
|
||||
pkg log/slog, func NewTextHandler(io.Writer, *HandlerOptions) *TextHandler #59339
|
||||
pkg log/slog, func SetDefault(*Logger) #56345
|
||||
pkg log/slog, func String(string, string) Attr #56345
|
||||
pkg log/slog, func StringValue(string) Value #56345
|
||||
pkg log/slog, func Time(string, time.Time) Attr #56345
|
||||
pkg log/slog, func TimeValue(time.Time) Value #56345
|
||||
pkg log/slog, func Uint64(string, uint64) Attr #56345
|
||||
pkg log/slog, func Uint64Value(uint64) Value #56345
|
||||
pkg log/slog, func WarnCtx(context.Context, string, ...interface{}) #56345
|
||||
pkg log/slog, func Warn(string, ...interface{}) #56345
|
||||
pkg log/slog, func With(...interface{}) *Logger #56345
|
||||
pkg log/slog, method (Attr) Equal(Attr) bool #56345
|
||||
pkg log/slog, method (Attr) String() string #56345
|
||||
pkg log/slog, method (*JSONHandler) Enabled(context.Context, Level) bool #56345
|
||||
pkg log/slog, method (*JSONHandler) Handle(context.Context, Record) error #56345
|
||||
pkg log/slog, method (*JSONHandler) WithAttrs([]Attr) Handler #56345
|
||||
pkg log/slog, method (*JSONHandler) WithGroup(string) Handler #56345
|
||||
pkg log/slog, method (Kind) String() string #56345
|
||||
pkg log/slog, method (Level) Level() Level #56345
|
||||
pkg log/slog, method (Level) MarshalJSON() ([]uint8, error) #56345
|
||||
pkg log/slog, method (Level) MarshalText() ([]uint8, error) #56345
|
||||
pkg log/slog, method (Level) String() string #56345
|
||||
pkg log/slog, method (*Level) UnmarshalJSON([]uint8) error #56345
|
||||
pkg log/slog, method (*Level) UnmarshalText([]uint8) error #56345
|
||||
pkg log/slog, method (*LevelVar) Level() Level #56345
|
||||
pkg log/slog, method (*LevelVar) MarshalText() ([]uint8, error) #56345
|
||||
pkg log/slog, method (*LevelVar) Set(Level) #56345
|
||||
pkg log/slog, method (*LevelVar) String() string #56345
|
||||
pkg log/slog, method (*LevelVar) UnmarshalText([]uint8) error #56345
|
||||
pkg log/slog, method (*Logger) DebugCtx(context.Context, string, ...interface{}) #56345
|
||||
pkg log/slog, method (*Logger) Debug(string, ...interface{}) #56345
|
||||
pkg log/slog, method (*Logger) Enabled(context.Context, Level) bool #56345
|
||||
pkg log/slog, method (*Logger) ErrorCtx(context.Context, string, ...interface{}) #56345
|
||||
pkg log/slog, method (*Logger) Error(string, ...interface{}) #56345
|
||||
pkg log/slog, method (*Logger) Handler() Handler #56345
|
||||
pkg log/slog, method (*Logger) InfoCtx(context.Context, string, ...interface{}) #56345
|
||||
pkg log/slog, method (*Logger) Info(string, ...interface{}) #56345
|
||||
pkg log/slog, method (*Logger) LogAttrs(context.Context, Level, string, ...Attr) #56345
|
||||
pkg log/slog, method (*Logger) Log(context.Context, Level, string, ...interface{}) #56345
|
||||
pkg log/slog, method (*Logger) WarnCtx(context.Context, string, ...interface{}) #56345
|
||||
pkg log/slog, method (*Logger) Warn(string, ...interface{}) #56345
|
||||
pkg log/slog, method (*Logger) WithGroup(string) *Logger #56345
|
||||
pkg log/slog, method (*Logger) With(...interface{}) *Logger #56345
|
||||
pkg log/slog, method (*Record) AddAttrs(...Attr) #56345
|
||||
pkg log/slog, method (*Record) Add(...interface{}) #56345
|
||||
pkg log/slog, method (Record) Attrs(func(Attr) bool) #59060
|
||||
pkg log/slog, method (Record) Clone() Record #56345
|
||||
pkg log/slog, method (Record) NumAttrs() int #56345
|
||||
pkg log/slog, method (*TextHandler) Enabled(context.Context, Level) bool #56345
|
||||
pkg log/slog, method (*TextHandler) Handle(context.Context, Record) error #56345
|
||||
pkg log/slog, method (*TextHandler) WithAttrs([]Attr) Handler #56345
|
||||
pkg log/slog, method (*TextHandler) WithGroup(string) Handler #56345
|
||||
pkg log/slog, method (Value) Any() interface{} #56345
|
||||
pkg log/slog, method (Value) Bool() bool #56345
|
||||
pkg log/slog, method (Value) Duration() time.Duration #56345
|
||||
pkg log/slog, method (Value) Equal(Value) bool #56345
|
||||
pkg log/slog, method (Value) Float64() float64 #56345
|
||||
pkg log/slog, method (Value) Group() []Attr #56345
|
||||
pkg log/slog, method (Value) Int64() int64 #56345
|
||||
pkg log/slog, method (Value) Kind() Kind #56345
|
||||
pkg log/slog, method (Value) LogValuer() LogValuer #56345
|
||||
pkg log/slog, method (Value) Resolve() Value #56345
|
||||
pkg log/slog, method (Value) String() string #56345
|
||||
pkg log/slog, method (Value) Time() time.Time #56345
|
||||
pkg log/slog, method (Value) Uint64() uint64 #56345
|
||||
pkg log/slog, type Attr struct #56345
|
||||
pkg log/slog, type Attr struct, Key string #56345
|
||||
pkg log/slog, type Attr struct, Value Value #56345
|
||||
pkg log/slog, type Handler interface, Enabled(context.Context, Level) bool #56345
|
||||
pkg log/slog, type Handler interface { Enabled, Handle, WithAttrs, WithGroup } #56345
|
||||
pkg log/slog, type Handler interface, Handle(context.Context, Record) error #56345
|
||||
pkg log/slog, type Handler interface, WithAttrs([]Attr) Handler #56345
|
||||
pkg log/slog, type Handler interface, WithGroup(string) Handler #56345
|
||||
pkg log/slog, type HandlerOptions struct #56345
|
||||
pkg log/slog, type HandlerOptions struct, AddSource bool #56345
|
||||
pkg log/slog, type HandlerOptions struct, Level Leveler #56345
|
||||
pkg log/slog, type HandlerOptions struct, ReplaceAttr func([]string, Attr) Attr #56345
|
||||
pkg log/slog, type JSONHandler struct #56345
|
||||
pkg log/slog, type Kind int #56345
|
||||
pkg log/slog, type Leveler interface { Level } #56345
|
||||
pkg log/slog, type Leveler interface, Level() Level #56345
|
||||
pkg log/slog, type Level int #56345
|
||||
pkg log/slog, type LevelVar struct #56345
|
||||
pkg log/slog, type Logger struct #56345
|
||||
pkg log/slog, type LogValuer interface { LogValue } #56345
|
||||
pkg log/slog, type LogValuer interface, LogValue() Value #56345
|
||||
pkg log/slog, type Record struct #56345
|
||||
pkg log/slog, type Record struct, Level Level #56345
|
||||
pkg log/slog, type Record struct, Message string #56345
|
||||
pkg log/slog, type Record struct, PC uintptr #56345
|
||||
pkg log/slog, type Record struct, Time time.Time #56345
|
||||
pkg log/slog, type Source struct #59280
|
||||
pkg log/slog, type Source struct, File string #59280
|
||||
pkg log/slog, type Source struct, Function string #59280
|
||||
pkg log/slog, type Source struct, Line int #59280
|
||||
pkg log/slog, type TextHandler struct #56345
|
||||
pkg log/slog, type Value struct #56345
|
||||
pkg maps, func Clone[$0 interface{ ~map[$1]$2 }, $1 comparable, $2 interface{}]($0) $0 #57436
|
||||
pkg maps, func Copy[$0 interface{ ~map[$2]$3 }, $1 interface{ ~map[$2]$3 }, $2 comparable, $3 interface{}]($0, $1) #57436
|
||||
pkg maps, func DeleteFunc[$0 interface{ ~map[$1]$2 }, $1 comparable, $2 interface{}]($0, func($1, $2) bool) #57436
|
||||
pkg maps, func Equal[$0 interface{ ~map[$2]$3 }, $1 interface{ ~map[$2]$3 }, $2 comparable, $3 comparable]($0, $1) bool #57436
|
||||
pkg maps, func EqualFunc[$0 interface{ ~map[$2]$3 }, $1 interface{ ~map[$2]$4 }, $2 comparable, $3 interface{}, $4 interface{}]($0, $1, func($3, $4) bool) bool #57436
|
||||
pkg maps, func Keys[$0 interface{ ~map[$1]$2 }, $1 comparable, $2 interface{}]($0) []$1 #57436
|
||||
pkg maps, func Values[$0 interface{ ~map[$1]$2 }, $1 comparable, $2 interface{}]($0) []$2 #57436
|
||||
pkg math/big, method (*Int) Float64() (float64, Accuracy) #56984
|
||||
pkg net/http, method (*ProtocolError) Is(error) bool #41198
|
||||
pkg net/http, method (*ResponseController) EnableFullDuplex() error #57786
|
||||
pkg net/http, var ErrSchemeMismatch error #44855
|
||||
pkg net, method (*Dialer) MultipathTCP() bool #56539
|
||||
pkg net, method (*Dialer) SetMultipathTCP(bool) #56539
|
||||
pkg net, method (*ListenConfig) MultipathTCP() bool #56539
|
||||
pkg net, method (*ListenConfig) SetMultipathTCP(bool) #56539
|
||||
pkg net, method (*TCPConn) MultipathTCP() (bool, error) #59166
|
||||
pkg reflect, method (Value) Clear() #55002
|
||||
pkg reflect, type SliceHeader //deprecated #56906
|
||||
pkg reflect, type StringHeader //deprecated #56906
|
||||
pkg regexp, method (*Regexp) MarshalText() ([]uint8, error) #46159
|
||||
pkg regexp, method (*Regexp) UnmarshalText([]uint8) error #46159
|
||||
pkg runtime, method (*PanicNilError) Error() string #25448
|
||||
pkg runtime, method (*PanicNilError) RuntimeError() #25448
|
||||
pkg runtime, method (*Pinner) Pin(interface{}) #46787
|
||||
pkg runtime, method (*Pinner) Unpin() #46787
|
||||
pkg runtime, type PanicNilError struct #25448
|
||||
pkg runtime, type Pinner struct #46787
|
||||
pkg slices, func BinarySearch[$0 interface{ ~[]$1 }, $1 cmp.Ordered]($0, $1) (int, bool) #60091
|
||||
pkg slices, func BinarySearchFunc[$0 interface{ ~[]$1 }, $1 interface{}, $2 interface{}]($0, $2, func($1, $2) int) (int, bool) #60091
|
||||
pkg slices, func Clip[$0 interface{ ~[]$1 }, $1 interface{}]($0) $0 #57433
|
||||
pkg slices, func Clone[$0 interface{ ~[]$1 }, $1 interface{}]($0) $0 #57433
|
||||
pkg slices, func Compact[$0 interface{ ~[]$1 }, $1 comparable]($0) $0 #57433
|
||||
pkg slices, func CompactFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1, $1) bool) $0 #57433
|
||||
pkg slices, func Compare[$0 interface{ ~[]$1 }, $1 cmp.Ordered]($0, $0) int #60091
|
||||
pkg slices, func CompareFunc[$0 interface{ ~[]$2 }, $1 interface{ ~[]$3 }, $2 interface{}, $3 interface{}]($0, $1, func($2, $3) int) int #60091
|
||||
pkg slices, func Contains[$0 interface{ ~[]$1 }, $1 comparable]($0, $1) bool #57433
|
||||
pkg slices, func ContainsFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1) bool) bool #57433
|
||||
pkg slices, func Delete[$0 interface{ ~[]$1 }, $1 interface{}]($0, int, int) $0 #57433
|
||||
pkg slices, func DeleteFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1) bool) $0 #54768
|
||||
pkg slices, func Equal[$0 interface{ ~[]$1 }, $1 comparable]($0, $0) bool #57433
|
||||
pkg slices, func EqualFunc[$0 interface{ ~[]$2 }, $1 interface{ ~[]$3 }, $2 interface{}, $3 interface{}]($0, $1, func($2, $3) bool) bool #57433
|
||||
pkg slices, func Grow[$0 interface{ ~[]$1 }, $1 interface{}]($0, int) $0 #57433
|
||||
pkg slices, func Index[$0 interface{ ~[]$1 }, $1 comparable]($0, $1) int #57433
|
||||
pkg slices, func IndexFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1) bool) int #57433
|
||||
pkg slices, func Insert[$0 interface{ ~[]$1 }, $1 interface{}]($0, int, ...$1) $0 #57433
|
||||
pkg slices, func IsSorted[$0 interface{ ~[]$1 }, $1 cmp.Ordered]($0) bool #60091
|
||||
pkg slices, func IsSortedFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1, $1) int) bool #60091
|
||||
pkg slices, func Max[$0 interface{ ~[]$1 }, $1 cmp.Ordered]($0) $1 #60091
|
||||
pkg slices, func MaxFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1, $1) int) $1 #60091
|
||||
pkg slices, func Min[$0 interface{ ~[]$1 }, $1 cmp.Ordered]($0) $1 #60091
|
||||
pkg slices, func MinFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1, $1) int) $1 #60091
|
||||
pkg slices, func Replace[$0 interface{ ~[]$1 }, $1 interface{}]($0, int, int, ...$1) $0 #57433
|
||||
pkg slices, func Reverse[$0 interface{ ~[]$1 }, $1 interface{}]($0) #58565
|
||||
pkg slices, func Sort[$0 interface{ ~[]$1 }, $1 cmp.Ordered]($0) #60091
|
||||
pkg slices, func SortFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1, $1) int) #60091
|
||||
pkg slices, func SortStableFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1, $1) int) #60091
|
||||
pkg strings, func ContainsFunc(string, func(int32) bool) bool #54386
|
||||
pkg sync, func OnceFunc(func()) func() #56102
|
||||
pkg sync, func OnceValue[$0 interface{}](func() $0) func() $0 #56102
|
||||
pkg sync, func OnceValues[$0 interface{}, $1 interface{}](func() ($0, $1)) func() ($0, $1) #56102
|
||||
pkg syscall (freebsd-386-cgo), type SysProcAttr struct, Jail int #46259
|
||||
pkg syscall (freebsd-386), type SysProcAttr struct, Jail int #46259
|
||||
pkg syscall (freebsd-amd64-cgo), type SysProcAttr struct, Jail int #46259
|
||||
pkg syscall (freebsd-amd64), type SysProcAttr struct, Jail int #46259
|
||||
pkg syscall (freebsd-arm64-cgo), type SysProcAttr struct, Jail int #46259
|
||||
pkg syscall (freebsd-arm64), type SysProcAttr struct, Jail int #46259
|
||||
pkg syscall (freebsd-arm-cgo), type SysProcAttr struct, Jail int #46259
|
||||
pkg syscall (freebsd-arm), type SysProcAttr struct, Jail int #46259
|
||||
pkg syscall (freebsd-riscv64-cgo), type SysProcAttr struct, Jail int #46259
|
||||
pkg syscall (freebsd-riscv64), type SysProcAttr struct, Jail int #46259
|
||||
pkg testing, func Testing() bool #52600
|
||||
pkg testing/slogtest, func TestHandler(slog.Handler, func() []map[string]interface{}) error #56345
|
||||
pkg unicode, const Version = "15.0.0" #55079
|
||||
pkg unicode, var Cypro_Minoan *RangeTable #55079
|
||||
pkg unicode, var Kawi *RangeTable #55079
|
||||
pkg unicode, var Nag_Mundari *RangeTable #55079
|
||||
pkg unicode, var Old_Uyghur *RangeTable #55079
|
||||
pkg unicode, var Tangsa *RangeTable #55079
|
||||
pkg unicode, var Toto *RangeTable #55079
|
||||
pkg unicode, var Vithkuqi *RangeTable #55079
|
||||
@@ -1,2 +1,2 @@
|
||||
branch: dev.inline
|
||||
branch: release-branch.go1.20
|
||||
parent-branch: master
|
||||
|
||||
1246
doc/go1.20.html
Normal file
1246
doc/go1.20.html
Normal file
File diff suppressed because it is too large
Load Diff
1246
doc/go1.21.html
1246
doc/go1.21.html
File diff suppressed because it is too large
Load Diff
728
doc/go_spec.html
728
doc/go_spec.html
@@ -1,6 +1,6 @@
|
||||
<!--{
|
||||
"Title": "The Go Programming Language Specification",
|
||||
"Subtitle": "Version of June 14, 2023",
|
||||
"Subtitle": "Version of December 15, 2022",
|
||||
"Path": "/ref/spec"
|
||||
}-->
|
||||
|
||||
@@ -643,7 +643,6 @@ an identifier denoting a constant,
|
||||
a <a href="#Constant_expressions">constant expression</a>,
|
||||
a <a href="#Conversions">conversion</a> with a result that is a constant, or
|
||||
the result value of some built-in functions such as
|
||||
<code>min</code> or <code>max</code> applied to constant arguments,
|
||||
<code>unsafe.Sizeof</code> applied to <a href="#Package_unsafe">certain values</a>,
|
||||
<code>cap</code> or <code>len</code> applied to
|
||||
<a href="#Length_and_capacity">some expressions</a>,
|
||||
@@ -691,7 +690,7 @@ constant is implicitly converted in contexts where a typed value is required,
|
||||
for instance, in a <a href="#Short_variable_declarations">short variable declaration</a>
|
||||
such as <code>i := 0</code> where there is no explicit type.
|
||||
The default type of an untyped constant is <code>bool</code>, <code>rune</code>,
|
||||
<code>int</code>, <code>float64</code>, <code>complex128</code>, or <code>string</code>
|
||||
<code>int</code>, <code>float64</code>, <code>complex128</code> or <code>string</code>
|
||||
respectively, depending on whether it is a boolean, rune, integer, floating-point,
|
||||
complex, or string constant.
|
||||
</p>
|
||||
@@ -1645,10 +1644,8 @@ built-in function <a href="#Length_and_capacity"><code>len</code></a>
|
||||
and may change during execution. Elements may be added during execution
|
||||
using <a href="#Assignment_statements">assignments</a> and retrieved with
|
||||
<a href="#Index_expressions">index expressions</a>; they may be removed with the
|
||||
<a href="#Deletion_of_map_elements"><code>delete</code></a> and
|
||||
<a href="#Clear"><code>clear</code></a> built-in function.
|
||||
<a href="#Deletion_of_map_elements"><code>delete</code></a> built-in function.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
A new, empty map value is made using the built-in
|
||||
function <a href="#Making_slices_maps_and_channels"><code>make</code></a>,
|
||||
@@ -1886,7 +1883,7 @@ interface{ ~[]byte | myString } // bytestring
|
||||
|
||||
<p>
|
||||
Note that <code>bytestring</code> is not a real type; it cannot be used to declare
|
||||
variables or compose other types. It exists solely to describe the behavior of some
|
||||
variables are compose other types. It exists solely to describe the behavior of some
|
||||
operations that read from a sequence of bytes, which may be a byte slice or a string.
|
||||
</p>
|
||||
|
||||
@@ -2319,8 +2316,8 @@ Zero value:
|
||||
nil
|
||||
|
||||
Functions:
|
||||
append cap clear close complex copy delete imag len
|
||||
make max min new panic print println real recover
|
||||
append cap close complex copy delete imag len
|
||||
make new panic print println real recover
|
||||
</pre>
|
||||
|
||||
<h3 id="Exported_identifiers">Exported identifiers</h3>
|
||||
@@ -2648,7 +2645,7 @@ TypeParamDecl = IdentifierList TypeConstraint .
|
||||
<p>
|
||||
All non-blank names in the list must be unique.
|
||||
Each name declares a type parameter, which is a new and different <a href="#Types">named type</a>
|
||||
that acts as a placeholder for an (as of yet) unknown type in the declaration.
|
||||
that acts as a place holder for an (as of yet) unknown type in the declaration.
|
||||
The type parameter is replaced with a <i>type argument</i> upon
|
||||
<a href="#Instantiations">instantiation</a> of the generic function or type.
|
||||
</p>
|
||||
@@ -2762,7 +2759,7 @@ However, they <a href="#Satisfying_a_type_constraint">satisfy</a> <code>comparab
|
||||
int // implements comparable (int is strictly comparable)
|
||||
[]byte // does not implement comparable (slices cannot be compared)
|
||||
interface{} // does not implement comparable (see above)
|
||||
interface{ ~int | ~string } // type parameter only: implements comparable (int, string types are strictly comparable)
|
||||
interface{ ~int | ~string } // type parameter only: implements comparable (int, string types are stricly comparable)
|
||||
interface{ comparable } // type parameter only: implements comparable (comparable implements itself)
|
||||
interface{ ~int | ~[]byte } // type parameter only: does not implement comparable (slices are not comparable)
|
||||
interface{ ~struct{ any } } // type parameter only: does not implement comparable (field any is not strictly comparable)
|
||||
@@ -2805,7 +2802,7 @@ A type T <i>satisfies</i> a constraint <code>C</code> if
|
||||
type argument type constraint // constraint satisfaction
|
||||
|
||||
int interface{ ~int } // satisfied: int implements interface{ ~int }
|
||||
string comparable // satisfied: string implements comparable (string is strictly comparable)
|
||||
string comparable // satisfied: string implements comparable (string is stricty comparable)
|
||||
[]byte comparable // not satisfied: slices are not comparable
|
||||
any interface{ comparable; int } // not satisfied: any does not implement interface{ int }
|
||||
any comparable // satisfied: any is comparable and implements the basic interface any
|
||||
@@ -4340,46 +4337,24 @@ type parameter list type arguments after substitution
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
When using a generic function, type arguments may be provided explicitly,
|
||||
or they may be partially or completely <a href="#Type_inference">inferred</a>
|
||||
from the context in which the function is used.
|
||||
Provided that they can be inferred, type arguments may be omitted entirely if the function is:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#Calls">called</a> with ordinary arguments,
|
||||
</li>
|
||||
<li>
|
||||
<a href="#Assignment_statements">assigned</a> to a variable with an explicitly declared type,
|
||||
</li>
|
||||
<li>
|
||||
<a href="#Calls">passed as an argument</a> to another function, or
|
||||
</li>
|
||||
<li>
|
||||
<a href="#Return_statements">returned as a result</a>.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
In all other cases, a (possibly partial) type argument list must be present.
|
||||
If a type argument list is absent or partial, all missing type arguments
|
||||
must be inferrable from the context in which the function is used.
|
||||
For a generic function, type arguments may be provided explicitly, or they
|
||||
may be partially or completely <a href="#Type_inference">inferred</a>.
|
||||
A generic function that is <i>not</i> <a href="#Calls">called</a> requires a
|
||||
type argument list for instantiation; if the list is partial, all
|
||||
remaining type arguments must be inferrable.
|
||||
A generic function that is called may provide a (possibly partial) type
|
||||
argument list, or may omit it entirely if the omitted type arguments are
|
||||
inferrable from the ordinary (non-type) function arguments.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
// sum returns the sum (concatenation, for strings) of its arguments.
|
||||
func sum[T ~int | ~float64 | ~string](x... T) T { … }
|
||||
func min[T ~int|~float64](x, y T) T { … }
|
||||
|
||||
x := sum // illegal: sum must have a type argument (x is a variable without a declared type)
|
||||
intSum := sum[int] // intSum has type func(x... int) int
|
||||
a := intSum(2, 3) // a has value 5 of type int
|
||||
b := sum[float64](2.0, 3) // b has value 5.0 of type float64
|
||||
c := sum(b, -1) // c has value 4.0 of type float64
|
||||
|
||||
type sumFunc func(x... string) string
|
||||
var f sumFunc = sum // same as var f sumFunc = sum[string]
|
||||
f = sum // same as f = sum[string]
|
||||
f := min // illegal: min must be instantiated with type arguments when used without being called
|
||||
minInt := min[int] // minInt has type func(x, y int) int
|
||||
a := minInt(2, 3) // a has value 2 of type int
|
||||
b := min[float64](2.0, 3) // b has value 2.0 of type float64
|
||||
c := min(b, -1) // c has value -1.0 of type float64
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -4405,10 +4380,6 @@ For a generic type, all type arguments must always be provided explicitly.
|
||||
|
||||
<h3 id="Type_inference">Type inference</h3>
|
||||
|
||||
<p>
|
||||
<em>NOTE: This section is not yet up-to-date for Go 1.21.</em>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Missing function type arguments may be <i>inferred</i> by a series of steps, described below.
|
||||
Each step attempts to use known information to infer additional type arguments.
|
||||
@@ -5609,6 +5580,21 @@ succeeds but the result value is implementation-dependent.
|
||||
<h4 id="Conversions_to_and_from_a_string_type">Conversions to and from a string type</h4>
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
Converting a signed or unsigned integer value to a string type yields a
|
||||
string containing the UTF-8 representation of the integer. Values outside
|
||||
the range of valid Unicode code points are converted to <code>"\uFFFD"</code>.
|
||||
|
||||
<pre>
|
||||
string('a') // "a"
|
||||
string(-1) // "\ufffd" == "\xef\xbf\xbd"
|
||||
string(0xf8) // "\u00f8" == "ø" == "\xc3\xb8"
|
||||
|
||||
type myString string
|
||||
myString(0x65e5) // "\u65e5" == "日" == "\xe6\x97\xa5"
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
Converting a slice of bytes to a string type yields
|
||||
a string whose successive bytes are the elements of the slice.
|
||||
@@ -5675,31 +5661,6 @@ runes("白鵬翔") // []rune{0x767d, 0x9d6c, 0x7fd4}
|
||||
[]myRune(myString("🌐")) // []myRune{0x1f310}
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
Finally, for historical reasons, an integer value may be converted to a string type.
|
||||
This form of conversion yields a string containing the (possibly multi-byte) UTF-8
|
||||
representation of the Unicode code point with the given integer value.
|
||||
Values outside the range of valid Unicode code points are converted to <code>"\uFFFD"</code>.
|
||||
|
||||
<pre>
|
||||
string('a') // "a"
|
||||
string(65) // "A"
|
||||
string('\xf8') // "\u00f8" == "ø" == "\xc3\xb8"
|
||||
string(-1) // "\ufffd" == "\xef\xbf\xbd"
|
||||
|
||||
type myString string
|
||||
myString('\u65e5') // "\u65e5" == "日" == "\xe6\x97\xa5"
|
||||
</pre>
|
||||
|
||||
Note: This form of conversion may eventually be removed from the language.
|
||||
The <a href="/pkg/cmd/vet"><code>go vet</code></a> tool flags certain
|
||||
integer-to-string conversions as potential errors.
|
||||
Library functions such as
|
||||
<a href="/pkg/unicode/utf8#AppendRune"><code>utf8.AppendRune</code></a> or
|
||||
<a href="/pkg/unicode/utf8#EncodeRune"><code>utf8.EncodeRune</code></a>
|
||||
should be used instead.
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<h4 id="Conversions_from_slice_to_array_or_array_pointer">Conversions from slice to array or array pointer</h4>
|
||||
@@ -6066,7 +6027,7 @@ The following built-in functions are not permitted in statement context:
|
||||
|
||||
<pre>
|
||||
append cap complex imag len make new real
|
||||
unsafe.Add unsafe.Alignof unsafe.Offsetof unsafe.Sizeof unsafe.Slice unsafe.SliceData unsafe.String unsafe.StringData
|
||||
unsafe.Add unsafe.Alignof unsafe.Offsetof unsafe.Sizeof unsafe.Slice
|
||||
</pre>
|
||||
|
||||
<pre>
|
||||
@@ -6248,7 +6209,7 @@ x = []int{3, 5, 7}
|
||||
for i, x[i] = range x { // set i, x[2] = 0, x[0]
|
||||
break
|
||||
}
|
||||
// after this loop, i == 0 and x is []int{3, 5, 3}
|
||||
// after this loop, i == 0 and x == []int{3, 5, 3}
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -7220,120 +7181,6 @@ so they can only appear in <a href="#Calls">call expressions</a>;
|
||||
they cannot be used as function values.
|
||||
</p>
|
||||
|
||||
|
||||
<h3 id="Appending_and_copying_slices">Appending to and copying slices</h3>
|
||||
|
||||
<p>
|
||||
The built-in functions <code>append</code> and <code>copy</code> assist in
|
||||
common slice operations.
|
||||
For both functions, the result is independent of whether the memory referenced
|
||||
by the arguments overlaps.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The <a href="#Function_types">variadic</a> function <code>append</code>
|
||||
appends zero or more values <code>x</code> to a slice <code>s</code>
|
||||
and returns the resulting slice of the same type as <code>s</code>.
|
||||
The <a href="#Core_types">core type</a> of <code>s</code> must be a slice
|
||||
of type <code>[]E</code>.
|
||||
The values <code>x</code> are passed to a parameter of type <code>...E</code>
|
||||
and the respective <a href="#Passing_arguments_to_..._parameters">parameter
|
||||
passing rules</a> apply.
|
||||
As a special case, if the core type of <code>s</code> is <code>[]byte</code>,
|
||||
<code>append</code> also accepts a second argument with core type
|
||||
<a href="#Core_types"><code>bytestring</code></a> followed by <code>...</code>.
|
||||
This form appends the bytes of the byte slice or string.
|
||||
</p>
|
||||
|
||||
<pre class="grammar">
|
||||
append(s S, x ...E) S // core type of S is []E
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
If the capacity of <code>s</code> is not large enough to fit the additional
|
||||
values, <code>append</code> <a href="#Allocation">allocates</a> a new, sufficiently large underlying
|
||||
array that fits both the existing slice elements and the additional values.
|
||||
Otherwise, <code>append</code> re-uses the underlying array.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
s0 := []int{0, 0}
|
||||
s1 := append(s0, 2) // append a single element s1 is []int{0, 0, 2}
|
||||
s2 := append(s1, 3, 5, 7) // append multiple elements s2 is []int{0, 0, 2, 3, 5, 7}
|
||||
s3 := append(s2, s0...) // append a slice s3 is []int{0, 0, 2, 3, 5, 7, 0, 0}
|
||||
s4 := append(s3[3:6], s3[2:]...) // append overlapping slice s4 is []int{3, 5, 7, 2, 3, 5, 7, 0, 0}
|
||||
|
||||
var t []interface{}
|
||||
t = append(t, 42, 3.1415, "foo") // t is []interface{}{42, 3.1415, "foo"}
|
||||
|
||||
var b []byte
|
||||
b = append(b, "bar"...) // append string contents b is []byte{'b', 'a', 'r' }
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The function <code>copy</code> copies slice elements from
|
||||
a source <code>src</code> to a destination <code>dst</code> and returns the
|
||||
number of elements copied.
|
||||
The <a href="#Core_types">core types</a> of both arguments must be slices
|
||||
with <a href="#Type_identity">identical</a> element type.
|
||||
The number of elements copied is the minimum of
|
||||
<code>len(src)</code> and <code>len(dst)</code>.
|
||||
As a special case, if the destination's core type is <code>[]byte</code>,
|
||||
<code>copy</code> also accepts a source argument with core type
|
||||
</a> <a href="#Core_types"><code>bytestring</code></a>.
|
||||
This form copies the bytes from the byte slice or string into the byte slice.
|
||||
</p>
|
||||
|
||||
<pre class="grammar">
|
||||
copy(dst, src []T) int
|
||||
copy(dst []byte, src string) int
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Examples:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
var a = [...]int{0, 1, 2, 3, 4, 5, 6, 7}
|
||||
var s = make([]int, 6)
|
||||
var b = make([]byte, 5)
|
||||
n1 := copy(s, a[0:]) // n1 == 6, s is []int{0, 1, 2, 3, 4, 5}
|
||||
n2 := copy(s, s[2:]) // n2 == 4, s is []int{2, 3, 4, 5, 4, 5}
|
||||
n3 := copy(b, "Hello, World!") // n3 == 5, b is []byte("Hello")
|
||||
</pre>
|
||||
|
||||
|
||||
<h3 id="Clear">Clear</h3>
|
||||
|
||||
<p>
|
||||
The built-in function <code>clear</code> takes an argument of <a href="#Map_types">map</a>,
|
||||
<a href="#Slice_types">slice</a>, or <a href="#Type_parameter_declarations">type parameter</a> type,
|
||||
and deletes or zeroes out all elements.
|
||||
</p>
|
||||
|
||||
<pre class="grammar">
|
||||
Call Argument type Result
|
||||
|
||||
clear(m) map[K]T deletes all entries, resulting in an
|
||||
empty map (len(m) == 0)
|
||||
|
||||
clear(s) []T sets all elements up to the length of
|
||||
<code>s</code> to the zero value of T
|
||||
|
||||
clear(t) type parameter see below
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
If the argument type is a <a href="#Type_parameter_declarations">type parameter</a>,
|
||||
all types in its type set must be maps or slices, and <code>clear</code>
|
||||
performs the operation corresponding to the actual type argument.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If the map or slice is <code>nil</code>, <code>clear</code> is a no-op.
|
||||
</p>
|
||||
|
||||
|
||||
<h3 id="Close">Close</h3>
|
||||
|
||||
<p>
|
||||
@@ -7350,100 +7197,6 @@ The multi-valued <a href="#Receive_operator">receive operation</a>
|
||||
returns a received value along with an indication of whether the channel is closed.
|
||||
</p>
|
||||
|
||||
|
||||
<h3 id="Complex_numbers">Manipulating complex numbers</h3>
|
||||
|
||||
<p>
|
||||
Three functions assemble and disassemble complex numbers.
|
||||
The built-in function <code>complex</code> constructs a complex
|
||||
value from a floating-point real and imaginary part, while
|
||||
<code>real</code> and <code>imag</code>
|
||||
extract the real and imaginary parts of a complex value.
|
||||
</p>
|
||||
|
||||
<pre class="grammar">
|
||||
complex(realPart, imaginaryPart floatT) complexT
|
||||
real(complexT) floatT
|
||||
imag(complexT) floatT
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The type of the arguments and return value correspond.
|
||||
For <code>complex</code>, the two arguments must be of the same
|
||||
<a href="#Numeric_types">floating-point type</a> and the return type is the
|
||||
<a href="#Numeric_types">complex type</a>
|
||||
with the corresponding floating-point constituents:
|
||||
<code>complex64</code> for <code>float32</code> arguments, and
|
||||
<code>complex128</code> for <code>float64</code> arguments.
|
||||
If one of the arguments evaluates to an untyped constant, it is first implicitly
|
||||
<a href="#Conversions">converted</a> to the type of the other argument.
|
||||
If both arguments evaluate to untyped constants, they must be non-complex
|
||||
numbers or their imaginary parts must be zero, and the return value of
|
||||
the function is an untyped complex constant.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For <code>real</code> and <code>imag</code>, the argument must be
|
||||
of complex type, and the return type is the corresponding floating-point
|
||||
type: <code>float32</code> for a <code>complex64</code> argument, and
|
||||
<code>float64</code> for a <code>complex128</code> argument.
|
||||
If the argument evaluates to an untyped constant, it must be a number,
|
||||
and the return value of the function is an untyped floating-point constant.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The <code>real</code> and <code>imag</code> functions together form the inverse of
|
||||
<code>complex</code>, so for a value <code>z</code> of a complex type <code>Z</code>,
|
||||
<code>z == Z(complex(real(z), imag(z)))</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If the operands of these functions are all constants, the return
|
||||
value is a constant.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
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 int = complex(1, 0) // untyped complex constant 1 + 0i can be converted to int
|
||||
_ = complex(1, 2<<s) // illegal: 2 assumes 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
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Arguments of type parameter type are not permitted.
|
||||
</p>
|
||||
|
||||
|
||||
<h3 id="Deletion_of_map_elements">Deletion of map elements</h3>
|
||||
|
||||
<p>
|
||||
The built-in function <code>delete</code> removes the element with key
|
||||
<code>k</code> from a <a href="#Map_types">map</a> <code>m</code>. The
|
||||
value <code>k</code> must be <a href="#Assignability">assignable</a>
|
||||
to the key type of <code>m</code>.
|
||||
</p>
|
||||
|
||||
<pre class="grammar">
|
||||
delete(m, k) // remove element m[k] from map m
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
If the type of <code>m</code> is a <a href="#Type_parameter_declarations">type parameter</a>,
|
||||
all types in that type set must be maps, and they must all have identical key types.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If the map <code>m</code> is <code>nil</code> or the element <code>m[k]</code>
|
||||
does not exist, <code>delete</code> is a no-op.
|
||||
</p>
|
||||
|
||||
|
||||
<h3 id="Length_and_capacity">Length and capacity</h3>
|
||||
|
||||
<p>
|
||||
@@ -7514,124 +7267,6 @@ const (
|
||||
var z complex128
|
||||
</pre>
|
||||
|
||||
|
||||
<h3 id="Making_slices_maps_and_channels">Making slices, maps and channels</h3>
|
||||
|
||||
<p>
|
||||
The built-in function <code>make</code> takes a type <code>T</code>,
|
||||
optionally followed by a type-specific list of expressions.
|
||||
The <a href="#Core_types">core type</a> of <code>T</code> must
|
||||
be a slice, map or channel.
|
||||
It returns a value of type <code>T</code> (not <code>*T</code>).
|
||||
The memory is initialized as described in the section on
|
||||
<a href="#The_zero_value">initial values</a>.
|
||||
</p>
|
||||
|
||||
<pre class="grammar">
|
||||
Call Core type Result
|
||||
|
||||
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) channel unbuffered channel of type T
|
||||
make(T, n) channel buffered channel of type T, buffer size n
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Each of the size arguments <code>n</code> and <code>m</code> must be of <a href="#Numeric_types">integer type</a>,
|
||||
have a <a href="#Interface_types">type set</a> containing only integer types,
|
||||
or be an untyped <a href="#Constants">constant</a>.
|
||||
A constant size argument must be non-negative and <a href="#Representability">representable</a>
|
||||
by a value of type <code>int</code>; if it is an untyped constant it is given type <code>int</code>.
|
||||
If both <code>n</code> and <code>m</code> are provided and are constant, then
|
||||
<code>n</code> must be no larger than <code>m</code>.
|
||||
For slices and channels, if <code>n</code> is negative or larger than <code>m</code> at run time,
|
||||
a <a href="#Run_time_panics">run-time panic</a> occurs.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
s := make([]int, 10, 100) // slice with len(s) == 10, cap(s) == 100
|
||||
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
|
||||
</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="Min_and_max">Min and max</h3>
|
||||
|
||||
<p>
|
||||
The built-in functions <code>min</code> and <code>max</code> compute the
|
||||
smallest—or largest, respectively—value of a fixed number of
|
||||
arguments of <a href="#Comparison_operators">ordered types</a>.
|
||||
There must be at least one argument.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The same type rules as for <a href="#Operators">operators</a> apply:
|
||||
for <a href="#Comparison_operators">ordered</a> arguments <code>x</code> and
|
||||
<code>y</code>, <code>min(x, y)</code> is valid if <code>x + y</code> is valid,
|
||||
and the type of <code>min(x, y)</code> is the type of <code>x + y</code>
|
||||
(and similarly for <code>max</code>).
|
||||
If all arguments are constant, the result is constant.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
var x, y int
|
||||
m := min(x) // m == x
|
||||
m := min(x, y) // m is the smaller of x and y
|
||||
m := max(x, y, 10) // m is the larger of x and y but at least 10
|
||||
c := max(1, 2.0, 10) // c == 10.0 (floating-point kind)
|
||||
f := max(0, float32(x)) // type of f is float32
|
||||
var s []string
|
||||
_ = min(s...) // invalid: slice arguments are not permitted
|
||||
t := max("", "foo", "bar") // t == "foo" (string kind)
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
For numeric arguments, assuming all NaNs are equal, <code>min</code> and <code>max</code> are
|
||||
commutative and associative:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
min(x, y) == min(y, x)
|
||||
min(x, y, z) == min(min(x, y), z) == min(x, min(y, z))
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
For floating-point arguments negative zero, NaN, and infinity the following rules apply:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
x y min(x, y) max(x, y)
|
||||
|
||||
-0.0 0.0 -0.0 0.0 // negative zero is smaller than (non-negative) zero
|
||||
-Inf y -Inf y // negative infinity is smaller than any other number
|
||||
+Inf y y +Inf // positive infinity is larger than any other number
|
||||
NaN y NaN NaN // if any argument is a NaN, the result is a NaN
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
For string arguments the result for <code>min</code> is the first argument
|
||||
with the smallest (or for <code>max</code>, largest) value,
|
||||
compared lexically byte-wise:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
min(x, y) == if x <= y then x else y
|
||||
min(x, y, z) == min(min(x, y), z)
|
||||
</pre>
|
||||
|
||||
<h3 id="Allocation">Allocation</h3>
|
||||
|
||||
<p>
|
||||
@@ -7663,6 +7298,233 @@ and returns a value of type <code>*S</code> containing the address
|
||||
of the location.
|
||||
</p>
|
||||
|
||||
<h3 id="Making_slices_maps_and_channels">Making slices, maps and channels</h3>
|
||||
|
||||
<p>
|
||||
The built-in function <code>make</code> takes a type <code>T</code>,
|
||||
optionally followed by a type-specific list of expressions.
|
||||
The <a href="#Core_types">core type</a> of <code>T</code> must
|
||||
be a slice, map or channel.
|
||||
It returns a value of type <code>T</code> (not <code>*T</code>).
|
||||
The memory is initialized as described in the section on
|
||||
<a href="#The_zero_value">initial values</a>.
|
||||
</p>
|
||||
|
||||
<pre class="grammar">
|
||||
Call Core type Result
|
||||
|
||||
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) channel unbuffered channel of type T
|
||||
make(T, n) channel buffered channel of type T, buffer size n
|
||||
</pre>
|
||||
|
||||
|
||||
<p>
|
||||
Each of the size arguments <code>n</code> and <code>m</code> must be of <a href="#Numeric_types">integer type</a>,
|
||||
have a <a href="#Interface_types">type set</a> containing only integer types,
|
||||
or be an untyped <a href="#Constants">constant</a>.
|
||||
A constant size argument must be non-negative and <a href="#Representability">representable</a>
|
||||
by a value of type <code>int</code>; if it is an untyped constant it is given type <code>int</code>.
|
||||
If both <code>n</code> and <code>m</code> are provided and are constant, then
|
||||
<code>n</code> must be no larger than <code>m</code>.
|
||||
For slices and channels, if <code>n</code> is negative or larger than <code>m</code> at run time,
|
||||
a <a href="#Run_time_panics">run-time panic</a> occurs.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
s := make([]int, 10, 100) // slice with len(s) == 10, cap(s) == 100
|
||||
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
|
||||
</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>
|
||||
|
||||
<p>
|
||||
The built-in functions <code>append</code> and <code>copy</code> assist in
|
||||
common slice operations.
|
||||
For both functions, the result is independent of whether the memory referenced
|
||||
by the arguments overlaps.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The <a href="#Function_types">variadic</a> function <code>append</code>
|
||||
appends zero or more values <code>x</code> to a slice <code>s</code>
|
||||
and returns the resulting slice of the same type as <code>s</code>.
|
||||
The <a href="#Core_types">core type</a> of <code>s</code> must be a slice
|
||||
of type <code>[]E</code>.
|
||||
The values <code>x</code> are passed to a parameter of type <code>...E</code>
|
||||
and the respective <a href="#Passing_arguments_to_..._parameters">parameter
|
||||
passing rules</a> apply.
|
||||
As a special case, if the core type of <code>s</code> is <code>[]byte</code>,
|
||||
<code>append</code> also accepts a second argument with core type
|
||||
<a href="#Core_types"><code>bytestring</code></a> followed by <code>...</code>.
|
||||
This form appends the bytes of the byte slice or string.
|
||||
</p>
|
||||
|
||||
<pre class="grammar">
|
||||
append(s S, x ...E) S // core type of S is []E
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
If the capacity of <code>s</code> is not large enough to fit the additional
|
||||
values, <code>append</code> <a href="#Allocation">allocates</a> a new, sufficiently large underlying
|
||||
array that fits both the existing slice elements and the additional values.
|
||||
Otherwise, <code>append</code> re-uses the underlying array.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
s0 := []int{0, 0}
|
||||
s1 := append(s0, 2) // append a single element s1 == []int{0, 0, 2}
|
||||
s2 := append(s1, 3, 5, 7) // append multiple elements s2 == []int{0, 0, 2, 3, 5, 7}
|
||||
s3 := append(s2, s0...) // append a slice s3 == []int{0, 0, 2, 3, 5, 7, 0, 0}
|
||||
s4 := append(s3[3:6], s3[2:]...) // append overlapping slice s4 == []int{3, 5, 7, 2, 3, 5, 7, 0, 0}
|
||||
|
||||
var t []interface{}
|
||||
t = append(t, 42, 3.1415, "foo") // t == []interface{}{42, 3.1415, "foo"}
|
||||
|
||||
var b []byte
|
||||
b = append(b, "bar"...) // append string contents b == []byte{'b', 'a', 'r' }
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The function <code>copy</code> copies slice elements from
|
||||
a source <code>src</code> to a destination <code>dst</code> and returns the
|
||||
number of elements copied.
|
||||
The <a href="#Core_types">core types</a> of both arguments must be slices
|
||||
with <a href="#Type_identity">identical</a> element type.
|
||||
The number of elements copied is the minimum of
|
||||
<code>len(src)</code> and <code>len(dst)</code>.
|
||||
As a special case, if the destination's core type is <code>[]byte</code>,
|
||||
<code>copy</code> also accepts a source argument with core type
|
||||
</a> <a href="#Core_types"><code>bytestring</code></a>.
|
||||
This form copies the bytes from the byte slice or string into the byte slice.
|
||||
</p>
|
||||
|
||||
<pre class="grammar">
|
||||
copy(dst, src []T) int
|
||||
copy(dst []byte, src string) int
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Examples:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
var a = [...]int{0, 1, 2, 3, 4, 5, 6, 7}
|
||||
var s = make([]int, 6)
|
||||
var b = make([]byte, 5)
|
||||
n1 := copy(s, a[0:]) // n1 == 6, s == []int{0, 1, 2, 3, 4, 5}
|
||||
n2 := copy(s, s[2:]) // n2 == 4, s == []int{2, 3, 4, 5, 4, 5}
|
||||
n3 := copy(b, "Hello, World!") // n3 == 5, b == []byte("Hello")
|
||||
</pre>
|
||||
|
||||
|
||||
<h3 id="Deletion_of_map_elements">Deletion of map elements</h3>
|
||||
|
||||
<p>
|
||||
The built-in function <code>delete</code> removes the element with key
|
||||
<code>k</code> from a <a href="#Map_types">map</a> <code>m</code>. The
|
||||
value <code>k</code> must be <a href="#Assignability">assignable</a>
|
||||
to the key type of <code>m</code>.
|
||||
</p>
|
||||
|
||||
<pre class="grammar">
|
||||
delete(m, k) // remove element m[k] from map m
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
If the type of <code>m</code> is a <a href="#Type_parameter_declarations">type parameter</a>,
|
||||
all types in that type set must be maps, and they must all have identical key types.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If the map <code>m</code> is <code>nil</code> or the element <code>m[k]</code>
|
||||
does not exist, <code>delete</code> is a no-op.
|
||||
</p>
|
||||
|
||||
|
||||
<h3 id="Complex_numbers">Manipulating complex numbers</h3>
|
||||
|
||||
<p>
|
||||
Three functions assemble and disassemble complex numbers.
|
||||
The built-in function <code>complex</code> constructs a complex
|
||||
value from a floating-point real and imaginary part, while
|
||||
<code>real</code> and <code>imag</code>
|
||||
extract the real and imaginary parts of a complex value.
|
||||
</p>
|
||||
|
||||
<pre class="grammar">
|
||||
complex(realPart, imaginaryPart floatT) complexT
|
||||
real(complexT) floatT
|
||||
imag(complexT) floatT
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The type of the arguments and return value correspond.
|
||||
For <code>complex</code>, the two arguments must be of the same
|
||||
<a href="#Numeric_types">floating-point type</a> and the return type is the
|
||||
<a href="#Numeric_types">complex type</a>
|
||||
with the corresponding floating-point constituents:
|
||||
<code>complex64</code> for <code>float32</code> arguments, and
|
||||
<code>complex128</code> for <code>float64</code> arguments.
|
||||
If one of the arguments evaluates to an untyped constant, it is first implicitly
|
||||
<a href="#Conversions">converted</a> to the type of the other argument.
|
||||
If both arguments evaluate to untyped constants, they must be non-complex
|
||||
numbers or their imaginary parts must be zero, and the return value of
|
||||
the function is an untyped complex constant.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For <code>real</code> and <code>imag</code>, the argument must be
|
||||
of complex type, and the return type is the corresponding floating-point
|
||||
type: <code>float32</code> for a <code>complex64</code> argument, and
|
||||
<code>float64</code> for a <code>complex128</code> argument.
|
||||
If the argument evaluates to an untyped constant, it must be a number,
|
||||
and the return value of the function is an untyped floating-point constant.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The <code>real</code> and <code>imag</code> functions together form the inverse of
|
||||
<code>complex</code>, so for a value <code>z</code> of a complex type <code>Z</code>,
|
||||
<code>z == Z(complex(real(z), imag(z)))</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If the operands of these functions are all constants, the return
|
||||
value is a constant.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
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 int = complex(1, 0) // untyped complex constant 1 + 0i can be converted to int
|
||||
_ = complex(1, 2<<s) // illegal: 2 assumes 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
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Arguments of type parameter type are not permitted.
|
||||
</p>
|
||||
|
||||
<h3 id="Handling_panics">Handling panics</h3>
|
||||
|
||||
@@ -7712,13 +7574,19 @@ execution terminates by returning to its caller.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The return value of <code>recover</code> is <code>nil</code> when the
|
||||
goroutine is not panicking or <code>recover</code> was not called directly by a deferred function.
|
||||
Conversely, if a goroutine is panicking and <code>recover</code> was called directly by a deferred function,
|
||||
the return value of <code>recover</code> is guaranteed not to be <code>nil</code>.
|
||||
To ensure this, calling <code>panic</code> with a <code>nil</code> interface value (or an untyped <code>nil</code>)
|
||||
causes a <a href="#Run_time_panics">run-time panic</a>.
|
||||
The return value of <code>recover</code> is <code>nil</code> if any of the following conditions holds:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<code>panic</code>'s argument was <code>nil</code>;
|
||||
</li>
|
||||
<li>
|
||||
the goroutine is not panicking;
|
||||
</li>
|
||||
<li>
|
||||
<code>recover</code> was not called directly by a deferred function.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
The <code>protect</code> function in the example below invokes
|
||||
@@ -7761,7 +7629,6 @@ 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>
|
||||
|
||||
<p>
|
||||
@@ -8035,9 +7902,6 @@ The declaration order of variables declared in multiple files is determined
|
||||
by the order in which the files are presented to the compiler: Variables
|
||||
declared in the first file are declared before any of the variables declared
|
||||
in the second file, and so on.
|
||||
To ensure reproducible initialization behavior, build systems are encouraged
|
||||
to present multiple files belonging to the same package in lexical file name
|
||||
order to a compiler.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -8148,30 +8012,15 @@ in a program.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The entire package is initialized by assigning initial values
|
||||
to all its package-level variables followed by calling
|
||||
all <code>init</code> functions in the order they appear
|
||||
in the source, possibly in multiple files, as presented
|
||||
to the compiler.
|
||||
</p>
|
||||
|
||||
<h3 id="Program_initialization">Program initialization</h3>
|
||||
|
||||
<p>
|
||||
The packages of a complete program are initialized stepwise, one package at a time.
|
||||
A package with no imports is initialized by assigning initial values
|
||||
to all its package-level variables followed by calling all <code>init</code>
|
||||
functions in the order they appear in the source, possibly in multiple files,
|
||||
as presented to the compiler.
|
||||
If a package has imports, the imported packages are initialized
|
||||
before initializing the package itself. If multiple packages import
|
||||
a package, the imported package will be initialized only once.
|
||||
The importing of packages, by construction, guarantees that there
|
||||
can be no cyclic initialization dependencies.
|
||||
More precisely:
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Given the list of all packages, sorted by import path, in each step the first
|
||||
uninitialized package in the list for which all imported packages (if any) are
|
||||
already initialized is <a href="#Package_initialization">initialized</a>.
|
||||
This step is repeated until all packages are initialized.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -8185,6 +8034,13 @@ the <code>init</code> functions: it will not invoke the next one
|
||||
until the previous one has returned.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To ensure reproducible initialization behavior, build systems are encouraged
|
||||
to present multiple files belonging to the same package in lexical file name
|
||||
order to a compiler.
|
||||
</p>
|
||||
|
||||
|
||||
<h3 id="Program_execution">Program execution</h3>
|
||||
<p>
|
||||
A complete program is created by linking a single, unimported package
|
||||
@@ -8200,8 +8056,8 @@ func main() { … }
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Program execution begins by <a href="#Program_initialization">initializing the program</a>
|
||||
and then invoking the function <code>main</code> in package <code>main</code>.
|
||||
Program execution begins by initializing the main package and then
|
||||
invoking the function <code>main</code>.
|
||||
When that function invocation returns, the program exits.
|
||||
It does not wait for other (non-<code>main</code>) goroutines to complete.
|
||||
</p>
|
||||
|
||||
201
doc/godebug.md
201
doc/godebug.md
@@ -1,201 +0,0 @@
|
||||
---
|
||||
title: "Go, Backwards Compatibility, and GODEBUG"
|
||||
layout: article
|
||||
---
|
||||
|
||||
<!--
|
||||
This document is kept in the Go repo, not x/website,
|
||||
because it documents the full list of known GODEBUG settings,
|
||||
which are tied to a specific release.
|
||||
-->
|
||||
|
||||
## Introduction {#intro}
|
||||
|
||||
Go's emphasis on backwards compatibility is one of its key strengths.
|
||||
There are, however, times when we cannot maintain complete compatibility.
|
||||
If code depends on buggy (including insecure) behavior,
|
||||
then fixing the bug will break that code.
|
||||
New features can also have similar impacts:
|
||||
enabling the HTTP/2 use by the HTTP client broke programs
|
||||
connecting to servers with buggy HTTP/2 implementations.
|
||||
These kinds of changes are unavoidable and
|
||||
[permitted by the Go 1 compatibility rules](/doc/go1compat).
|
||||
Even so, Go provides a mechanism called GODEBUG to
|
||||
reduce the impact such changes have on Go developers
|
||||
using newer toolchains to compile old code.
|
||||
|
||||
A GODEBUG setting is a `key=value` pair
|
||||
that controls the execution of certain parts of a Go program.
|
||||
The environment variable `GODEBUG`
|
||||
can hold a comma-separated list of these settings.
|
||||
For example, if a Go program is running in an environment that contains
|
||||
|
||||
GODEBUG=http2client=0,http2server=0
|
||||
|
||||
then that Go program will disable the use of HTTP/2 by default in both
|
||||
the HTTP client and the HTTP server.
|
||||
It is also possible to set the default `GODEBUG` for a given program
|
||||
(discussed below).
|
||||
|
||||
When preparing any change that is permitted by Go 1 compatibility
|
||||
but may nonetheless break some existing programs,
|
||||
we first engineer the change to keep as many existing programs working as possible.
|
||||
For the remaining programs,
|
||||
we define a new GODEBUG setting that
|
||||
allows individual programs to opt back in to the old behavior.
|
||||
A GODEBUG setting may not be added if doing so is infeasible,
|
||||
but that should be extremely rare.
|
||||
|
||||
GODEBUG settings added for compatibility will be maintained
|
||||
for a minimum of two years (four Go releases).
|
||||
Some, such as `http2client` and `http2server`,
|
||||
will be maintained much longer, even indefinitely.
|
||||
|
||||
When possible, each GODEBUG setting has an associated
|
||||
[runtime/metrics](/pkg/runtime/metrics/) counter
|
||||
named `/godebug/non-default-behavior/<name>:events`
|
||||
that counts the number of times a particular program's
|
||||
behavior has changed based on a non-default value
|
||||
for that setting.
|
||||
For example, when `GODEBUG=http2client=0` is set,
|
||||
`/godebug/non-default-behavior/http2client:events`
|
||||
counts the number of HTTP transports that the program
|
||||
has configured without HTTP/2 support.
|
||||
|
||||
## Default GODEBUG Values {#default}
|
||||
|
||||
When a GODEBUG setting is not listed in the environment variable,
|
||||
its value is derived from three sources:
|
||||
the defaults for the Go toolchain used to build the program,
|
||||
amended to match the Go version listed in `go.mod`,
|
||||
and then overridden by explicit `//go:debug` lines in the program.
|
||||
|
||||
The [GODEBUG History](#history) gives the exact defaults for each Go toolchain version.
|
||||
For example, Go 1.21 introduces the `panicnil` setting,
|
||||
controlling whether `panic(nil)` is allowed;
|
||||
it defaults to `panicnil=0`, making `panic(nil)` a run-time error.
|
||||
Using `panicnil=1` restores the behavior of Go 1.20 and earlier.
|
||||
|
||||
When compiling a work module or workspace that declares
|
||||
an older Go version, the Go toolchain amends its defaults
|
||||
to match that older Go version as closely as possible.
|
||||
For example, when a Go 1.21 toolchain compiles a program,
|
||||
if the work module's `go.mod` or the workspace's `go.work`
|
||||
says `go` `1.20`, then the program defaults to `panicnil=1`,
|
||||
matching Go 1.20 instead of Go 1.21.
|
||||
|
||||
Because this method of setting GODEBUG defaults was introduced only in Go 1.21,
|
||||
programs listing versions of Go earlier than Go 1.20 are configured to match Go 1.20,
|
||||
not the older version.
|
||||
|
||||
To override these defaults, a main package's source files
|
||||
can include one or more `//go:debug` directives at the top of the file
|
||||
(preceding the `package` statement).
|
||||
Continuing the `panicnil` example, if the module or workspace is updated
|
||||
to say `go` `1.21`, the program can opt back into the old `panic(nil)`
|
||||
behavior by including this directive:
|
||||
|
||||
//go:debug panicnil=1
|
||||
|
||||
Starting in Go 1.21, the Go toolchain treats a `//go:debug` directive
|
||||
with an unrecognized GODEBUG setting as an invalid program.
|
||||
Programs with more than one `//go:debug` line for a given setting
|
||||
are also treated as invalid.
|
||||
(Older toolchains ignore `//go:debug` directives entirely.)
|
||||
|
||||
The defaults that will be compiled into a main package
|
||||
are reported by the command:
|
||||
|
||||
{{raw `
|
||||
go list -f '{{.DefaultGODEBUG}}' my/main/package
|
||||
`}}
|
||||
|
||||
Only differences from the base Go toolchain defaults are reported.
|
||||
|
||||
When testing a package, `//go:debug` lines in the `*_test.go`
|
||||
files are treated as directives for the test's main package.
|
||||
In any other context, `//go:debug` lines are ignored by the toolchain;
|
||||
`go` `vet` reports such lines as misplaced.
|
||||
|
||||
## GODEBUG History {#history}
|
||||
|
||||
This section documents the GODEBUG settings introduced and removed in each major Go release
|
||||
for compatibility reasons.
|
||||
Packages or programs may define additional settings for internal debugging purposes;
|
||||
for example,
|
||||
see the [runtime documentation](/pkg/runtime#hdr-Environment_Variables)
|
||||
and the [go command documentation](/cmd/go#hdr-Build_and_test_caching).
|
||||
|
||||
### Go 1.21
|
||||
|
||||
Go 1.21 made it a run-time error to call `panic` with a nil interface value,
|
||||
controlled by the [`panicnil` setting](/pkg/builtin/#panic).
|
||||
|
||||
Go 1.21 made it an error for html/template actions to appear inside of an ECMAScript 6
|
||||
template literal, controlled by the
|
||||
[`jstmpllitinterp` setting](/pkg/html/template#hdr-Security_Model).
|
||||
This behavior was backported to Go 1.19.8+ and Go 1.20.3+.
|
||||
|
||||
Go 1.21 introduced a limit on the maximum number of MIME headers and multipart
|
||||
forms, controlled by the
|
||||
[`multipartmaxheaders` and `multipartmaxparts` settings](/pkg/mime/multipart#hdr-Limits)
|
||||
respectively.
|
||||
This behavior was backported to Go 1.19.8+ and Go 1.20.3+.
|
||||
|
||||
There is no plan to remove any of these settings.
|
||||
|
||||
### Go 1.20
|
||||
|
||||
Go 1.20 introduced support for rejecting insecure paths in tar and zip archives,
|
||||
controlled by the [`tarinsecurepath` setting](/pkg/archive/tar/#Reader.Next)
|
||||
and the [`zipinsecurepath` setting](/pkg/archive/zip/#NewReader).
|
||||
These default to `tarinsecurepath=1` and `zipinsecurepath=1`,
|
||||
preserving the behavior of earlier versions of Go.
|
||||
A future version of Go may change the defaults to
|
||||
`tarinsecurepath=0` and `zipinsecurepath=0`.
|
||||
|
||||
Go 1.20 introduced automatic seeding of the
|
||||
[`math/rand`](/pkg/math/rand) global random number generator,
|
||||
controlled by the [`randautoseed` setting](/pkg/math/rand/#Seed).
|
||||
|
||||
Go 1.20 introduced the concept of fallback roots for use during certificate verification,
|
||||
controlled by the [`x509usefallbackroots` setting](/pkg/crypto/x509/#SetFallbackRoots).
|
||||
|
||||
Go 1.20 removed the preinstalled `.a` files for the standard library
|
||||
from the Go distribution.
|
||||
Installations now build and cache the standard library like
|
||||
packages in other modules.
|
||||
The [`installgoroot` setting](/cmd/go#hdr-Compile_and_install_packages_and_dependencies)
|
||||
restores the installation and use of preinstalled `.a` files.
|
||||
|
||||
There is no plan to remove any of these settings.
|
||||
|
||||
### Go 1.19
|
||||
|
||||
Go 1.19 made it an error for path lookups to resolve to binaries in the current directory,
|
||||
controlled by the [`execerrdot` setting](/pkg/os/exec#hdr-Executables_in_the_current_directory).
|
||||
There is no plan to remove this setting.
|
||||
|
||||
### Go 1.18
|
||||
|
||||
Go 1.18 removed support for SHA1 in most X.509 certificates,
|
||||
controlled by the [`x509sha1` setting](/crypto/x509#InsecureAlgorithmError).
|
||||
This setting will be removed in a future release, Go 1.22 at the earliest.
|
||||
|
||||
### Go 1.10
|
||||
|
||||
Go 1.10 changed how build caching worked and added test caching, along
|
||||
with the [`gocacheverify`, `gocachehash`, and `gocachetest` settings](/cmd/go/#hdr-Build_and_test_caching).
|
||||
There is no plan to remove these settings.
|
||||
|
||||
### Go 1.6
|
||||
|
||||
Go 1.6 introduced transparent support for HTTP/2,
|
||||
controlled by the [`http2client`, `http2server`, and `http2debug` settings](/pkg/net/http/#hdr-HTTP_2).
|
||||
There is no plan to remove these settings.
|
||||
|
||||
### Go 1.5
|
||||
|
||||
Go 1.5 introduced a pure Go DNS resolver,
|
||||
controlled by the [`netdns` setting](/pkg/net/#hdr-Name_Resolution).
|
||||
There is no plan to remove this setting.
|
||||
12
go.env
12
go.env
@@ -1,12 +0,0 @@
|
||||
# This file contains the initial defaults for go command configuration.
|
||||
# Values set by 'go env -w' and written to the user's go/env file override these.
|
||||
# The environment overrides everything else.
|
||||
|
||||
# Use the Go module mirror and checksum database by default.
|
||||
# See https://proxy.golang.org for details.
|
||||
GOPROXY=https://proxy.golang.org,direct
|
||||
GOSUMDB=sum.golang.org
|
||||
|
||||
# Automatically download newer toolchains as directed by go.mod files.
|
||||
# See https://go.dev/doc/toolchain for details.
|
||||
GOTOOLCHAIN=auto
|
||||
@@ -24,8 +24,8 @@
|
||||
# in the CL match the update.bash in the CL.
|
||||
|
||||
# Versions to use.
|
||||
CODE=2023c
|
||||
DATA=2023c
|
||||
CODE=2022g
|
||||
DATA=2022g
|
||||
|
||||
set -e
|
||||
|
||||
@@ -48,8 +48,9 @@ fi
|
||||
cd zoneinfo
|
||||
../mkzip ../../zoneinfo.zip
|
||||
cd ../..
|
||||
go generate time/tzdata
|
||||
|
||||
files="update.bash zoneinfo.zip"
|
||||
files="update.bash zoneinfo.zip ../../src/time/tzdata/zipdata.go"
|
||||
modified=true
|
||||
if git diff --quiet $files; then
|
||||
modified=false
|
||||
|
||||
Binary file not shown.
340
misc/android/go_android_exec.go
Normal file
340
misc/android/go_android_exec.go
Normal file
@@ -0,0 +1,340 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
// This program can be used as go_android_GOARCH_exec by the Go tool.
|
||||
// It executes binaries on an android device using adb.
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"go/build"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func run(args ...string) (string, error) {
|
||||
cmd := adbCmd(args...)
|
||||
buf := new(strings.Builder)
|
||||
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}
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("adb %s: %v", strings.Join(args, " "), err)
|
||||
}
|
||||
return buf.String(), nil
|
||||
}
|
||||
|
||||
func adb(args ...string) error {
|
||||
if out, err := adbCmd(args...).CombinedOutput(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "adb %s\n%s", strings.Join(args, " "), out)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func adbCmd(args ...string) *exec.Cmd {
|
||||
if flags := os.Getenv("GOANDROID_ADB_FLAGS"); flags != "" {
|
||||
args = append(strings.Split(flags, " "), args...)
|
||||
}
|
||||
return exec.Command("adb", args...)
|
||||
}
|
||||
|
||||
const (
|
||||
deviceRoot = "/data/local/tmp/go_android_exec"
|
||||
deviceGoroot = deviceRoot + "/goroot"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.SetFlags(0)
|
||||
log.SetPrefix("go_android_exec: ")
|
||||
exitCode, err := runMain()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
os.Exit(exitCode)
|
||||
}
|
||||
|
||||
func runMain() (int, error) {
|
||||
// Concurrent use of adb is flaky, so serialize adb commands.
|
||||
// See https://github.com/golang/go/issues/23795 or
|
||||
// https://issuetracker.google.com/issues/73230216.
|
||||
lockPath := filepath.Join(os.TempDir(), "go_android_exec-adb-lock")
|
||||
lock, err := os.OpenFile(lockPath, os.O_CREATE|os.O_RDWR, 0666)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer lock.Close()
|
||||
if err := syscall.Flock(int(lock.Fd()), syscall.LOCK_EX); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// In case we're booting a device or emulator alongside all.bash, wait for
|
||||
// it to be ready. adb wait-for-device is not enough, we have to
|
||||
// wait for sys.boot_completed.
|
||||
if err := adb("wait-for-device", "exec-out", "while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;"); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Done once per make.bash.
|
||||
if err := adbCopyGoroot(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Prepare a temporary directory that will be cleaned up at the end.
|
||||
// Binary names can conflict.
|
||||
// E.g. template.test from the {html,text}/template packages.
|
||||
binName := filepath.Base(os.Args[1])
|
||||
deviceGotmp := fmt.Sprintf(deviceRoot+"/%s-%d", binName, os.Getpid())
|
||||
deviceGopath := deviceGotmp + "/gopath"
|
||||
defer adb("exec-out", "rm", "-rf", deviceGotmp) // Clean up.
|
||||
|
||||
// Determine the package by examining the current working
|
||||
// directory, which will look something like
|
||||
// "$GOROOT/src/mime/multipart" or "$GOPATH/src/golang.org/x/mobile".
|
||||
// We extract everything after the $GOROOT or $GOPATH to run on the
|
||||
// same relative directory on the target device.
|
||||
subdir, inGoRoot, err := subdir()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
deviceCwd := filepath.Join(deviceGopath, subdir)
|
||||
if inGoRoot {
|
||||
deviceCwd = filepath.Join(deviceGoroot, subdir)
|
||||
} else {
|
||||
if err := adb("exec-out", "mkdir", "-p", deviceCwd); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if err := adbCopyTree(deviceCwd, subdir); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Copy .go files from the package.
|
||||
goFiles, err := filepath.Glob("*.go")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if len(goFiles) > 0 {
|
||||
args := append(append([]string{"push"}, goFiles...), deviceCwd)
|
||||
if err := adb(args...); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deviceBin := fmt.Sprintf("%s/%s", deviceGotmp, binName)
|
||||
if err := adb("push", os.Args[1], deviceBin); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Forward SIGQUIT from the go command to show backtraces from
|
||||
// the binary instead of from this wrapper.
|
||||
quit := make(chan os.Signal, 1)
|
||||
signal.Notify(quit, syscall.SIGQUIT)
|
||||
go func() {
|
||||
for range quit {
|
||||
// We don't have the PID of the running process; use the
|
||||
// binary name instead.
|
||||
adb("exec-out", "killall -QUIT "+binName)
|
||||
}
|
||||
}()
|
||||
// In light of
|
||||
// https://code.google.com/p/android/issues/detail?id=3254
|
||||
// dont trust the exitcode of adb. Instead, append the exitcode to
|
||||
// the output and parse it from there.
|
||||
const exitstr = "exitcode="
|
||||
cmd := `export TMPDIR="` + deviceGotmp + `"` +
|
||||
`; export GOROOT="` + deviceGoroot + `"` +
|
||||
`; export GOPATH="` + deviceGopath + `"` +
|
||||
`; export CGO_ENABLED=0` +
|
||||
`; export GOPROXY=` + os.Getenv("GOPROXY") +
|
||||
`; export GOCACHE="` + deviceRoot + `/gocache"` +
|
||||
`; export PATH=$PATH:"` + deviceGoroot + `/bin"` +
|
||||
`; cd "` + deviceCwd + `"` +
|
||||
"; '" + deviceBin + "' " + strings.Join(os.Args[2:], " ") +
|
||||
"; echo -n " + exitstr + "$?"
|
||||
output, err := run("exec-out", cmd)
|
||||
signal.Reset(syscall.SIGQUIT)
|
||||
close(quit)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
exitIdx := strings.LastIndex(output, exitstr)
|
||||
if exitIdx == -1 {
|
||||
return 0, fmt.Errorf("no exit code: %q", output)
|
||||
}
|
||||
code, err := strconv.Atoi(output[exitIdx+len(exitstr):])
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("bad exit code: %v", err)
|
||||
}
|
||||
return code, nil
|
||||
}
|
||||
|
||||
// subdir determines the package based on the current working directory,
|
||||
// and returns the path to the package source relative to $GOROOT (or $GOPATH).
|
||||
func subdir() (pkgpath string, underGoRoot bool, err error) {
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return "", false, err
|
||||
}
|
||||
cwd, err = filepath.EvalSymlinks(cwd)
|
||||
if err != nil {
|
||||
return "", false, err
|
||||
}
|
||||
goroot, err := filepath.EvalSymlinks(runtime.GOROOT())
|
||||
if err != nil {
|
||||
return "", false, err
|
||||
}
|
||||
if subdir, err := filepath.Rel(goroot, cwd); err == nil {
|
||||
if !strings.Contains(subdir, "..") {
|
||||
return subdir, true, nil
|
||||
}
|
||||
}
|
||||
|
||||
for _, p := range filepath.SplitList(build.Default.GOPATH) {
|
||||
pabs, err := filepath.EvalSymlinks(p)
|
||||
if err != nil {
|
||||
return "", false, err
|
||||
}
|
||||
if subdir, err := filepath.Rel(pabs, cwd); err == nil {
|
||||
if !strings.Contains(subdir, "..") {
|
||||
return subdir, false, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return "", false, fmt.Errorf("the current path %q is not in either GOROOT(%q) or GOPATH(%q)",
|
||||
cwd, runtime.GOROOT(), build.Default.GOPATH)
|
||||
}
|
||||
|
||||
// adbCopyTree copies testdata, go.mod, go.sum files from subdir
|
||||
// and from parent directories all the way up to the root of subdir.
|
||||
// go.mod and go.sum files are needed for the go tool modules queries,
|
||||
// and the testdata directories for tests. It is common for tests to
|
||||
// reach out into testdata from parent packages.
|
||||
func adbCopyTree(deviceCwd, subdir string) error {
|
||||
dir := ""
|
||||
for {
|
||||
for _, path := range []string{"testdata", "go.mod", "go.sum"} {
|
||||
path := filepath.Join(dir, path)
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
continue
|
||||
}
|
||||
devicePath := filepath.Join(deviceCwd, dir)
|
||||
if err := adb("exec-out", "mkdir", "-p", devicePath); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := adb("push", path, devicePath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if subdir == "." {
|
||||
break
|
||||
}
|
||||
subdir = filepath.Dir(subdir)
|
||||
dir = filepath.Join(dir, "..")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// adbCopyGoroot clears deviceRoot for previous versions of GOROOT, GOPATH
|
||||
// and temporary data. Then, it copies relevant parts of GOROOT to the device,
|
||||
// including the go tool built for android.
|
||||
// A lock file ensures this only happens once, even with concurrent exec
|
||||
// wrappers.
|
||||
func adbCopyGoroot() error {
|
||||
// Also known by cmd/dist. The bootstrap command deletes the file.
|
||||
statPath := filepath.Join(os.TempDir(), "go_android_exec-adb-sync-status")
|
||||
stat, err := os.OpenFile(statPath, os.O_CREATE|os.O_RDWR, 0666)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer stat.Close()
|
||||
// Serialize check and copying.
|
||||
if err := syscall.Flock(int(stat.Fd()), syscall.LOCK_EX); err != nil {
|
||||
return err
|
||||
}
|
||||
s, err := io.ReadAll(stat)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if string(s) == "done" {
|
||||
return nil
|
||||
}
|
||||
// Delete GOROOT, GOPATH and any leftover test data.
|
||||
if err := adb("exec-out", "rm", "-rf", deviceRoot); err != nil {
|
||||
return err
|
||||
}
|
||||
deviceBin := filepath.Join(deviceGoroot, "bin")
|
||||
if err := adb("exec-out", "mkdir", "-p", deviceBin); err != nil {
|
||||
return err
|
||||
}
|
||||
goroot := runtime.GOROOT()
|
||||
// Build go for android.
|
||||
goCmd := filepath.Join(goroot, "bin", "go")
|
||||
tmpGo, err := os.CreateTemp("", "go_android_exec-cmd-go-*")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tmpGo.Close()
|
||||
defer os.Remove(tmpGo.Name())
|
||||
|
||||
if out, err := exec.Command(goCmd, "build", "-o", tmpGo.Name(), "cmd/go").CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("failed to build go tool for device: %s\n%v", out, err)
|
||||
}
|
||||
deviceGo := filepath.Join(deviceBin, "go")
|
||||
if err := adb("push", tmpGo.Name(), deviceGo); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, dir := range []string{"src", "test", "lib", "api"} {
|
||||
if err := adb("push", filepath.Join(goroot, dir), filepath.Join(deviceGoroot)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Copy only the relevant from pkg.
|
||||
if err := adb("exec-out", "mkdir", "-p", filepath.Join(deviceGoroot, "pkg", "tool")); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := adb("push", filepath.Join(goroot, "pkg", "include"), filepath.Join(deviceGoroot, "pkg")); err != nil {
|
||||
return err
|
||||
}
|
||||
runtimea, err := exec.Command(goCmd, "list", "-f", "{{.Target}}", "runtime").Output()
|
||||
pkgdir := filepath.Dir(string(runtimea))
|
||||
if pkgdir == "" {
|
||||
return errors.New("could not find android pkg dir")
|
||||
}
|
||||
if err := adb("push", pkgdir, filepath.Join(deviceGoroot, "pkg")); err != nil {
|
||||
return err
|
||||
}
|
||||
tooldir := filepath.Join(goroot, "pkg", "tool", filepath.Base(pkgdir))
|
||||
if err := adb("push", tooldir, filepath.Join(deviceGoroot, "pkg", "tool")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := stat.Write([]byte("done")); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
58
misc/arm/a
Executable file
58
misc/arm/a
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2010 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.
|
||||
|
||||
# This is a small script for executing go binaries on the android platform.
|
||||
#
|
||||
# example:
|
||||
# ./a 5.out foo bar baz
|
||||
#
|
||||
# The script exports the local values of GOARCH, GOTRACEBACK and GOGC
|
||||
# to the android environment.
|
||||
#
|
||||
# Known issues:
|
||||
# The script fails unless the last character output by the program is "\n"
|
||||
#
|
||||
# TODO(kaib): add gdb bridge support
|
||||
|
||||
exp ()
|
||||
{
|
||||
if [ ${!1} ]; then
|
||||
echo "export $1=\"${!1}\"; "
|
||||
fi
|
||||
}
|
||||
|
||||
# adb does not correctly return the exit value of the executed program. use this
|
||||
# wrapper to manually extract the exit value
|
||||
rloc=/data/local/tmp/retval
|
||||
rsize=$(adb shell "ls -l $rloc"|tr -s ' '|cut -d' ' -f4)
|
||||
rcheck=38
|
||||
if [ "$rsize" != "$rcheck" ]; then
|
||||
# echo "debug: retval size incorrect want $rcheck, got $rsize. uploading"
|
||||
echo >/tmp/adb.retval '#!/system/bin/sh
|
||||
"$@"
|
||||
echo RETVAL: $?'
|
||||
adb push /tmp/adb.retval $rloc >/dev/null 2>&1
|
||||
adb shell chmod 755 $rloc
|
||||
fi
|
||||
|
||||
# run the main binary
|
||||
if [ "-g" == "$1" ]; then
|
||||
adb forward tcp:$2 tcp:$2
|
||||
args=$(echo $*| cut -d' ' -f4-)
|
||||
adb push $3 /data/local/tmp/$3 >/dev/null 2>&1
|
||||
adb shell "$(exp GOARCH) $(exp GOTRACEBACK) $(exp GOGC) \
|
||||
gdbserver :$2 /data/local/tmp/retval /data/local/tmp/$3 $args" \
|
||||
2>&1|tr -d '\r' |tee /tmp/adb.out|grep -v RETVAL
|
||||
else
|
||||
if [ "$*" != "$1" ]; then
|
||||
args=$(echo $*| cut -d' ' -f2-)
|
||||
fi
|
||||
adb push $1 /data/local/tmp/$1 >/dev/null 2>&1
|
||||
adb shell "$(exp GOARCH) $(exp GOTRACEBACK) $(exp GOGC) \
|
||||
/data/local/tmp/retval /data/local/tmp/$1 $args" \
|
||||
2>&1|tr -d '\r' |tee /tmp/adb.out|grep -v RETVAL
|
||||
fi
|
||||
exit $(grep RETVAL /tmp/adb.out|tr -d '\n\r'| cut -d' ' -f2)
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"go/ast"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"internal/testenv"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -66,9 +65,6 @@ func (v *Visitor) Visit(node ast.Node) ast.Visitor {
|
||||
}
|
||||
|
||||
func TestArgumentsPositions(t *testing.T) {
|
||||
testenv.MustHaveCGO(t)
|
||||
testenv.MustHaveExec(t)
|
||||
|
||||
testdata, err := filepath.Abs("testdata")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -6,8 +6,6 @@ package errorstest
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"cmd/internal/quoted"
|
||||
"internal/testenv"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -41,9 +39,6 @@ func main() {
|
||||
`
|
||||
|
||||
func TestBadSymbol(t *testing.T) {
|
||||
testenv.MustHaveGoBuild(t)
|
||||
testenv.MustHaveCGO(t)
|
||||
|
||||
dir := t.TempDir()
|
||||
|
||||
mkdir := func(base string) string {
|
||||
@@ -172,14 +167,7 @@ func TestBadSymbol(t *testing.T) {
|
||||
}
|
||||
|
||||
func cCompilerCmd(t *testing.T) []string {
|
||||
cc, err := quoted.Split(goEnv(t, "CC"))
|
||||
if err != nil {
|
||||
t.Skipf("parsing go env CC: %s", err)
|
||||
}
|
||||
if len(cc) == 0 {
|
||||
t.Skipf("no C compiler")
|
||||
}
|
||||
testenv.MustHaveExecPath(t, cc[0])
|
||||
cc := []string{goEnv(t, "CC")}
|
||||
|
||||
out := goEnv(t, "GOGCCFLAGS")
|
||||
quote := '\000'
|
||||
@@ -7,7 +7,6 @@ package errorstest
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"internal/testenv"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -23,8 +22,6 @@ func path(file string) string {
|
||||
|
||||
func check(t *testing.T, file string) {
|
||||
t.Run(file, func(t *testing.T) {
|
||||
testenv.MustHaveGoBuild(t)
|
||||
testenv.MustHaveCGO(t)
|
||||
t.Parallel()
|
||||
|
||||
contents, err := os.ReadFile(path(file))
|
||||
@@ -39,16 +36,23 @@ func check(t *testing.T, file string) {
|
||||
continue
|
||||
}
|
||||
|
||||
_, frag, ok := bytes.Cut(line, []byte("ERROR HERE: "))
|
||||
if !ok {
|
||||
continue
|
||||
if _, frag, ok := bytes.Cut(line, []byte("ERROR HERE: ")); ok {
|
||||
re, err := regexp.Compile(fmt.Sprintf(":%d:.*%s", i+1, frag))
|
||||
if err != nil {
|
||||
t.Errorf("Invalid regexp after `ERROR HERE: `: %#q", frag)
|
||||
continue
|
||||
}
|
||||
errors = append(errors, re)
|
||||
}
|
||||
re, err := regexp.Compile(fmt.Sprintf(":%d:.*%s", i+1, frag))
|
||||
if err != nil {
|
||||
t.Errorf("Invalid regexp after `ERROR HERE: `: %#q", frag)
|
||||
continue
|
||||
|
||||
if _, frag, ok := bytes.Cut(line, []byte("ERROR MESSAGE: ")); ok {
|
||||
re, err := regexp.Compile(string(frag))
|
||||
if err != nil {
|
||||
t.Errorf("Invalid regexp after `ERROR MESSAGE: `: %#q", frag)
|
||||
continue
|
||||
}
|
||||
errors = append(errors, re)
|
||||
}
|
||||
errors = append(errors, re)
|
||||
}
|
||||
if len(errors) == 0 {
|
||||
t.Fatalf("cannot find ERROR HERE")
|
||||
@@ -92,8 +96,6 @@ func expect(t *testing.T, file string, errors []*regexp.Regexp) {
|
||||
}
|
||||
|
||||
func sizeofLongDouble(t *testing.T) int {
|
||||
testenv.MustHaveGoRun(t)
|
||||
testenv.MustHaveCGO(t)
|
||||
cmd := exec.Command("go", "run", path("long_double_size.go"))
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
@@ -111,6 +113,7 @@ func TestReportsTypeErrors(t *testing.T) {
|
||||
for _, file := range []string{
|
||||
"err1.go",
|
||||
"err2.go",
|
||||
"err5.go",
|
||||
"issue11097a.go",
|
||||
"issue11097b.go",
|
||||
"issue18452.go",
|
||||
@@ -139,8 +142,6 @@ func TestToleratesOptimizationFlag(t *testing.T) {
|
||||
} {
|
||||
cflags := cflags
|
||||
t.Run(cflags, func(t *testing.T) {
|
||||
testenv.MustHaveGoBuild(t)
|
||||
testenv.MustHaveCGO(t)
|
||||
t.Parallel()
|
||||
|
||||
cmd := exec.Command("go", "build", path("issue14669.go"))
|
||||
@@ -154,8 +155,6 @@ func TestToleratesOptimizationFlag(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMallocCrashesOnNil(t *testing.T) {
|
||||
testenv.MustHaveCGO(t)
|
||||
testenv.MustHaveGoRun(t)
|
||||
t.Parallel()
|
||||
|
||||
cmd := exec.Command("go", "run", path("malloc.go"))
|
||||
@@ -10,12 +10,9 @@ import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"internal/testenv"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
@@ -164,17 +161,6 @@ var ptrTests = []ptrTest{
|
||||
fail: true,
|
||||
expensive: true,
|
||||
},
|
||||
{
|
||||
// Storing a pinned Go pointer into C memory should succeed.
|
||||
name: "barrierpinnedok",
|
||||
c: `#include <stdlib.h>
|
||||
char **f14a2() { return malloc(sizeof(char*)); }
|
||||
void f14b2(char **p) {}`,
|
||||
imports: []string{"runtime"},
|
||||
body: `var pinr runtime.Pinner; p := C.f14a2(); x := new(C.char); pinr.Pin(x); *p = x; C.f14b2(p); pinr.Unpin()`,
|
||||
fail: false,
|
||||
expensive: true,
|
||||
},
|
||||
{
|
||||
// Storing a Go pointer into C memory by assigning a
|
||||
// large value should fail.
|
||||
@@ -445,54 +431,10 @@ var ptrTests = []ptrTest{
|
||||
body: `s := &S40{p: new(int)}; C.f40((*C.struct_S40i)(&s.a))`,
|
||||
fail: false,
|
||||
},
|
||||
{
|
||||
// Test that we handle unsafe.StringData.
|
||||
name: "stringdata",
|
||||
c: `void f41(void* p) {}`,
|
||||
imports: []string{"unsafe"},
|
||||
body: `s := struct { a [4]byte; p *int }{p: new(int)}; str := unsafe.String(&s.a[0], 4); C.f41(unsafe.Pointer(unsafe.StringData(str)))`,
|
||||
fail: false,
|
||||
},
|
||||
{
|
||||
name: "slicedata",
|
||||
c: `void f42(void* p) {}`,
|
||||
imports: []string{"unsafe"},
|
||||
body: `s := []*byte{nil, new(byte)}; C.f42(unsafe.Pointer(unsafe.SliceData(s)))`,
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
name: "slicedata2",
|
||||
c: `void f43(void* p) {}`,
|
||||
imports: []string{"unsafe"},
|
||||
body: `s := struct { a [4]byte; p *int }{p: new(int)}; C.f43(unsafe.Pointer(unsafe.SliceData(s.a[:])))`,
|
||||
fail: false,
|
||||
},
|
||||
}
|
||||
|
||||
func TestPointerChecks(t *testing.T) {
|
||||
testenv.MustHaveGoBuild(t)
|
||||
testenv.MustHaveCGO(t)
|
||||
if runtime.GOOS == "windows" {
|
||||
// TODO: Skip just the cases that fail?
|
||||
t.Skipf("some tests fail to build on %s", runtime.GOOS)
|
||||
}
|
||||
|
||||
var gopath string
|
||||
var dir string
|
||||
if *tmp != "" {
|
||||
gopath = *tmp
|
||||
dir = ""
|
||||
} else {
|
||||
d, err := os.MkdirTemp("", filepath.Base(t.Name()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
dir = d
|
||||
gopath = d
|
||||
}
|
||||
|
||||
exe := buildPtrTests(t, gopath, false)
|
||||
exe2 := buildPtrTests(t, gopath, true)
|
||||
dir, exe := buildPtrTests(t)
|
||||
|
||||
// We (TestPointerChecks) return before the parallel subtest functions do,
|
||||
// so we can't just defer os.RemoveAll(dir). Instead we have to wait for
|
||||
@@ -509,18 +451,30 @@ func TestPointerChecks(t *testing.T) {
|
||||
os.RemoveAll(dir)
|
||||
}
|
||||
}()
|
||||
testOne(t, pt, exe, exe2)
|
||||
testOne(t, pt, exe)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func buildPtrTests(t *testing.T, gopath string, cgocheck2 bool) (exe string) {
|
||||
func buildPtrTests(t *testing.T) (dir, exe string) {
|
||||
var gopath string
|
||||
if *tmp != "" {
|
||||
gopath = *tmp
|
||||
dir = ""
|
||||
} else {
|
||||
d, err := os.MkdirTemp("", filepath.Base(t.Name()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
dir = d
|
||||
gopath = d
|
||||
}
|
||||
|
||||
src := filepath.Join(gopath, "src", "ptrtest")
|
||||
if err := os.MkdirAll(src, 0777); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(src, "go.mod"), []byte("module ptrtest\ngo 1.20"), 0666); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(src, "go.mod"), []byte("module ptrtest"), 0666); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -587,38 +541,15 @@ func buildPtrTests(t *testing.T, gopath string, cgocheck2 bool) (exe string) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
exeName := "ptrtest.exe"
|
||||
if cgocheck2 {
|
||||
exeName = "ptrtest2.exe"
|
||||
}
|
||||
cmd := exec.Command("go", "build", "-o", exeName)
|
||||
cmd := exec.Command("go", "build", "-o", "ptrtest.exe")
|
||||
cmd.Dir = src
|
||||
cmd.Env = append(os.Environ(), "GOPATH="+gopath)
|
||||
|
||||
// Set or remove cgocheck2 from the environment.
|
||||
goexperiment := strings.Split(os.Getenv("GOEXPERIMENT"), ",")
|
||||
if len(goexperiment) == 1 && goexperiment[0] == "" {
|
||||
goexperiment = nil
|
||||
}
|
||||
i := slices.Index(goexperiment, "cgocheck2")
|
||||
changed := false
|
||||
if cgocheck2 && i < 0 {
|
||||
goexperiment = append(goexperiment, "cgocheck2")
|
||||
changed = true
|
||||
} else if !cgocheck2 && i >= 0 {
|
||||
goexperiment = append(goexperiment[:i], goexperiment[i+1:]...)
|
||||
changed = true
|
||||
}
|
||||
if changed {
|
||||
cmd.Env = append(cmd.Env, "GOEXPERIMENT="+strings.Join(goexperiment, ","))
|
||||
}
|
||||
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("go build: %v\n%s", err, out)
|
||||
}
|
||||
|
||||
return filepath.Join(src, exeName)
|
||||
return dir, filepath.Join(src, "ptrtest.exe")
|
||||
}
|
||||
|
||||
const ptrTestMain = `
|
||||
@@ -635,7 +566,7 @@ func main() {
|
||||
|
||||
var csem = make(chan bool, 16)
|
||||
|
||||
func testOne(t *testing.T, pt ptrTest, exe, exe2 string) {
|
||||
func testOne(t *testing.T, pt ptrTest, exe string) {
|
||||
t.Parallel()
|
||||
|
||||
// Run the tests in parallel, but don't run too many
|
||||
@@ -643,12 +574,7 @@ func testOne(t *testing.T, pt ptrTest, exe, exe2 string) {
|
||||
runcmd := func(cgocheck string) ([]byte, error) {
|
||||
csem <- true
|
||||
defer func() { <-csem }()
|
||||
x := exe
|
||||
if cgocheck == "2" {
|
||||
x = exe2
|
||||
cgocheck = "1"
|
||||
}
|
||||
cmd := exec.Command(x, pt.name)
|
||||
cmd := exec.Command(exe, pt.name)
|
||||
cmd.Env = append(os.Environ(), "GODEBUG=cgocheck="+cgocheck)
|
||||
return cmd.CombinedOutput()
|
||||
}
|
||||
@@ -4,11 +4,8 @@
|
||||
|
||||
package main
|
||||
|
||||
import "runtime"
|
||||
|
||||
import "C"
|
||||
//line /tmp/_cgo_.go:1
|
||||
//go:cgo_dynamic_linker "/elf/interp"
|
||||
// ERROR MESSAGE: only allowed in cgo-generated code
|
||||
|
||||
func main() {}
|
||||
|
||||
//export GoF
|
||||
func GoF() { runtime.GC() }
|
||||
@@ -6,7 +6,6 @@ package fortran
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"internal/testenv"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -16,9 +15,6 @@ import (
|
||||
)
|
||||
|
||||
func TestFortran(t *testing.T) {
|
||||
testenv.MustHaveGoRun(t)
|
||||
testenv.MustHaveCGO(t)
|
||||
|
||||
// Find the FORTRAN compiler.
|
||||
fc := os.Getenv("FC")
|
||||
if fc == "" {
|
||||
@@ -67,7 +63,7 @@ func TestFortran(t *testing.T) {
|
||||
}
|
||||
|
||||
// Do a test build that doesn't involve Go FORTRAN support.
|
||||
fcArgs := append([]string{"testdata/helloworld/helloworld.f90", "-o", "/dev/null"}, fcExtra...)
|
||||
fcArgs := append([]string{"helloworld/helloworld.f90", "-o", "/dev/null"}, fcExtra...)
|
||||
t.Logf("%s %s", fc, fcArgs)
|
||||
if err := exec.Command(fc, fcArgs...).Run(); err != nil {
|
||||
t.Skipf("skipping Fortran test: could not build helloworld.f90 with %s: %s", fc, err)
|
||||
@@ -3,6 +3,7 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
// Compute Fibonacci numbers with two goroutines
|
||||
// that pass integers back and forth. No actual
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
|
||||
@@ -6,12 +6,11 @@ package life_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"cmd/cgo/internal/cgotest"
|
||||
"internal/testenv"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -31,7 +30,7 @@ func testMain(m *testing.M) int {
|
||||
// Copy testdata into GOPATH/src/cgolife, along with a go.mod file
|
||||
// declaring the same path.
|
||||
modRoot := filepath.Join(GOPATH, "src", "cgolife")
|
||||
if err := cgotest.OverlayDir(modRoot, "testdata"); err != nil {
|
||||
if err := overlayDir(modRoot, "testdata"); err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
if err := os.Chdir(modRoot); err != nil {
|
||||
@@ -45,21 +44,20 @@ func testMain(m *testing.M) int {
|
||||
return m.Run()
|
||||
}
|
||||
|
||||
// TestTestRun runs a test case for cgo //export.
|
||||
func TestTestRun(t *testing.T) {
|
||||
testenv.MustHaveGoRun(t)
|
||||
testenv.MustHaveCGO(t)
|
||||
if os.Getenv("GOOS") == "android" {
|
||||
t.Skip("the go tool runs with CGO_ENABLED=0 on the android device")
|
||||
}
|
||||
out, err := exec.Command("go", "env", "GOROOT").Output()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
GOROOT := string(bytes.TrimSpace(out))
|
||||
|
||||
cmd := exec.Command("go", "run", "main.go")
|
||||
got, err := cmd.CombinedOutput()
|
||||
cmd := exec.Command("go", "run", filepath.Join(GOROOT, "test", "run.go"), "-", ".")
|
||||
out, err = cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("%v: %s\n%s", cmd, err, got)
|
||||
}
|
||||
want, err := os.ReadFile("main.out")
|
||||
if err != nil {
|
||||
t.Fatal("reading golden output:", err)
|
||||
}
|
||||
if !bytes.Equal(got, want) {
|
||||
t.Errorf("'%v' output does not match expected in main.out. Instead saw:\n%s", cmd, got)
|
||||
t.Fatalf("%s: %s\n%s", strings.Join(cmd.Args, " "), err, out)
|
||||
}
|
||||
t.Logf("%s:\n%s", strings.Join(cmd.Args, " "), out)
|
||||
}
|
||||
78
misc/cgo/life/overlaydir_test.go
Normal file
78
misc/cgo/life/overlaydir_test.go
Normal file
@@ -0,0 +1,78 @@
|
||||
// Copyright 2019 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 life_test
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// overlayDir makes a minimal-overhead copy of srcRoot in which new files may be added.
|
||||
//
|
||||
// TODO: Once we no longer need to support the misc module in GOPATH mode,
|
||||
// factor this function out into a package to reduce duplication.
|
||||
func overlayDir(dstRoot, srcRoot string) error {
|
||||
dstRoot = filepath.Clean(dstRoot)
|
||||
if err := os.MkdirAll(dstRoot, 0777); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
srcRoot, err := filepath.Abs(srcRoot)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return filepath.Walk(srcRoot, func(srcPath string, info os.FileInfo, err error) error {
|
||||
if err != nil || srcPath == srcRoot {
|
||||
return err
|
||||
}
|
||||
|
||||
suffix := strings.TrimPrefix(srcPath, srcRoot)
|
||||
for len(suffix) > 0 && suffix[0] == filepath.Separator {
|
||||
suffix = suffix[1:]
|
||||
}
|
||||
dstPath := filepath.Join(dstRoot, suffix)
|
||||
|
||||
perm := info.Mode() & os.ModePerm
|
||||
if info.Mode()&os.ModeSymlink != 0 {
|
||||
info, err = os.Stat(srcPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
perm = info.Mode() & os.ModePerm
|
||||
}
|
||||
|
||||
// Always copy directories (don't symlink them).
|
||||
// If we add a file in the overlay, we don't want to add it in the original.
|
||||
if info.IsDir() {
|
||||
return os.MkdirAll(dstPath, perm|0200)
|
||||
}
|
||||
|
||||
// If the OS supports symlinks, use them instead of copying bytes.
|
||||
if err := os.Symlink(srcPath, dstPath); err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Otherwise, copy the bytes.
|
||||
src, err := os.Open(srcPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer src.Close()
|
||||
|
||||
dst, err := os.OpenFile(dstPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, perm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = io.Copy(dst, src)
|
||||
if closeErr := dst.Close(); err == nil {
|
||||
err = closeErr
|
||||
}
|
||||
return err
|
||||
})
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// skip
|
||||
|
||||
// Copyright 2010 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.
|
||||
@@ -20,9 +22,8 @@ func Run(gen, x, y int, a []int32) {
|
||||
// Keep the channels visible from Go.
|
||||
var chans [4]chan bool
|
||||
|
||||
// Double return value is just for testing.
|
||||
//
|
||||
//export GoStart
|
||||
// Double return value is just for testing.
|
||||
func GoStart(i, xdim, ydim, xstart, xend, ystart, yend C.int, a *C.int, n *C.int) (int, int) {
|
||||
c := make(chan bool, int(C.MYCONST))
|
||||
go func() {
|
||||
@@ -1,8 +1,10 @@
|
||||
// run -tags=use_go_run
|
||||
|
||||
// Copyright 2010 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.
|
||||
|
||||
//go:build test_run
|
||||
// +build test_run
|
||||
|
||||
// Run the game of life in C using Go for parallelization.
|
||||
|
||||
78
misc/cgo/stdio/overlaydir_test.go
Normal file
78
misc/cgo/stdio/overlaydir_test.go
Normal file
@@ -0,0 +1,78 @@
|
||||
// Copyright 2019 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 stdio_test
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// overlayDir makes a minimal-overhead copy of srcRoot in which new files may be added.
|
||||
//
|
||||
// TODO: Once we no longer need to support the misc module in GOPATH mode,
|
||||
// factor this function out into a package to reduce duplication.
|
||||
func overlayDir(dstRoot, srcRoot string) error {
|
||||
dstRoot = filepath.Clean(dstRoot)
|
||||
if err := os.MkdirAll(dstRoot, 0777); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
srcRoot, err := filepath.Abs(srcRoot)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return filepath.Walk(srcRoot, func(srcPath string, info os.FileInfo, err error) error {
|
||||
if err != nil || srcPath == srcRoot {
|
||||
return err
|
||||
}
|
||||
|
||||
suffix := strings.TrimPrefix(srcPath, srcRoot)
|
||||
for len(suffix) > 0 && suffix[0] == filepath.Separator {
|
||||
suffix = suffix[1:]
|
||||
}
|
||||
dstPath := filepath.Join(dstRoot, suffix)
|
||||
|
||||
perm := info.Mode() & os.ModePerm
|
||||
if info.Mode()&os.ModeSymlink != 0 {
|
||||
info, err = os.Stat(srcPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
perm = info.Mode() & os.ModePerm
|
||||
}
|
||||
|
||||
// Always copy directories (don't symlink them).
|
||||
// If we add a file in the overlay, we don't want to add it in the original.
|
||||
if info.IsDir() {
|
||||
return os.MkdirAll(dstPath, perm|0200)
|
||||
}
|
||||
|
||||
// If the OS supports symlinks, use them instead of copying bytes.
|
||||
if err := os.Symlink(srcPath, dstPath); err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Otherwise, copy the bytes.
|
||||
src, err := os.Open(srcPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer src.Close()
|
||||
|
||||
dst, err := os.OpenFile(dstPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, perm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = io.Copy(dst, src)
|
||||
if closeErr := dst.Close(); err == nil {
|
||||
err = closeErr
|
||||
}
|
||||
return err
|
||||
})
|
||||
}
|
||||
@@ -6,8 +6,6 @@ package stdio_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"cmd/cgo/internal/cgotest"
|
||||
"internal/testenv"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -32,7 +30,7 @@ func testMain(m *testing.M) int {
|
||||
// Copy testdata into GOPATH/src/cgostdio, along with a go.mod file
|
||||
// declaring the same path.
|
||||
modRoot := filepath.Join(GOPATH, "src", "cgostdio")
|
||||
if err := cgotest.OverlayDir(modRoot, "testdata"); err != nil {
|
||||
if err := overlayDir(modRoot, "testdata"); err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
if err := os.Chdir(modRoot); err != nil {
|
||||
@@ -46,32 +44,20 @@ func testMain(m *testing.M) int {
|
||||
return m.Run()
|
||||
}
|
||||
|
||||
// TestTestRun runs a cgo test that doesn't depend on non-standard libraries.
|
||||
func TestTestRun(t *testing.T) {
|
||||
testenv.MustHaveGoRun(t)
|
||||
testenv.MustHaveCGO(t)
|
||||
|
||||
for _, file := range [...]string{
|
||||
"chain.go",
|
||||
"fib.go",
|
||||
"hello.go",
|
||||
} {
|
||||
file := file
|
||||
wantFile := strings.Replace(file, ".go", ".out", 1)
|
||||
t.Run(file, func(t *testing.T) {
|
||||
cmd := exec.Command("go", "run", file)
|
||||
got, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("%v: %s\n%s", cmd, err, got)
|
||||
}
|
||||
got = bytes.ReplaceAll(got, []byte("\r\n"), []byte("\n"))
|
||||
want, err := os.ReadFile(wantFile)
|
||||
if err != nil {
|
||||
t.Fatal("reading golden output:", err)
|
||||
}
|
||||
if !bytes.Equal(got, want) {
|
||||
t.Errorf("'%v' output does not match expected in %s. Instead saw:\n%s", cmd, wantFile, got)
|
||||
}
|
||||
})
|
||||
if os.Getenv("GOOS") == "android" {
|
||||
t.Skip("subpackage stdio is not available on android")
|
||||
}
|
||||
out, err := exec.Command("go", "env", "GOROOT").Output()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
GOROOT := string(bytes.TrimSpace(out))
|
||||
|
||||
cmd := exec.Command("go", "run", filepath.Join(GOROOT, "test", "run.go"), "-", ".")
|
||||
out, err = cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %s\n%s", strings.Join(cmd.Args, " "), err, out)
|
||||
}
|
||||
t.Logf("%s:\n%s", strings.Join(cmd.Args, " "), out)
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
// run -tags=use_go_run
|
||||
|
||||
// Copyright 2009 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.
|
||||
|
||||
//go:build test_run
|
||||
// +build test_run
|
||||
|
||||
// Pass numbers along a chain of threads.
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
// run -tags=use_go_run
|
||||
|
||||
// Copyright 2009 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.
|
||||
|
||||
//go:build test_run
|
||||
// +build test_run
|
||||
|
||||
// Compute Fibonacci numbers with two goroutines
|
||||
// that pass integers back and forth. No actual
|
||||
@@ -1,8 +1,10 @@
|
||||
// run -tags=use_go_run
|
||||
|
||||
// Copyright 2009 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.
|
||||
|
||||
//go:build test_run
|
||||
// +build test_run
|
||||
|
||||
package main
|
||||
|
||||
150
misc/cgo/stdio/testdata/run.out
vendored
Normal file
150
misc/cgo/stdio/testdata/run.out
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
* hello
|
||||
hello, world
|
||||
* fib
|
||||
0
|
||||
1
|
||||
1
|
||||
2
|
||||
3
|
||||
5
|
||||
8
|
||||
13
|
||||
21
|
||||
34
|
||||
55
|
||||
89
|
||||
144
|
||||
233
|
||||
377
|
||||
610
|
||||
987
|
||||
1597
|
||||
2584
|
||||
4181
|
||||
6765
|
||||
10946
|
||||
17711
|
||||
28657
|
||||
46368
|
||||
75025
|
||||
121393
|
||||
196418
|
||||
317811
|
||||
514229
|
||||
832040
|
||||
1346269
|
||||
2178309
|
||||
3524578
|
||||
5702887
|
||||
9227465
|
||||
14930352
|
||||
24157817
|
||||
39088169
|
||||
63245986
|
||||
102334155
|
||||
165580141
|
||||
267914296
|
||||
433494437
|
||||
701408733
|
||||
1134903170
|
||||
1836311903
|
||||
2971215073
|
||||
4807526976
|
||||
7778742049
|
||||
12586269025
|
||||
20365011074
|
||||
32951280099
|
||||
53316291173
|
||||
86267571272
|
||||
139583862445
|
||||
225851433717
|
||||
365435296162
|
||||
591286729879
|
||||
956722026041
|
||||
1548008755920
|
||||
2504730781961
|
||||
4052739537881
|
||||
6557470319842
|
||||
10610209857723
|
||||
17167680177565
|
||||
27777890035288
|
||||
44945570212853
|
||||
72723460248141
|
||||
117669030460994
|
||||
190392490709135
|
||||
308061521170129
|
||||
498454011879264
|
||||
806515533049393
|
||||
1304969544928657
|
||||
2111485077978050
|
||||
3416454622906707
|
||||
5527939700884757
|
||||
8944394323791464
|
||||
14472334024676221
|
||||
23416728348467685
|
||||
37889062373143906
|
||||
61305790721611591
|
||||
99194853094755497
|
||||
160500643816367088
|
||||
259695496911122585
|
||||
420196140727489673
|
||||
679891637638612258
|
||||
1100087778366101931
|
||||
1779979416004714189
|
||||
2880067194370816120
|
||||
* chain
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
@@ -1,3 +1,5 @@
|
||||
// skip
|
||||
|
||||
// Copyright 2009 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.
|
||||
@@ -5,7 +7,7 @@
|
||||
/*
|
||||
A trivial example of wrapping a C library in Go.
|
||||
For a more complex example and explanation,
|
||||
see misc/cgo/gmp/gmp.go.
|
||||
see ../gmp/gmp.go.
|
||||
*/
|
||||
|
||||
package stdio
|
||||
@@ -1,3 +1,5 @@
|
||||
// skip
|
||||
|
||||
// Copyright 2009 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.
|
||||
@@ -211,7 +211,7 @@ func testCallbackCallers(t *testing.T) {
|
||||
}
|
||||
// In module mode, this package has a fully-qualified import path.
|
||||
// Remove it if present.
|
||||
fname = strings.TrimPrefix(fname, "cmd/cgo/internal/")
|
||||
fname = strings.TrimPrefix(fname, "misc/cgo/")
|
||||
|
||||
namei := ""
|
||||
if i < len(name) {
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build gc
|
||||
// +build gc
|
||||
|
||||
#include "_cgo_export.h"
|
||||
#include <stdint.h>
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build gccgo
|
||||
// +build gccgo
|
||||
|
||||
#include "_cgo_export.h"
|
||||
#include <stdint.h>
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build cgo
|
||||
|
||||
package cgotest
|
||||
|
||||
import (
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build cgo
|
||||
|
||||
package cgotest
|
||||
|
||||
import "testing"
|
||||
@@ -106,7 +104,6 @@ func TestThreadLock(t *testing.T) { testThreadLockFunc(t) }
|
||||
func TestUnsignedInt(t *testing.T) { testUnsignedInt(t) }
|
||||
func TestZeroArgCallback(t *testing.T) { testZeroArgCallback(t) }
|
||||
|
||||
func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
|
||||
func BenchmarkGoString(b *testing.B) { benchGoString(b) }
|
||||
func BenchmarkCGoCallback(b *testing.B) { benchCallback(b) }
|
||||
func BenchmarkCGoInCThread(b *testing.B) { benchCGoInCthread(b) }
|
||||
func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
|
||||
func BenchmarkGoString(b *testing.B) { benchGoString(b) }
|
||||
func BenchmarkCGoCallback(b *testing.B) { benchCallback(b) }
|
||||
@@ -2,25 +2,22 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build linux
|
||||
//go:build linux && freebsd && openbsd
|
||||
// +build linux,freebsd,openbsd
|
||||
|
||||
package cgotest
|
||||
|
||||
/*
|
||||
#include <unistd.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/syscall.h>
|
||||
void Gosched(void);
|
||||
static bool Ctid(void) {
|
||||
long tid1 = syscall(SYS_gettid);
|
||||
Gosched();
|
||||
return tid1 == syscall(SYS_gettid);
|
||||
}
|
||||
static int Ctid(void) { Gosched(); return syscall(SYS_gettid); }
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -50,7 +47,7 @@ func testThreadLock(t *testing.T) {
|
||||
defer close(stop)
|
||||
|
||||
for i := 0; i < 1000; i++ {
|
||||
if !C.Ctid() {
|
||||
if C.int(syscall.Gettid()) != C.Ctid() {
|
||||
t.Fatalf("cgo has not locked OS thread")
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build cgo && !windows
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package cgotest
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
|
||||
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
#include <pthread.h>
|
||||
#include "_cgo_export.h"
|
||||
@@ -32,27 +32,3 @@ doAdd(int max, int nthread)
|
||||
for(i=0; i<nthread; i++)
|
||||
pthread_join(thread_id[i], 0);
|
||||
}
|
||||
|
||||
static void*
|
||||
goDummyCallbackThread(void* p)
|
||||
{
|
||||
int i, max;
|
||||
|
||||
max = *(int*)p;
|
||||
for(i=0; i<max; i++)
|
||||
goDummy();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
callGoInCThread(int max)
|
||||
{
|
||||
pthread_t thread;
|
||||
|
||||
if (pthread_create(&thread, NULL, goDummyCallbackThread, (void*)(&max)) != 0)
|
||||
return -1;
|
||||
if (pthread_join(thread, NULL) != 0)
|
||||
return -1;
|
||||
|
||||
return max;
|
||||
}
|
||||
@@ -35,25 +35,3 @@ doAdd(int max, int nthread)
|
||||
CloseHandle((HANDLE)thread_id[i]);
|
||||
}
|
||||
}
|
||||
|
||||
__stdcall
|
||||
static unsigned int
|
||||
goDummyCallbackThread(void* p)
|
||||
{
|
||||
int i, max;
|
||||
|
||||
max = *(int*)p;
|
||||
for(i=0; i<max; i++)
|
||||
goDummy();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
callGoInCThread(int max)
|
||||
{
|
||||
uintptr_t thread_id;
|
||||
thread_id = _beginthreadex(0, 0, goDummyCallbackThread, &max, 0, 0);
|
||||
WaitForSingleObject((HANDLE)thread_id, INFINITE);
|
||||
CloseHandle((HANDLE)thread_id);
|
||||
return max;
|
||||
}
|
||||
@@ -2,14 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build cgo
|
||||
|
||||
package cgotest
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cmd/cgo/internal/test/gcc68255"
|
||||
"misc/cgo/test/gcc68255"
|
||||
)
|
||||
|
||||
func testGCC68255(t *testing.T) {
|
||||
@@ -3,6 +3,7 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build linux && cgo
|
||||
// +build linux,cgo
|
||||
|
||||
package cgotest
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build cgo && !windows
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
// Issue 18146: pthread_create failure during syscall.Exec.
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build darwin && cgo && !internal
|
||||
// +build darwin,cgo,!internal
|
||||
|
||||
package cgotest
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !darwin || !cgo || internal
|
||||
// +build !darwin !cgo internal
|
||||
|
||||
package cgotest
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build cgo
|
||||
|
||||
// Test that we can have two identical cgo packages in a single binary.
|
||||
// No runtime test; just make sure it compiles.
|
||||
|
||||
package cgotest
|
||||
|
||||
import (
|
||||
_ "cmd/cgo/internal/test/issue23555a"
|
||||
_ "cmd/cgo/internal/test/issue23555b"
|
||||
_ "misc/cgo/test/issue23555a"
|
||||
_ "misc/cgo/test/issue23555b"
|
||||
)
|
||||
@@ -2,18 +2,16 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build cgo
|
||||
|
||||
package cgotest
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cmd/cgo/internal/test/issue24161arg"
|
||||
"cmd/cgo/internal/test/issue24161e0"
|
||||
"cmd/cgo/internal/test/issue24161e1"
|
||||
"cmd/cgo/internal/test/issue24161e2"
|
||||
"cmd/cgo/internal/test/issue24161res"
|
||||
"misc/cgo/test/issue24161arg"
|
||||
"misc/cgo/test/issue24161e0"
|
||||
"misc/cgo/test/issue24161e1"
|
||||
"misc/cgo/test/issue24161e2"
|
||||
"misc/cgo/test/issue24161res"
|
||||
)
|
||||
|
||||
func Test24161Arg(t *testing.T) {
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build darwin
|
||||
// +build darwin
|
||||
|
||||
package issue24161arg
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build darwin
|
||||
// +build darwin
|
||||
|
||||
package issue24161arg
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build darwin
|
||||
// +build darwin
|
||||
|
||||
package issue24161e0
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build darwin
|
||||
// +build darwin
|
||||
|
||||
package issue24161e1
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build darwin
|
||||
// +build darwin
|
||||
|
||||
package issue24161e2
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user