mirror of
https://github.com/golang/go.git
synced 2026-02-03 01:15:04 +03:00
Compare commits
2 Commits
go1.8beta1
...
dev.tls
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84eed51494 | ||
|
|
f55d0ab2c6 |
259
api/go1.8.txt
259
api/go1.8.txt
@@ -1,259 +0,0 @@
|
||||
pkg compress/gzip, const HuffmanOnly = -2
|
||||
pkg compress/gzip, const HuffmanOnly ideal-int
|
||||
pkg compress/zlib, const HuffmanOnly = -2
|
||||
pkg compress/zlib, const HuffmanOnly ideal-int
|
||||
pkg crypto/tls, const ECDSAWithP256AndSHA256 = 1027
|
||||
pkg crypto/tls, const ECDSAWithP256AndSHA256 SignatureScheme
|
||||
pkg crypto/tls, const ECDSAWithP384AndSHA384 = 1283
|
||||
pkg crypto/tls, const ECDSAWithP384AndSHA384 SignatureScheme
|
||||
pkg crypto/tls, const ECDSAWithP521AndSHA512 = 1539
|
||||
pkg crypto/tls, const ECDSAWithP521AndSHA512 SignatureScheme
|
||||
pkg crypto/tls, const PKCS1WithSHA1 = 513
|
||||
pkg crypto/tls, const PKCS1WithSHA1 SignatureScheme
|
||||
pkg crypto/tls, const PKCS1WithSHA256 = 1025
|
||||
pkg crypto/tls, const PKCS1WithSHA256 SignatureScheme
|
||||
pkg crypto/tls, const PKCS1WithSHA384 = 1281
|
||||
pkg crypto/tls, const PKCS1WithSHA384 SignatureScheme
|
||||
pkg crypto/tls, const PKCS1WithSHA512 = 1537
|
||||
pkg crypto/tls, const PKCS1WithSHA512 SignatureScheme
|
||||
pkg crypto/tls, const PSSWithSHA256 = 2052
|
||||
pkg crypto/tls, const PSSWithSHA256 SignatureScheme
|
||||
pkg crypto/tls, const PSSWithSHA384 = 2053
|
||||
pkg crypto/tls, const PSSWithSHA384 SignatureScheme
|
||||
pkg crypto/tls, const PSSWithSHA512 = 2054
|
||||
pkg crypto/tls, const PSSWithSHA512 SignatureScheme
|
||||
pkg crypto/tls, const TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 = 49187
|
||||
pkg crypto/tls, const TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 uint16
|
||||
pkg crypto/tls, const TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 = 52393
|
||||
pkg crypto/tls, const TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 uint16
|
||||
pkg crypto/tls, const TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 = 49191
|
||||
pkg crypto/tls, const TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 uint16
|
||||
pkg crypto/tls, const TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 = 52392
|
||||
pkg crypto/tls, const TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 uint16
|
||||
pkg crypto/tls, const TLS_RSA_WITH_AES_128_CBC_SHA256 = 60
|
||||
pkg crypto/tls, const TLS_RSA_WITH_AES_128_CBC_SHA256 uint16
|
||||
pkg crypto/tls, const X25519 = 29
|
||||
pkg crypto/tls, const X25519 CurveID
|
||||
pkg crypto/tls, method (*Config) Clone() *Config
|
||||
pkg crypto/tls, method (*Conn) CloseWrite() error
|
||||
pkg crypto/tls, type CertificateRequestInfo struct
|
||||
pkg crypto/tls, type CertificateRequestInfo struct, AcceptableCAs [][]uint8
|
||||
pkg crypto/tls, type CertificateRequestInfo struct, SignatureSchemes []SignatureScheme
|
||||
pkg crypto/tls, type ClientHelloInfo struct, Conn net.Conn
|
||||
pkg crypto/tls, type ClientHelloInfo struct, SignatureSchemes []SignatureScheme
|
||||
pkg crypto/tls, type ClientHelloInfo struct, SupportedProtos []string
|
||||
pkg crypto/tls, type ClientHelloInfo struct, SupportedVersions []uint16
|
||||
pkg crypto/tls, type Config struct, GetClientCertificate func(*CertificateRequestInfo) (*Certificate, error)
|
||||
pkg crypto/tls, type Config struct, GetConfigForClient func(*ClientHelloInfo) (*Config, error)
|
||||
pkg crypto/tls, type Config struct, KeyLogWriter io.Writer
|
||||
pkg crypto/tls, type Config struct, VerifyPeerCertificate func([][]uint8, [][]*x509.Certificate) error
|
||||
pkg crypto/tls, type SignatureScheme uint16
|
||||
pkg crypto/x509, const NameMismatch = 5
|
||||
pkg crypto/x509, const NameMismatch InvalidReason
|
||||
pkg crypto/x509, const SHA256WithRSAPSS = 13
|
||||
pkg crypto/x509, const SHA256WithRSAPSS SignatureAlgorithm
|
||||
pkg crypto/x509, const SHA384WithRSAPSS = 14
|
||||
pkg crypto/x509, const SHA384WithRSAPSS SignatureAlgorithm
|
||||
pkg crypto/x509, const SHA512WithRSAPSS = 15
|
||||
pkg crypto/x509, const SHA512WithRSAPSS SignatureAlgorithm
|
||||
pkg crypto/x509, type UnknownAuthorityError struct, Cert *Certificate
|
||||
pkg database/sql, const LevelDefault = 0
|
||||
pkg database/sql, const LevelDefault IsolationLevel
|
||||
pkg database/sql, const LevelLinearizable = 7
|
||||
pkg database/sql, const LevelLinearizable IsolationLevel
|
||||
pkg database/sql, const LevelReadCommitted = 2
|
||||
pkg database/sql, const LevelReadCommitted IsolationLevel
|
||||
pkg database/sql, const LevelReadUncommitted = 1
|
||||
pkg database/sql, const LevelReadUncommitted IsolationLevel
|
||||
pkg database/sql, const LevelRepeatableRead = 4
|
||||
pkg database/sql, const LevelRepeatableRead IsolationLevel
|
||||
pkg database/sql, const LevelSerializable = 6
|
||||
pkg database/sql, const LevelSerializable IsolationLevel
|
||||
pkg database/sql, const LevelSnapshot = 5
|
||||
pkg database/sql, const LevelSnapshot IsolationLevel
|
||||
pkg database/sql, const LevelWriteCommitted = 3
|
||||
pkg database/sql, const LevelWriteCommitted IsolationLevel
|
||||
pkg database/sql/driver, func IsolationFromContext(context.Context) (IsolationLevel, bool)
|
||||
pkg database/sql/driver, func ReadOnlyFromContext(context.Context) bool
|
||||
pkg database/sql/driver, type ConnBeginContext interface { BeginContext }
|
||||
pkg database/sql/driver, type ConnBeginContext interface, BeginContext(context.Context) (Tx, error)
|
||||
pkg database/sql/driver, type ConnPrepareContext interface { PrepareContext }
|
||||
pkg database/sql/driver, type ConnPrepareContext interface, PrepareContext(context.Context, string) (Stmt, error)
|
||||
pkg database/sql/driver, type ExecerContext interface { ExecContext }
|
||||
pkg database/sql/driver, type ExecerContext interface, ExecContext(context.Context, string, []NamedValue) (Result, error)
|
||||
pkg database/sql/driver, type IsolationLevel int
|
||||
pkg database/sql/driver, type NamedValue struct
|
||||
pkg database/sql/driver, type NamedValue struct, Name string
|
||||
pkg database/sql/driver, type NamedValue struct, Ordinal int
|
||||
pkg database/sql/driver, type NamedValue struct, Value Value
|
||||
pkg database/sql/driver, type Pinger interface { Ping }
|
||||
pkg database/sql/driver, type Pinger interface, Ping(context.Context) error
|
||||
pkg database/sql/driver, type QueryerContext interface { QueryContext }
|
||||
pkg database/sql/driver, type QueryerContext interface, QueryContext(context.Context, string, []NamedValue) (Rows, error)
|
||||
pkg database/sql/driver, type RowsColumnTypeDatabaseTypeName interface { Close, ColumnTypeDatabaseTypeName, Columns, Next }
|
||||
pkg database/sql/driver, type RowsColumnTypeDatabaseTypeName interface, Close() error
|
||||
pkg database/sql/driver, type RowsColumnTypeDatabaseTypeName interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsColumnTypeDatabaseTypeName interface, ColumnTypeDatabaseTypeName(int) string
|
||||
pkg database/sql/driver, type RowsColumnTypeDatabaseTypeName interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsColumnTypeLength interface { Close, ColumnTypeLength, Columns, Next }
|
||||
pkg database/sql/driver, type RowsColumnTypeLength interface, Close() error
|
||||
pkg database/sql/driver, type RowsColumnTypeLength interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsColumnTypeLength interface, ColumnTypeLength(int) (int64, bool)
|
||||
pkg database/sql/driver, type RowsColumnTypeLength interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsColumnTypeNullable interface { Close, ColumnTypeNullable, Columns, Next }
|
||||
pkg database/sql/driver, type RowsColumnTypeNullable interface, Close() error
|
||||
pkg database/sql/driver, type RowsColumnTypeNullable interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsColumnTypeNullable interface, ColumnTypeNullable(int) (bool, bool)
|
||||
pkg database/sql/driver, type RowsColumnTypeNullable interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsColumnTypePrecisionScale interface { Close, ColumnTypePrecisionScale, Columns, Next }
|
||||
pkg database/sql/driver, type RowsColumnTypePrecisionScale interface, Close() error
|
||||
pkg database/sql/driver, type RowsColumnTypePrecisionScale interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsColumnTypePrecisionScale interface, ColumnTypePrecisionScale(int) (int64, int64, bool)
|
||||
pkg database/sql/driver, type RowsColumnTypePrecisionScale interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsColumnTypeScanType interface { Close, ColumnTypeScanType, Columns, Next }
|
||||
pkg database/sql/driver, type RowsColumnTypeScanType interface, Close() error
|
||||
pkg database/sql/driver, type RowsColumnTypeScanType interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsColumnTypeScanType interface, ColumnTypeScanType(int) reflect.Type
|
||||
pkg database/sql/driver, type RowsColumnTypeScanType interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsNextResultSet interface { Close, Columns, HasNextResultSet, Next, NextResultSet }
|
||||
pkg database/sql/driver, type RowsNextResultSet interface, Close() error
|
||||
pkg database/sql/driver, type RowsNextResultSet interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsNextResultSet interface, HasNextResultSet() bool
|
||||
pkg database/sql/driver, type RowsNextResultSet interface, NextResultSet() error
|
||||
pkg database/sql/driver, type RowsNextResultSet interface, Next([]Value) error
|
||||
pkg database/sql/driver, type StmtExecContext interface { ExecContext }
|
||||
pkg database/sql/driver, type StmtExecContext interface, ExecContext(context.Context, []NamedValue) (Result, error)
|
||||
pkg database/sql/driver, type StmtQueryContext interface { QueryContext }
|
||||
pkg database/sql/driver, type StmtQueryContext interface, QueryContext(context.Context, []NamedValue) (Rows, error)
|
||||
pkg database/sql, func IsolationContext(context.Context, IsolationLevel) context.Context
|
||||
pkg database/sql, func Named(string, interface{}) NamedArg
|
||||
pkg database/sql, func ReadOnlyContext(context.Context) context.Context
|
||||
pkg database/sql, method (*ColumnType) DatabaseTypeName() string
|
||||
pkg database/sql, method (*ColumnType) DecimalSize() (int64, int64, bool)
|
||||
pkg database/sql, method (*ColumnType) Length() (int64, bool)
|
||||
pkg database/sql, method (*ColumnType) Name() string
|
||||
pkg database/sql, method (*ColumnType) Nullable() (bool, bool)
|
||||
pkg database/sql, method (*ColumnType) ScanType() reflect.Type
|
||||
pkg database/sql, method (*DB) BeginContext(context.Context) (*Tx, error)
|
||||
pkg database/sql, method (*DB) ExecContext(context.Context, string, ...interface{}) (Result, error)
|
||||
pkg database/sql, method (*DB) PingContext(context.Context) error
|
||||
pkg database/sql, method (*DB) PrepareContext(context.Context, string) (*Stmt, error)
|
||||
pkg database/sql, method (*DB) QueryContext(context.Context, string, ...interface{}) (*Rows, error)
|
||||
pkg database/sql, method (*DB) QueryRowContext(context.Context, string, ...interface{}) *Row
|
||||
pkg database/sql, method (*Rows) ColumnTypes() ([]*ColumnType, error)
|
||||
pkg database/sql, method (*Rows) NextResultSet() bool
|
||||
pkg database/sql, method (*Stmt) ExecContext(context.Context, ...interface{}) (Result, error)
|
||||
pkg database/sql, method (*Stmt) QueryContext(context.Context, ...interface{}) (*Rows, error)
|
||||
pkg database/sql, method (*Stmt) QueryRowContext(context.Context, ...interface{}) *Row
|
||||
pkg database/sql, method (*Tx) ExecContext(context.Context, string, ...interface{}) (Result, error)
|
||||
pkg database/sql, method (*Tx) PrepareContext(context.Context, string) (*Stmt, error)
|
||||
pkg database/sql, method (*Tx) QueryContext(context.Context, string, ...interface{}) (*Rows, error)
|
||||
pkg database/sql, method (*Tx) QueryRowContext(context.Context, string, ...interface{}) *Row
|
||||
pkg database/sql, method (*Tx) StmtContext(context.Context, *Stmt) *Stmt
|
||||
pkg database/sql, type ColumnType struct
|
||||
pkg database/sql, type IsolationLevel int
|
||||
pkg database/sql, type NamedArg struct
|
||||
pkg database/sql, type NamedArg struct, Name string
|
||||
pkg database/sql, type NamedArg struct, Value interface{}
|
||||
pkg debug/gosym, func PCValue([]uint8, uint64, int) int
|
||||
pkg debug/pe, method (*COFFSymbol) FullName(StringTable) (string, error)
|
||||
pkg debug/pe, method (StringTable) String(uint32) (string, error)
|
||||
pkg debug/pe, type File struct, COFFSymbols []COFFSymbol
|
||||
pkg debug/pe, type File struct, StringTable StringTable
|
||||
pkg debug/pe, type Reloc struct
|
||||
pkg debug/pe, type Reloc struct, SymbolTableIndex uint32
|
||||
pkg debug/pe, type Reloc struct, Type uint16
|
||||
pkg debug/pe, type Reloc struct, VirtualAddress uint32
|
||||
pkg debug/pe, type Section struct, Relocs []Reloc
|
||||
pkg debug/pe, type StringTable []uint8
|
||||
pkg encoding/base64, method (Encoding) Strict() *Encoding
|
||||
pkg encoding/json, method (RawMessage) MarshalJSON() ([]uint8, error)
|
||||
pkg encoding/json, type UnmarshalTypeError struct, Field string
|
||||
pkg encoding/json, type UnmarshalTypeError struct, Struct string
|
||||
pkg expvar, func Handler() http.Handler
|
||||
pkg expvar, method (*Float) Value() float64
|
||||
pkg expvar, method (Func) Value() interface{}
|
||||
pkg expvar, method (*Int) Value() int64
|
||||
pkg expvar, method (*String) Value() string
|
||||
pkg go/build, type NoGoError struct, Ignored bool
|
||||
pkg go/doc, func IsPredeclared(string) bool
|
||||
pkg go/types, func Default(Type) Type
|
||||
pkg go/types, func IdenticalIgnoreTags(Type, Type) bool
|
||||
pkg math/big, method (*Float) Scan(fmt.ScanState, int32) error
|
||||
pkg math/big, method (*Int) Sqrt(*Int) *Int
|
||||
pkg math/rand, func Uint64() uint64
|
||||
pkg math/rand, method (*Rand) Uint64() uint64
|
||||
pkg math/rand, type Source64 interface, Int63() int64
|
||||
pkg math/rand, type Source64 interface { Int63, Seed, Uint64 }
|
||||
pkg math/rand, type Source64 interface, Seed(int64)
|
||||
pkg math/rand, type Source64 interface, Uint64() uint64
|
||||
pkg net/http, const TrailerPrefix ideal-string
|
||||
pkg net/http, const TrailerPrefix = "Trailer:"
|
||||
pkg net/http/httptrace, type ClientTrace struct, TLSHandshakeDone func(tls.ConnectionState, error)
|
||||
pkg net/http/httptrace, type ClientTrace struct, TLSHandshakeStart func()
|
||||
pkg net/http/httputil, type ReverseProxy struct, ModifyResponse func(*http.Response) error
|
||||
pkg net/http, method (*Server) Close() error
|
||||
pkg net/http, method (*Server) Shutdown(context.Context) error
|
||||
pkg net/http, type Pusher interface { Push }
|
||||
pkg net/http, type Pusher interface, Push(string, *PushOptions) error
|
||||
pkg net/http, type PushOptions struct
|
||||
pkg net/http, type PushOptions struct, Header Header
|
||||
pkg net/http, type PushOptions struct, Method string
|
||||
pkg net/http, type Request struct, GetBody func() (io.ReadCloser, error)
|
||||
pkg net/http, type Server struct, IdleTimeout time.Duration
|
||||
pkg net/http, type Server struct, ReadHeaderTimeout time.Duration
|
||||
pkg net/http, type Transport struct, ProxyConnectHeader Header
|
||||
pkg net/http, var ErrAbortHandler error
|
||||
pkg net/http, var ErrServerClosed error
|
||||
pkg net/http, var NoBody noBody
|
||||
pkg net/mail, func ParseDate(string) (time.Time, error)
|
||||
pkg net, method (*Buffers) Read([]uint8) (int, error)
|
||||
pkg net, method (*Buffers) WriteTo(io.Writer) (int64, error)
|
||||
pkg net, method (*Resolver) LookupAddr(context.Context, string) ([]string, error)
|
||||
pkg net, method (*Resolver) LookupCNAME(context.Context, string) (string, error)
|
||||
pkg net, method (*Resolver) LookupHost(context.Context, string) ([]string, error)
|
||||
pkg net, method (*Resolver) LookupIPAddr(context.Context, string) ([]IPAddr, error)
|
||||
pkg net, method (*Resolver) LookupMX(context.Context, string) ([]*MX, error)
|
||||
pkg net, method (*Resolver) LookupNS(context.Context, string) ([]*NS, error)
|
||||
pkg net, method (*Resolver) LookupPort(context.Context, string, string) (int, error)
|
||||
pkg net, method (*Resolver) LookupSRV(context.Context, string, string, string) (string, []*SRV, error)
|
||||
pkg net, method (*Resolver) LookupTXT(context.Context, string) ([]string, error)
|
||||
pkg net, method (*UnixListener) SetUnlinkOnClose(bool)
|
||||
pkg net, type Buffers [][]uint8
|
||||
pkg net, type Dialer struct, Resolver *Resolver
|
||||
pkg net, type Resolver struct
|
||||
pkg net, type Resolver struct, PreferGo bool
|
||||
pkg net/url, func PathEscape(string) string
|
||||
pkg net/url, func PathUnescape(string) (string, error)
|
||||
pkg net/url, method (*URL) Hostname() string
|
||||
pkg net/url, method (*URL) MarshalBinary() ([]uint8, error)
|
||||
pkg net/url, method (*URL) Port() string
|
||||
pkg net/url, method (*URL) UnmarshalBinary([]uint8) error
|
||||
pkg net, var DefaultResolver *Resolver
|
||||
pkg os, func Executable() (string, error)
|
||||
pkg os, var ErrClosed error
|
||||
pkg plugin, func Open(string) (*Plugin, error)
|
||||
pkg plugin, method (*Plugin) Lookup(string) (Symbol, error)
|
||||
pkg plugin, type Plugin struct
|
||||
pkg plugin, type Symbol interface {}
|
||||
pkg reflect, func Swapper(interface{}) func(int, int)
|
||||
pkg runtime, func MutexProfile([]BlockProfileRecord) (int, bool)
|
||||
pkg runtime, func SetMutexProfileFraction(int) int
|
||||
pkg sort, func Slice(interface{}, func(int, int) bool)
|
||||
pkg sort, func SliceIsSorted(interface{}, func(int, int) bool) bool
|
||||
pkg sort, func SliceStable(interface{}, func(int, int) bool)
|
||||
pkg syscall (linux-arm-cgo), func TimevalToNsec(Timeval) int64
|
||||
pkg syscall (linux-arm), func TimevalToNsec(Timeval) int64
|
||||
pkg syscall (windows-386), const ERROR_DIR_NOT_EMPTY = 145
|
||||
pkg syscall (windows-386), const ERROR_DIR_NOT_EMPTY Errno
|
||||
pkg syscall (windows-amd64), const ERROR_DIR_NOT_EMPTY = 145
|
||||
pkg syscall (windows-amd64), const ERROR_DIR_NOT_EMPTY Errno
|
||||
pkg testing, func CoverMode() string
|
||||
pkg testing, func MainStart(testDeps, []InternalTest, []InternalBenchmark, []InternalExample) *M
|
||||
pkg testing, method (*B) Context() context.Context
|
||||
pkg testing, method (*B) Name() string
|
||||
pkg testing, method (*T) Context() context.Context
|
||||
pkg testing, method (*T) Name() string
|
||||
pkg testing, type TB interface, Context() context.Context
|
||||
pkg testing, type TB interface, Name() string
|
||||
pkg time, func Until(Time) Duration
|
||||
193
api/next.txt
193
api/next.txt
@@ -0,0 +1,193 @@
|
||||
pkg compress/gzip, const HuffmanOnly = -2
|
||||
pkg compress/gzip, const HuffmanOnly ideal-int
|
||||
pkg compress/zlib, const HuffmanOnly = -2
|
||||
pkg compress/zlib, const HuffmanOnly ideal-int
|
||||
pkg crypto/tls, const TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 = 49187
|
||||
pkg crypto/tls, const TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 uint16
|
||||
pkg crypto/tls, const TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 = 52393
|
||||
pkg crypto/tls, const TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 uint16
|
||||
pkg crypto/tls, const TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 = 49191
|
||||
pkg crypto/tls, const TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 uint16
|
||||
pkg crypto/tls, const TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 = 52392
|
||||
pkg crypto/tls, const TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 uint16
|
||||
pkg crypto/tls, const TLS_RSA_WITH_AES_128_CBC_SHA256 = 60
|
||||
pkg crypto/tls, const TLS_RSA_WITH_AES_128_CBC_SHA256 uint16
|
||||
pkg crypto/tls, const X25519 = 29
|
||||
pkg crypto/tls, const X25519 CurveID
|
||||
pkg crypto/tls, method (*Config) Clone() *Config
|
||||
pkg crypto/tls, type ClientHelloInfo struct, Conn net.Conn
|
||||
pkg crypto/tls, type ClientHelloInfo struct, SignatureSchemes []uint16
|
||||
pkg crypto/tls, type ClientHelloInfo struct, SupportedProtos []string
|
||||
pkg crypto/tls, type ClientHelloInfo struct, SupportedVersions []uint16
|
||||
pkg crypto/tls, type Config struct, GetConfigForClient func(*ClientHelloInfo) (*Config, error)
|
||||
pkg crypto/tls, type Config struct, KeyLogWriter io.Writer
|
||||
pkg crypto/tls, type Config struct, VerifyPeerCertificate func([][]uint8, [][]*x509.Certificate) error
|
||||
pkg crypto/x509, const NameMismatch = 5
|
||||
pkg crypto/x509, const NameMismatch InvalidReason
|
||||
pkg crypto/x509, const SHA256WithRSAPSS = 13
|
||||
pkg crypto/x509, const SHA256WithRSAPSS SignatureAlgorithm
|
||||
pkg crypto/x509, const SHA384WithRSAPSS = 14
|
||||
pkg crypto/x509, const SHA384WithRSAPSS SignatureAlgorithm
|
||||
pkg crypto/x509, const SHA512WithRSAPSS = 15
|
||||
pkg crypto/x509, const SHA512WithRSAPSS SignatureAlgorithm
|
||||
pkg database/sql, func Param(string, interface{}) NamedParam
|
||||
pkg database/sql, method (*ColumnType) DatabaseTypeName() string
|
||||
pkg database/sql, method (*ColumnType) DecimalSize() (int64, int64, bool)
|
||||
pkg database/sql, method (*ColumnType) Length() (int64, bool)
|
||||
pkg database/sql, method (*ColumnType) Name() string
|
||||
pkg database/sql, method (*ColumnType) Nullable() (bool, bool)
|
||||
pkg database/sql, method (*ColumnType) ScanType() reflect.Type
|
||||
pkg database/sql, method (*DB) BeginContext(context.Context) (*Tx, error)
|
||||
pkg database/sql, method (*DB) ExecContext(context.Context, string, ...interface{}) (Result, error)
|
||||
pkg database/sql, method (*DB) PingContext(context.Context) error
|
||||
pkg database/sql, method (*DB) PrepareContext(context.Context, string) (*Stmt, error)
|
||||
pkg database/sql, method (*DB) QueryContext(context.Context, string, ...interface{}) (*Rows, error)
|
||||
pkg database/sql, method (*DB) QueryRowContext(context.Context, string, ...interface{}) *Row
|
||||
pkg database/sql, method (*Rows) ColumnTypes() ([]*ColumnType, error)
|
||||
pkg database/sql, method (*Rows) NextResultSet() bool
|
||||
pkg database/sql, method (*Stmt) ExecContext(context.Context, ...interface{}) (Result, error)
|
||||
pkg database/sql, method (*Stmt) QueryContext(context.Context, ...interface{}) (*Rows, error)
|
||||
pkg database/sql, method (*Stmt) QueryRowContext(context.Context, ...interface{}) *Row
|
||||
pkg database/sql, method (*Tx) ExecContext(context.Context, string, ...interface{}) (Result, error)
|
||||
pkg database/sql, method (*Tx) PrepareContext(context.Context, string) (*Stmt, error)
|
||||
pkg database/sql, method (*Tx) QueryContext(context.Context, string, ...interface{}) (*Rows, error)
|
||||
pkg database/sql, method (*Tx) QueryRowContext(context.Context, string, ...interface{}) *Row
|
||||
pkg database/sql, method (*Tx) StmtContext(context.Context, *Stmt) *Stmt
|
||||
pkg database/sql, type ColumnType struct
|
||||
pkg database/sql, type NamedParam struct
|
||||
pkg database/sql, type NamedParam struct, Name string
|
||||
pkg database/sql, type NamedParam struct, Value interface{}
|
||||
pkg database/sql/driver, type ConnBeginContext interface { BeginContext }
|
||||
pkg database/sql/driver, type ConnBeginContext interface, BeginContext(context.Context) (Tx, error)
|
||||
pkg database/sql/driver, type ConnPrepareContext interface { PrepareContext }
|
||||
pkg database/sql/driver, type ConnPrepareContext interface, PrepareContext(context.Context, string) (Stmt, error)
|
||||
pkg database/sql/driver, type ExecerContext interface { ExecContext }
|
||||
pkg database/sql/driver, type ExecerContext interface, ExecContext(context.Context, string, []NamedValue) (Result, error)
|
||||
pkg database/sql/driver, type NamedValue struct
|
||||
pkg database/sql/driver, type NamedValue struct, Name string
|
||||
pkg database/sql/driver, type NamedValue struct, Ordinal int
|
||||
pkg database/sql/driver, type NamedValue struct, Value Value
|
||||
pkg database/sql/driver, type QueryerContext interface { QueryContext }
|
||||
pkg database/sql/driver, type QueryerContext interface, QueryContext(context.Context, string, []NamedValue) (Rows, error)
|
||||
pkg database/sql/driver, type RowsColumnTypeDatabaseTypeName interface { Close, ColumnTypeDatabaseTypeName, Columns, Next }
|
||||
pkg database/sql/driver, type RowsColumnTypeDatabaseTypeName interface, Close() error
|
||||
pkg database/sql/driver, type RowsColumnTypeDatabaseTypeName interface, ColumnTypeDatabaseTypeName(int) string
|
||||
pkg database/sql/driver, type RowsColumnTypeDatabaseTypeName interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsColumnTypeDatabaseTypeName interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsColumnTypeLength interface { Close, ColumnTypeLength, Columns, Next }
|
||||
pkg database/sql/driver, type RowsColumnTypeLength interface, Close() error
|
||||
pkg database/sql/driver, type RowsColumnTypeLength interface, ColumnTypeLength(int) (int64, bool)
|
||||
pkg database/sql/driver, type RowsColumnTypeLength interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsColumnTypeLength interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsColumnTypeNullable interface { Close, ColumnTypeNullable, Columns, Next }
|
||||
pkg database/sql/driver, type RowsColumnTypeNullable interface, Close() error
|
||||
pkg database/sql/driver, type RowsColumnTypeNullable interface, ColumnTypeNullable(int) (bool, bool)
|
||||
pkg database/sql/driver, type RowsColumnTypeNullable interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsColumnTypeNullable interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsColumnTypePrecisionScale interface { Close, ColumnTypePrecisionScale, Columns, Next }
|
||||
pkg database/sql/driver, type RowsColumnTypePrecisionScale interface, Close() error
|
||||
pkg database/sql/driver, type RowsColumnTypePrecisionScale interface, ColumnTypePrecisionScale(int) (int64, int64, bool)
|
||||
pkg database/sql/driver, type RowsColumnTypePrecisionScale interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsColumnTypePrecisionScale interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsColumnTypeScanType interface { Close, ColumnTypeScanType, Columns, Next }
|
||||
pkg database/sql/driver, type RowsColumnTypeScanType interface, Close() error
|
||||
pkg database/sql/driver, type RowsColumnTypeScanType interface, ColumnTypeScanType(int) reflect.Type
|
||||
pkg database/sql/driver, type RowsColumnTypeScanType interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsColumnTypeScanType interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsNextResultSet interface { Close, Columns, HasNextResultSet, Next, NextResultSet }
|
||||
pkg database/sql/driver, type RowsNextResultSet interface, Close() error
|
||||
pkg database/sql/driver, type RowsNextResultSet interface, Columns() []string
|
||||
pkg database/sql/driver, type RowsNextResultSet interface, HasNextResultSet() bool
|
||||
pkg database/sql/driver, type RowsNextResultSet interface, Next([]Value) error
|
||||
pkg database/sql/driver, type RowsNextResultSet interface, NextResultSet() error
|
||||
pkg database/sql/driver, type StmtExecContext interface { ExecContext }
|
||||
pkg database/sql/driver, type StmtExecContext interface, ExecContext(context.Context, []NamedValue) (Result, error)
|
||||
pkg database/sql/driver, type StmtQueryContext interface { QueryContext }
|
||||
pkg database/sql/driver, type StmtQueryContext interface, QueryContext(context.Context, []NamedValue) (Rows, error)
|
||||
pkg debug/gosym, func PCValue([]uint8, uint64, int) int
|
||||
pkg debug/pe, method (*COFFSymbol) FullName(StringTable) (string, error)
|
||||
pkg debug/pe, method (StringTable) String(uint32) (string, error)
|
||||
pkg debug/pe, type File struct, COFFSymbols []COFFSymbol
|
||||
pkg debug/pe, type File struct, StringTable StringTable
|
||||
pkg debug/pe, type Reloc struct
|
||||
pkg debug/pe, type Reloc struct, SymbolTableIndex uint32
|
||||
pkg debug/pe, type Reloc struct, Type uint16
|
||||
pkg debug/pe, type Reloc struct, VirtualAddress uint32
|
||||
pkg debug/pe, type Section struct, Relocs []Reloc
|
||||
pkg debug/pe, type StringTable []uint8
|
||||
pkg encoding/base64, method (Encoding) Strict() *Encoding
|
||||
pkg encoding/json, type UnmarshalTypeError struct, Field string
|
||||
pkg encoding/json, type UnmarshalTypeError struct, Struct string
|
||||
pkg expvar, func Handler() http.Handler
|
||||
pkg expvar, method (*Float) Value() float64
|
||||
pkg expvar, method (*Int) Value() int64
|
||||
pkg expvar, method (*String) Value() string
|
||||
pkg expvar, method (Func) Value() interface{}
|
||||
pkg go/ast, method (*AliasSpec) End() token.Pos
|
||||
pkg go/ast, method (*AliasSpec) Pos() token.Pos
|
||||
pkg go/ast, type AliasSpec struct
|
||||
pkg go/ast, type AliasSpec struct, Comment *CommentGroup
|
||||
pkg go/ast, type AliasSpec struct, Doc *CommentGroup
|
||||
pkg go/ast, type AliasSpec struct, Name *Ident
|
||||
pkg go/ast, type AliasSpec struct, Orig Expr
|
||||
pkg go/build, type NoGoError struct, Ignored bool
|
||||
pkg go/doc, func IsPredeclared(string) bool
|
||||
pkg go/token, const ALIAS = 87
|
||||
pkg go/token, const ALIAS Token
|
||||
pkg go/types, func Default(Type) Type
|
||||
pkg go/types, func IdenticalIgnoreTags(Type, Type) bool
|
||||
pkg math/big, method (*Float) Scan(fmt.ScanState, int32) error
|
||||
pkg math/big, method (*Int) Sqrt(*Int) *Int
|
||||
pkg math/rand, func Uint64() uint64
|
||||
pkg math/rand, method (*Rand) Uint64() uint64
|
||||
pkg net, method (*Buffers) Read([]uint8) (int, error)
|
||||
pkg net, method (*Buffers) WriteTo(io.Writer) (int64, error)
|
||||
pkg net, method (*Resolver) LookupAddr(context.Context, string) ([]string, error)
|
||||
pkg net, method (*Resolver) LookupCNAME(context.Context, string) (string, error)
|
||||
pkg net, method (*Resolver) LookupHost(context.Context, string) ([]string, error)
|
||||
pkg net, method (*Resolver) LookupIPAddr(context.Context, string) ([]IPAddr, error)
|
||||
pkg net, method (*Resolver) LookupMX(context.Context, string) ([]*MX, error)
|
||||
pkg net, method (*Resolver) LookupNS(context.Context, string) ([]*NS, error)
|
||||
pkg net, method (*Resolver) LookupPort(context.Context, string, string) (int, error)
|
||||
pkg net, method (*Resolver) LookupSRV(context.Context, string, string, string) (string, []*SRV, error)
|
||||
pkg net, method (*Resolver) LookupTXT(context.Context, string) ([]string, error)
|
||||
pkg net, type Buffers [][]uint8
|
||||
pkg net, type Dialer struct, Resolver *Resolver
|
||||
pkg net, type Resolver struct
|
||||
pkg net, type Resolver struct, PreferGo bool
|
||||
pkg net, var DefaultResolver *Resolver
|
||||
pkg net/http, type PushOptions struct
|
||||
pkg net/http, type PushOptions struct, Header Header
|
||||
pkg net/http, type PushOptions struct, Method string
|
||||
pkg net/http, type Pusher interface { Push }
|
||||
pkg net/http, type Pusher interface, Push(string, *PushOptions) error
|
||||
pkg net/http, type Request struct, GetBody func() (io.ReadCloser, error)
|
||||
pkg net/http, var NoBody noBody
|
||||
pkg net/http/httptrace, type ClientTrace struct, TLSHandshakeDone func(tls.ConnectionState, error)
|
||||
pkg net/http/httptrace, type ClientTrace struct, TLSHandshakeStart func()
|
||||
pkg net/mail, func ParseDate(string) (time.Time, error)
|
||||
pkg net/url, func PathEscape(string) string
|
||||
pkg net/url, func PathUnescape(string) (string, error)
|
||||
pkg net/url, method (*URL) Hostname() string
|
||||
pkg net/url, method (*URL) MarshalBinary() ([]uint8, error)
|
||||
pkg net/url, method (*URL) Port() string
|
||||
pkg net/url, method (*URL) UnmarshalBinary([]uint8) error
|
||||
pkg os, var ErrClosed error
|
||||
pkg plugin, func Open(string) (*Plugin, error)
|
||||
pkg plugin, method (*Plugin) Lookup(string) (Symbol, error)
|
||||
pkg plugin, type Plugin struct
|
||||
pkg plugin, type Symbol interface {}
|
||||
pkg reflect, func Swapper(interface{}) func(int, int)
|
||||
pkg sort, func Slice(interface{}, func(int, int) bool)
|
||||
pkg sort, func SliceIsSorted(interface{}, func(int, int) bool) bool
|
||||
pkg sort, func SliceStable(interface{}, func(int, int) bool)
|
||||
pkg syscall (linux-arm), func TimevalToNsec(Timeval) int64
|
||||
pkg syscall (linux-arm-cgo), func TimevalToNsec(Timeval) int64
|
||||
pkg syscall (windows-386), const ERROR_DIR_NOT_EMPTY = 145
|
||||
pkg syscall (windows-386), const ERROR_DIR_NOT_EMPTY Errno
|
||||
pkg syscall (windows-amd64), const ERROR_DIR_NOT_EMPTY = 145
|
||||
pkg syscall (windows-amd64), const ERROR_DIR_NOT_EMPTY Errno
|
||||
pkg testing, method (*B) Name() string
|
||||
pkg testing, method (*T) Name() string
|
||||
pkg testing, type TB interface, Name() string
|
||||
pkg time, func Until(Time) Duration
|
||||
|
||||
@@ -97,14 +97,13 @@ a tool like the go command to look at an unfamiliar import path and
|
||||
deduce where to obtain the source code.</p>
|
||||
|
||||
<p>Second, the place to store sources in the local file system is derived
|
||||
in a known way from the import path, specifically
|
||||
<code>$GOPATH/src/<import-path></code>.
|
||||
If unset, <code>$GOPATH</code> defaults to a subdirectory
|
||||
named <code>go</code> in the user's home directory.
|
||||
in a known way from the import path. Specifically, the first choice
|
||||
is <code>$GOPATH/src/<import-path></code>. If <code>$GOPATH</code> is
|
||||
unset, the go command will fall back to storing source code alongside the
|
||||
standard Go packages, in <code>$GOROOT/src/<import-path></code>.
|
||||
If <code>$GOPATH</code> is set to a list of paths, the go command tries
|
||||
<code><dir>/src/<import-path></code> for each of the directories in
|
||||
that list.
|
||||
</p>
|
||||
that list.</p>
|
||||
|
||||
<p>Each of those trees contains, by convention, a top-level directory named
|
||||
"<code>bin</code>", for holding compiled executables, and a top-level directory
|
||||
@@ -138,13 +137,28 @@ to the use of a specific tool chain.</p>
|
||||
|
||||
<h2>Getting started with the go command</h2>
|
||||
|
||||
<p>Finally, a quick tour of how to use the go command.
|
||||
As mentioned above, the default <code>$GOPATH</code> on Unix is <code>$HOME/go</code>.
|
||||
We'll store our programs there.
|
||||
To use a different location, you can set <code>$GOPATH</code>;
|
||||
see <a href="/doc/code.html">How to Write Go Code</a> for details.
|
||||
<p>Finally, a quick tour of how to use the go command, to supplement
|
||||
the information in <a href="/doc/code.html">How to Write Go Code</a>,
|
||||
which you might want to read first. Assuming you want
|
||||
to keep your source code separate from the Go distribution source
|
||||
tree, the first step is to set <code>$GOPATH</code>, the one piece of global
|
||||
configuration that the go command needs. The <code>$GOPATH</code> can be a
|
||||
list of directories, but by far the most common usage should be to set it to a
|
||||
single directory. In particular, you do not need a separate entry in
|
||||
<code>$GOPATH</code> for each of your projects. One <code>$GOPATH</code> can
|
||||
support many projects.</p>
|
||||
|
||||
<p>We first add some source code. Suppose we want to use
|
||||
<p>Here’s an example. Let’s say we decide to keep our Go code in the directory
|
||||
<code>$HOME/mygo</code>. We need to create that directory and set
|
||||
<code>$GOPATH</code> accordingly.</p>
|
||||
|
||||
<pre>
|
||||
$ mkdir $HOME/mygo
|
||||
$ export GOPATH=$HOME/mygo
|
||||
$
|
||||
</pre>
|
||||
|
||||
<p>Into this directory, we now add some source code. Suppose we want to use
|
||||
the indexing library from the codesearch project along with a left-leaning
|
||||
red-black tree. We can install both with the "<code>go get</code>"
|
||||
subcommand:</p>
|
||||
@@ -155,8 +169,8 @@ $ go get github.com/petar/GoLLRB/llrb
|
||||
$
|
||||
</pre>
|
||||
|
||||
<p>Both of these projects are now downloaded and installed into <code>$HOME/go</code>,
|
||||
which contains the two directories
|
||||
<p>Both of these projects are now downloaded and installed into our
|
||||
<code>$GOPATH</code> directory. The one tree now contains the two directories
|
||||
<code>src/github.com/google/codesearch/index/</code> and
|
||||
<code>src/github.com/petar/GoLLRB/llrb/</code>, along with the compiled
|
||||
packages (in <code>pkg/</code>) for those libraries and their dependencies.</p>
|
||||
@@ -170,7 +184,6 @@ the pattern "<code>./...</code>" means start in the current directory
|
||||
("<code>...</code>"):</p>
|
||||
|
||||
<pre>
|
||||
$ cd $HOME/go/src
|
||||
$ go list ./...
|
||||
github.com/google/codesearch/cmd/cgrep
|
||||
github.com/google/codesearch/cmd/cindex
|
||||
@@ -202,7 +215,7 @@ $
|
||||
current directory:</p>
|
||||
|
||||
<pre>
|
||||
$ cd github.com/google/codesearch/regexp
|
||||
$ cd $GOPATH/src/github.com/google/codesearch/regexp
|
||||
$ go list
|
||||
github.com/google/codesearch/regexp
|
||||
$ go test -v
|
||||
@@ -231,6 +244,9 @@ pick such a long name, but that ability would require additional configuration
|
||||
and complexity in the tool. Typing an extra directory name or two is a small
|
||||
price to pay for the increased simplicity and power.</p>
|
||||
|
||||
<p>As the example shows, it’s fine to work with packages from many different
|
||||
projects at once within a single <code>$GOPATH</code> root directory.</p>
|
||||
|
||||
<h2>Limitations</h2>
|
||||
|
||||
<p>As mentioned above, the go command is not a general-purpose build
|
||||
|
||||
@@ -120,43 +120,30 @@ We will discuss the distinction <a href="#PackageNames">later</a>.
|
||||
|
||||
<p>
|
||||
The <code>GOPATH</code> environment variable specifies the location of your
|
||||
workspace. It defaults to a directory named <code>go</code> inside your home directory,
|
||||
so <code>$HOME/go</code> on Unix,
|
||||
<code>$home/go</code> on Plan 9,
|
||||
and <code>%USERPROFILE%\go</code> (usually <code>C:\Users\YourName\go</code>) on Windows.
|
||||
If you would like to work in a different location, you will need to set
|
||||
<code>GOPATH</code> to the path to that directory.
|
||||
(Another common setup is to set <code>GOPATH=$HOME</code>.)
|
||||
Note that <code>GOPATH</code> must <b>not</b> be the
|
||||
same path as your Go installation.
|
||||
workspace. It is likely the only environment variable you'll need to set
|
||||
when developing Go code.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The command <code>go</code> <code>env</code> <code>GOPATH</code>
|
||||
prints the effective current <code>GOPATH</code>;
|
||||
it prints the default location if the environment variable is unset.
|
||||
To get started, create a workspace directory and set <code>GOPATH</code>
|
||||
accordingly. Your workspace can be located wherever you like, but we'll use
|
||||
<code>$HOME/work</code> in this document. Note that this must <b>not</b> be the
|
||||
same path as your Go installation.
|
||||
(Another common setup is to set <code>GOPATH=$HOME</code>.)
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ <b>mkdir $HOME/work</b>
|
||||
$ <b>export GOPATH=$HOME/work</b>
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
For convenience, add the workspace's <code>bin</code> subdirectory
|
||||
to your <code>PATH</code>:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ <b>export PATH=$PATH:$(go env GOPATH)/bin</b>
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The scripts in the rest of this document use <code>$GOPATH</code>
|
||||
instead of <code>$(go env GOPATH)</code> for brevity.
|
||||
To make the scripts run as written
|
||||
if you have not set GOPATH,
|
||||
you can substitute $HOME/go in those commands
|
||||
or else run:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ <b>export GOPATH=$(go env GOPATH)</b>
|
||||
$ <b>export PATH=$PATH:$GOPATH/bin</b>
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -2450,7 +2450,7 @@ The http package's URL parsing and query escaping code (such as ParseURL and
|
||||
URLEscape) has been moved to the new url package, with several simplifications
|
||||
to the names. Client code can be updated automatically with gofix.
|
||||
|
||||
* asn1: support unmarshaling structs with int32 members (thanks Dave Cheney).
|
||||
* asn1: support unmarshalling structs with int32 members (thanks Dave Cheney).
|
||||
* build: allow builds without cgo or hg,
|
||||
support versioning without hg (thanks Gustavo Niemeyer).
|
||||
* builtin: add documentation for builtins.
|
||||
@@ -3030,7 +3030,7 @@ Other changes:
|
||||
* 5g: alignment fixes.
|
||||
* 6l, 8l: fix Mach-O binaries with many dynamic libraries.
|
||||
* 8l: emit resources (.rsrc) in Windows PE. (thanks Wei Guangjing).
|
||||
* asn1: fix marshaling of empty optional RawValues (thanks Mikkel Krautz).
|
||||
* asn1: fix marshalling of empty optional RawValues (thanks Mikkel Krautz).
|
||||
* big: make Int and Rat implement fmt.Scanner (thanks Evan Shaw),
|
||||
~8x faster number scanning,
|
||||
remove some unnecessary conversions.
|
||||
@@ -4238,7 +4238,7 @@ example: http://golang.org/pkg/xml/
|
||||
<pre>
|
||||
The json, gob, and template packages have changed, and code that uses them
|
||||
may need to be updated after this release. They will no longer read or write
|
||||
unexported struct fields. When marshaling a struct with json or gob the
|
||||
unexported struct fields. When marshalling a struct with json or gob the
|
||||
unexported fields will be silently ignored. Attempting to unmarshal json or
|
||||
gob data into an unexported field will generate an error. Accessing an
|
||||
unexported field from a template will cause the Execute function to return
|
||||
@@ -5682,7 +5682,7 @@ Other changes:
|
||||
pidigits ~10% performance win by using adds instead of shifts.
|
||||
* time: remove incorrect time.ISO8601 and add time.RFC3339 (thanks Micah Stetson).
|
||||
* utf16: add DecodeRune, EncodeRune.
|
||||
* xml: add support for XML marshaling embedded structs (thanks Raif S. Naffah),
|
||||
* xml: add support for XML marshalling embedded structs (thanks Raif S. Naffah),
|
||||
new "innerxml" tag to collect inner XML.
|
||||
</pre>
|
||||
|
||||
@@ -5925,10 +5925,10 @@ Other changes and fixes:
|
||||
* 8a/8l: Added CMOVcc instructions (thanks Evan Shaw)
|
||||
* 8l: pe executable building code changed to include import table for kernel32.dll functions (thanks Alex Brainman)
|
||||
* 5g/6g/8g: bug fixes
|
||||
* asn1: bug fixes and additions (incl marshaling)
|
||||
* asn1: bug fixes and additions (incl marshalling)
|
||||
* build: fix build for Native Client, Linux/ARM
|
||||
* dashboard: show benchmarks, add garbage collector benchmarks
|
||||
* encoding/pem: add marshaling support
|
||||
* encoding/pem: add marshalling support
|
||||
* exp/draw: fast paths for a nil mask
|
||||
* godoc: support for directories outside $GOROOT
|
||||
* http: sort header keys when writing Response or Request to wire (thanks Petar Maymounkov)
|
||||
|
||||
1615
doc/go1.8.html
1615
doc/go1.8.html
File diff suppressed because it is too large
Load Diff
403
doc/go1.8.txt
403
doc/go1.8.txt
@@ -1,23 +1,82 @@
|
||||
This file lists things yet to be moved into go1.8.html or deemed too
|
||||
minor to mention. Either way, delete from here when done.
|
||||
Overall:
|
||||
|
||||
plugin build mode & package (many CLs)
|
||||
Many ppc64, s390x, arm, arm64 optimizations
|
||||
New frontend
|
||||
Improvements to binary size, runtime speed, compile speed.
|
||||
Hybrid barrier. <100us GC pauses.
|
||||
|
||||
Language:
|
||||
|
||||
Alias declarations?
|
||||
|
||||
Tools:
|
||||
|
||||
compile: SSA for 386, nacl, arm, arm64, ppc64, ppc64le, s390x ... (many CLs)
|
||||
yacc: "go tool yacc" is removed. now at golang.org/x/tools/cmd/goyacc (CL 27324, CL 27325)
|
||||
go: -buildmode=c-archive now builds PIC on ELF (CL 24180)
|
||||
go: mobile pkg dir change, recommend using go list in scripts (CL 24930, CL 27929)
|
||||
go, dist: can set default pkg-config tool using PKG_CONFIG env var (CL 29991)
|
||||
go: can set secure/insecure GIT schemes using GIT_ALLOW_PROTOCOL env var (CL 30135)
|
||||
|
||||
Ports:
|
||||
|
||||
dragonfly: go1.8 requires DragonFly BSD 4.4.4 or above (CL 29491)
|
||||
plan9: various fixes (Close unblocks Read, I/O deadline maybe?)
|
||||
mips, mipsle
|
||||
|
||||
API additions and behavior changes:
|
||||
|
||||
all: freeze net/rpc and reword the 'frozen' message in other frozen packages (CL 32112)
|
||||
archive/tar: fix and cleanup readOldGNUSparseMap (CL 28471)
|
||||
archive/tar: fix parsePAX to be POSIX.1-2001 compliant (CL 31440)
|
||||
archive/tar: fix parsePAXTime (CL 31441)
|
||||
archive/tar: make Reader handle GNU format properly (CL 31444)
|
||||
archive/tar: reapply Header.Size to regFileReader after merging (CL 28418)
|
||||
archive/tar: validate sparse headers in parsePAX (CL 31439)
|
||||
archive/zip: handle mtime in NTFS/UNIX/ExtendedTS extra fields (CL 18274)
|
||||
archive/zip: only use Extended Timestamp on non-zero MS-DOS timestamps (CL 30811)
|
||||
cmd/cgo: add -srcdir option (CL 32354)
|
||||
cmd/cgo: fix line info in _cgo_gotypes.go (CL 29713)
|
||||
cmd/cgo: throw if C.malloc returns nil (CL 31768)
|
||||
cmd/compile, runtime, etc: get rid of constant FP registers (CL 28095)
|
||||
cmd/compile, runtime: add go:yeswritebarrierrec pragma (CL 30938)
|
||||
cmd/compile/internal/gc: add runtime/trace support (CL 25354)
|
||||
cmd/compile/internal/gc: enable new parser by default (CL 27203)
|
||||
cmd/compile/internal/syntax: fast Go syntax trees, initial commit (CL 27195)
|
||||
cmd/compile: add SSA backend for s390x and enable by default (CL 28978)
|
||||
cmd/compile: add compiler phase timing (CL 24462)
|
||||
cmd/compile: add go:notinheap type pragma (CL 30939)
|
||||
cmd/compile: add inline explainer (CL 22782)
|
||||
cmd/compile: args no longer live until end of function - use runtime.KeepAlive instead (CL 28310)
|
||||
cmd/compile: enable flag-specified dump of specific phase+function (CL 23044)
|
||||
|
||||
cmd/compile: fail gracefully on export format skew (CL 27814)
|
||||
cmd/compile: import/export of alias declarations (CL 32090)
|
||||
cmd/compile: inline convI2E (CL 31260)
|
||||
cmd/compile: make ssa compilation unconditional (CL 29155)
|
||||
cmd/compile: remove -A flag (CL 31497)
|
||||
cmd/compile: remove old lexer and parser (CL 32020)
|
||||
cmd/compile: remove support for textual export format (CL 27171)
|
||||
cmd/cover: Fix compiler directives handling (CL 30161)
|
||||
cmd/cover: handle gotos (CL 30977)
|
||||
cmd/dist, go/build: make CGO_ENABLED during make.bash sticky (CL 31141)
|
||||
cmd/dist: enable plugin test on darwin/amd64 (CL 29396)
|
||||
cmd/dist: test PIE internal linking on linux/amd64 (CL 28545)
|
||||
cmd/doc: ensure summaries truly are only one line (CL 25420)
|
||||
cmd/doc: perform type grouping for constants and variables (CL 25419)
|
||||
cmd/doc: show documentation for interface methods when requested explicitly (CL 31852)
|
||||
cmd/fix: add golang.org/x/net/context fix (CL 28872)
|
||||
cmd/go, testing: indicate when no tests are run (CL 22341)
|
||||
cmd/go: add bug command (CL 28485)
|
||||
cmd/go: add distribution-specific info for Linux to bug command (CL 28581)
|
||||
cmd/go: apply import restrictions to test code too (CL 31821)
|
||||
cmd/go: diagnose non-canonical import paths before compilation (CL 31668)
|
||||
cmd/go: enable -buildmode=plugin on darwin/amd64 (CL 29395)
|
||||
cmd/go: for -msan build runtime/cgo with -fsanitize=memory (CL 24855)
|
||||
cmd/go: make bug subcommand open the browser (CL 29210)
|
||||
cmd/go: make go test -i -o x.test actually write x.test (CL 31352)
|
||||
cmd/go: print more env variables in "go env" (CL 31330)
|
||||
cmd/go: referee another vendor vs symlink fight (CL 31665)
|
||||
cmd/internal/obj, cmd/link: darwin dynlink support (CL 29393)
|
||||
cmd/internal/objfile: add ppc64/ppc64le disassembler support (CL 9682)
|
||||
cmd/link, cmd/go: delay linking of mingwex and mingw32 until very end (CL 26670)
|
||||
@@ -26,7 +85,6 @@ cmd/link: add trampolines for too far calls in ppc64x (CL 30850)
|
||||
cmd/link: allow internal PIE linking (CL 28543)
|
||||
cmd/link: fix -X importpath.name=value when import path needs escaping (CL 31970)
|
||||
cmd/link: fix -buildmode=pie / -linkshared combination (CL 28996)
|
||||
cmd/link: for -buildmode=exe pass -no-pie to external linker (CL 33106)
|
||||
cmd/link: insert trampolines for too-far jumps on ARM (CL 29397)
|
||||
cmd/link: non-executable stack support for Solaris (CL 24142)
|
||||
cmd/link: plugin support on darwin/amd64 (CL 29394)
|
||||
@@ -35,22 +93,351 @@ cmd/link: remove the -shared flag (CL 28852)
|
||||
cmd/link: split large elf text sections on ppc64x (CL 27790)
|
||||
cmd/link: trampoline support for external linking on ARM (CL 31143)
|
||||
cmd/objdump: implement objdump of .o files (CL 24818)
|
||||
|
||||
cmd/pprof: instruction-level granularity in callgrind output (CL 23781)
|
||||
cmd/trace: add option to output pprof files (CL 23324)
|
||||
cmd/trace: fix a runnable goroutine count bug (CL 25552)
|
||||
cmd/trace: move process-wide GC events to their own row (CL 30017)
|
||||
cmd/vet: accept space-separated tag lists for compatibility with cmd/go (CL 32030)
|
||||
cmd/vet: allow ^& uintptr arithmetic (CL 27156)
|
||||
cmd/vet: allow any printf verb with any interface (CL 27127)
|
||||
cmd/vet: check for copying of array of locks (CL 24340)
|
||||
cmd/vet: check for duplicate json, xml struct field tags (CL 16704)
|
||||
cmd/vet: diagnose non-space-separated struct tag like `json:"x",xml:"y"` (CL 32031)
|
||||
cmd/vet: improve asmdecl parameter handling (CL 27150)
|
||||
cmd/vet: properly handle indexed arguments in printf (CL 24391)
|
||||
cmd/vet: skip printf check for non-constant format string during failed import (CL 29014)
|
||||
compress/flate: always return uncompressed data in the event of error (CL 28216)
|
||||
compress/flate: level 1 (best speed) match across blocks (CL 31640)
|
||||
compress/flate: make compression level 0 consistent (CL 31174)
|
||||
compress/flate: tighten the BestSpeed max match offset bound. (CL 32149)
|
||||
compress/gzip, compress/zlib: add HuffmanOnly as compression levels. (CL 31186)
|
||||
compress/gzip: only encode MTIME if it is valid (CL 32325)
|
||||
context: make DeadlineExceeded implement net.Error (CL 30370)
|
||||
crypto/cipher: enforce message size limits for GCM (CL 28410)
|
||||
crypto/rsa: ensure that generating toy RSA keys doesn't loop (CL 28969)
|
||||
crypto/tls: add CloseWrite method to Conn (CL 25159)
|
||||
crypto/tls: add CloseWrite method to Conn (CL 31318)
|
||||
crypto/tls: add Config.Clone (CL 28075)
|
||||
crypto/tls: add Config.GetConfigForClient (CL 30790)
|
||||
crypto/tls: add GetClientCertificate callback (CL 32115)
|
||||
crypto/tls: add KeyLogWriter for debugging (CL 27434)
|
||||
crypto/tls: add VerifyPeerCertificate to tls.Config (CL 26654)
|
||||
crypto/tls: add a SignatureScheme type. (CL 32119)
|
||||
crypto/tls: don't generate random ticket keys if already set (CL 27317)
|
||||
crypto/tls: enable ChaCha20-Poly1305 cipher suites by default. (CL 30958)
|
||||
crypto/tls: expand ClientHelloInfo (CL 31391)
|
||||
crypto/tls: fix deadlock when racing to complete handshake (CL 29164)
|
||||
crypto/tls: flush the buffer on handshake errors (CL 28818)
|
||||
crypto/tls: implement countermeasures against CBC padding oracles (CL 18130)
|
||||
crypto/tls: set Conn.ConnectionState.ServerName unconditionally (CL 22862)
|
||||
crypto/tls: support AES-128-CBC cipher suites with SHA-256 (CL 27315)
|
||||
crypto/tls: support ChaCha20-Poly1305. (CL 30957)
|
||||
crypto/tls: support X25519 (CL 30824, CL 30825)
|
||||
crypto/x509: Fix bug in UnknownAuthorityError.Error (CL 27992)
|
||||
crypto/x509: allow a leaf certificate to be specified directly as root (CL 27393)
|
||||
crypto/x509: check that the issuer name matches the issuer's subject name (CL 23571)
|
||||
crypto/x509: don't accept a root that already appears in a chain. (CL 32121)
|
||||
crypto/x509: fix name constraints handling (CL 30155)
|
||||
crypto/x509: implement SystemCertPool on Windows (CL 30578)
|
||||
crypto/x509: parse all names in an RDN (CL 30810)
|
||||
crypto/x509: recognise ISO OID for RSA+SHA1 (CL 27394)
|
||||
crypto/x509: require a NULL parameters for RSA public keys (CL 16166)
|
||||
crypto/x509: require a NULL parameters for RSA public keys (CL 27312)
|
||||
crypto/x509: return error for missing SerialNumber (CL 27238)
|
||||
crypto/x509: support PSS signatures (CL 24743)
|
||||
crypto/x509: support RHEL 7 cert bundle (CL 30375)
|
||||
database/sql: accept nil pointers to Valuers implemented on value receivers (CL 31259)
|
||||
database/sql: add Pinger interface to driver Conn (CL 32136)
|
||||
database/sql: add context helper methods and transaction types (CL 31258)
|
||||
database/sql: add context methods (CL 29381)
|
||||
database/sql: add option to use named parameter in query arguments (CL 30166)
|
||||
database/sql: add support for multiple result sets (CL 30592)
|
||||
database/sql: don't hang if the driver Exec method panics (CL 23576)
|
||||
database/sql: support returning query database types (CL 29961)
|
||||
debug/elf: add sparc64 relocations (CL 30870)
|
||||
debug/pe: revert CL 22720 (CL 27212)
|
||||
doc: document minimum OS X version as 10.8 (CL 28870)
|
||||
encoding/base64: add Encoding.Strict (CL 24964)
|
||||
encoding/binary: add bool support (CL 28514)
|
||||
encoding/json: add struct and field name to UnmarshalTypeError message (CL 18692)
|
||||
encoding/json: fix decoding of null into Unmarshaler, TextUnmarshaler (CL 30944)
|
||||
encoding/json: marshal the RawMessage value type the same as its pointer type (CL 21811)
|
||||
encoding/json: use standard ES6 formatting for numbers during marshal (CL 30371)
|
||||
encoding/pem: be stricter about the ending line (CL 27391)
|
||||
encoding/xml: add wildcard support for collecting all attributes (CL 30946)
|
||||
encoding/xml: prevent omitempty from omitting non-nil pointers to empty values (CL 15684)
|
||||
expvar: add Value methods (CL 30917)
|
||||
expvar: export http.Handler (CL 24722)
|
||||
flag: arrange for FlagSet.Usage to be non-nil by default (CL 31576)
|
||||
fmt: document and adjust Scanf space handling to eliminate a few paradoxes (CL 30611)
|
||||
go/ast, go/parser: parse alias declarations (CL 30211)
|
||||
go/build: allow % in ${SRCDIR} expansion for Jenkins (CL 31611)
|
||||
go/build: do not record go:binary-only-package if build tags not satisfied (CL 31577)
|
||||
go/build: implement default GOPATH (CL 32019)
|
||||
|
||||
go/doc: add IsPredeclared function (CL 29870)
|
||||
go/doc: allow ToHTML to properly handle URLs containing semicolons (CL 25385)
|
||||
go/internal/gcimporter: fail gracefully on export format skew (CL 27816)
|
||||
go/token: fix race in FileSet.PositionFor. (CL 25345)
|
||||
go/types: expose Default function, which converts untyped T to T (CL 30715)
|
||||
go/types: handle imported aliases (CL 32534)
|
||||
go/types: match cmd/compile's alignment for complex64 (CL 31939)
|
||||
go/types: minimal support for alias declarations: don't crash (CL 30213)
|
||||
html/template: check "type" attribute in <script> (CL 14336)
|
||||
image/color: tweak the formula for converting to gray. (CL 31538)
|
||||
image/png: implement grayscale transparency. (CL 32143)
|
||||
image/png: implement truecolor transparency. (CL 32140)
|
||||
image/png: improve compression by skipping filter for paletted images (CL 29872)
|
||||
internal/trace: fix analysis of EvGoWaiting/EvGoInSyscall events (CL 25572)
|
||||
io: fix infinite loop bug in MultiReader (CL 27397)
|
||||
io: make MultiReader nil exhausted Readers for earlier GC (CL 28533)
|
||||
math/big: Rat.SetString to report error if input is not consumed entirely (CL 30472)
|
||||
math/big: add (*Int).Sqrt (CL 30706)
|
||||
math/big: implement Float.Scan, type assert fmt interfaces to enforce docs (CL 30723)
|
||||
math/big: support negative numbers in ModInverse (CL 29299)
|
||||
math/big: test and optimize Exp(2, y, n) for large y, odd n (CL 30708)
|
||||
math/cmplx: prevent infinite loop in tanSeries (CL 31952)
|
||||
math/rand: add Rand.Uint64 (CL 27253)
|
||||
math: fix Gamma(-171.5) on all platforms (CL 30540)
|
||||
mime/quotedprintable: accept = not followed by 2 hex digits as literal equals (CL 32174)
|
||||
mime/quotedprintable: accept trailing soft line-break at the end of message (CL 27530)
|
||||
mime: preserve unnecessary backslash escapes as literals (CL 32175)
|
||||
net/http, net/http/httptest: make http2's TrailerPrefix work for http1 (CL 32479)
|
||||
net/http/httptest: fill ContentLength in recorded Response (CL 28302)
|
||||
net/http/httptrace: add ClientTrace.TLSHandshakeStart & TLSHandshakeDone (CL 30359)
|
||||
net/http/httputil: add ModifyResponse to reverseProxy (CL 32356)
|
||||
net/http/httputil: copy header map if necessary in ReverseProxy (CL 28493)
|
||||
net/http/httputil: log err encountered during reverseproxy body copying (CL 30692)
|
||||
net/http/httputil: make ReverseProxy send nil Body requests when possible (CL 28412)
|
||||
net/http/httputil: remove custom hop-by-hop headers from response in ReverseProxy (CL 28810)
|
||||
net/http/httputil: remove proxied headers mentioned in connection-tokens (CL 27970)
|
||||
net/http/internal: don't block unnecessarily in ChunkedReader (CL 31329)
|
||||
net/http: add NoBody, don't return nil from NewRequest on zero bodies (CL 31726)
|
||||
net/http: add Request.GetBody func for 307/308 redirects (CL 31733)
|
||||
net/http: add Server.Close & Server.Shutdown for forced & graceful shutdown (CL 32329)
|
||||
net/http: add Server.ReadHeaderTimeout, IdleTimeout, document WriteTimeout (CL 32024)
|
||||
net/http: add Transport.ProxyConnectHeader to control headers to proxies (CL 32481)
|
||||
net/http: add an interface for HTTP/2 server push (CL 32012)
|
||||
net/http: allow Handlers to test Hijacked conn without spamming error log (CL 30812)
|
||||
net/http: don't sniff Request.Body on 100-continue requests in Transport (CL 30151)
|
||||
net/http: handle 3xx redirects properly (CL 29852)
|
||||
net/http: make Client copy headers on redirect (CL 28930)
|
||||
net/http: make DefaultTransport's Dialer enable DualStack ("Happy Eyeballs") (CL 28077)
|
||||
net/http: make NewRequest set empty Body nil, don't peek Read Body in Transport (CL 31445)
|
||||
net/http: make Redirect escape non-ASCII in Location header (CL 31732)
|
||||
net/http: make Server Handler's Request.Context be done on conn errors (CL 31173)
|
||||
net/http: make Transport reject URLs with bogus ports with non-digits (CL 32482)
|
||||
net/http: make Transport retry non-idempotent requests if no bytes written (CL 27117)
|
||||
net/http: make Transport support international domain names (CL 29072)
|
||||
net/http: omit Content-Length in Response.Write for 1xx or 204 status (CL 28351)
|
||||
net/http: returned typed error on Transport proxy dial (CL 30750)
|
||||
net/http: send Content-Range if no byte range overlaps (CL 24212)
|
||||
net/http: skip test needing good DNS in short mode, except on builders (CL 28782)
|
||||
net/http: support multiple identical Content-Length headers (CL 31252)
|
||||
net/http: update bundled http2, add h2 Transport.IdleConnTimeout tests (CL 30078)
|
||||
net/mail: allow empty quoted string name in address again (CL 32176)
|
||||
net/mail: expose ParseDate, for use parsing Resent-Date headers (CL 31581)
|
||||
net/url: add PathEscape, PathUnescape (CL 31322)
|
||||
net/url: add URL.Hostname and URL.Port accessors (CL 28933)
|
||||
net/url: handle escaped paths in ResolveReference (CL 28343)
|
||||
net/url: make URL implement encoding.BinaryMarshaler, BinaryUnmarshaler (CL 31467)
|
||||
net/url: prefix relative paths containing ":" in the first segment with "./" (CL 29610)
|
||||
net/url: reject colon in first segment of relative path in Parse (CL 31582)
|
||||
net: add (*UnixListener).SetUnlinkOnClose (CL 32099)
|
||||
net: add Buffers type, do writev on unix (CL 29951)
|
||||
net: add Resolver type, Dialer.Resolver, and DefaultResolver (CL 29440)
|
||||
net: always wake up the readers on close on Plan 9 (CL 31390)
|
||||
net: break up >1GB reads and writes on stream connections (CL 31584)
|
||||
net: close the connection gracefully on Plan 9 (CL 31271)
|
||||
net: implement network interface API for Plan 9 (CL 29963)
|
||||
net: implement network interface API for Solaris (CL 29892)
|
||||
net: make LookupPort and lookupProtocol work on nacl (CL 28951)
|
||||
net: make lookupPort case-insensitive on Plan 9 (CL 29051)
|
||||
net: only remove Unix domain socket file on the first call to Close (CL 32098)
|
||||
net: remove parsing of negative decimals in IPv4 literal (CL 28414)
|
||||
net: respect resolv.conf rotate option (CL 29233)
|
||||
net: support "option ndots:0" in resolv.conf (CL 24901)
|
||||
net: there are no invalid domain names anymore (CL 31468)
|
||||
net: use libresolv rules for ndots range and validation (CL 24901)
|
||||
os, syscall: fix incorrect offset calculation in Readlink on windows (CL 31118)
|
||||
os: add ErrClosed, return for use of closed File (CL 30614)
|
||||
os: add Executable() (CL 16551)
|
||||
os: consider only files from #M as regular on Plan 9 (CL 32152)
|
||||
os: don't let File.Readdir return an empty slice and nil error (CL 28056)
|
||||
os: make IsExist report true on ERROR_DIR_NOT_EMPTY on Windows (CL 29753)
|
||||
os: make Windows readConsole handle input and output correctly (CL 29493)
|
||||
os: prevent infinite symlink loop of Stat on Windows (CL 27580)
|
||||
os: reject Rename("old", "new") where new is a directory (CL 31358)
|
||||
os: use GetConsoleCP() instead of GetACP() (CL 27575)
|
||||
path/filepath: don't return SkipDir at top (CL 24780)
|
||||
path/filepath: fix Abs on Windows (CL 32292)
|
||||
path/filepath: fix match of \\?\c:\* on Windows (CL 31460)
|
||||
path/filepath: handle ".." in normalizing a path on Windows (CL 27410)
|
||||
path/filepath: handle "C:." correctly in EvalSymlinks on Windows (CL 28214)
|
||||
plugin: darwin support (CL 29392)
|
||||
plugin: mention OS X support and concurrency (CL 31463)
|
||||
plugin: new package for loading plugins (CL 27823)
|
||||
reflect: add Swapper func (CL 30088)
|
||||
reflect: fix DeepEqual for some cyclic corner cases (CL 31588)
|
||||
reflect: ignore struct tags when converting structs (CL 30191)
|
||||
runtime, cmd/trace: annotate different mark worker types (CL 30702)
|
||||
runtime, runtime/cgo: revert CL 18814; don't drop signal stack in new thread on dragonfly (CL 29971)
|
||||
runtime/pprof: write profiles in protobuf format. (CL 32257)
|
||||
runtime/race: don't crash on invalid PCs (CL 29714)
|
||||
runtime/race: update race runtime (CL 32160)
|
||||
runtime: Profile goroutines holding contended mutexes. (CL 29650)
|
||||
runtime: assume 64kB physical pages on ARM (CL 25021)
|
||||
runtime: disable stack rescanning by default (CL 31766)
|
||||
runtime: don't call cgocallback from signal handler (CL 30218)
|
||||
runtime: fetch physical page size from the OS (CL 25050)
|
||||
runtime: fix check for vacuous page boundary rounding (CL 27230)
|
||||
runtime: fix map iterator concurrent map check (CL 24749)
|
||||
runtime: fix newextram PC passed to race detector (CL 29712)
|
||||
runtime: implement unconditional hybrid barrier (CL 31765)
|
||||
runtime: include pre-panic/throw logs in core dumps (CL 32013)
|
||||
runtime: limit the number of map overflow buckets (CL 25049)
|
||||
runtime: pass windows float syscall args via XMM (CL 32173)
|
||||
runtime: print sigcode on signal crash (CL 32183)
|
||||
runtime: record current PC for SIGPROF on non-Go thread (CL 30252)
|
||||
runtime: report GCSys and OtherSys in heap profile (CL 29276)
|
||||
runtime: sleep on CLOCK_MONOTONIC in futexsleep1 on freebsd (CL 30154)
|
||||
runtime: use RtlGenRandom instead of CryptGenRandom (CL 29700)
|
||||
runtime: use clock_gettime(CLOCK_REALTIME) for nanosecond-precision time.now on arm64, mips64x (CL 32177)
|
||||
runtime: use correct system page size on all arches (CL 25022)
|
||||
sort: add Slice, SliceStable, and SliceIsSorted (CL 27321)
|
||||
spec: add new language for alias declarations (CL 30601)
|
||||
spec: ignore struct tags when converting structs (CL 24190)
|
||||
spec: require 16 bit minimum exponent in constants rather than 32 (CL 17711)
|
||||
spec: update language on type switches to match implementations (CL 27356)
|
||||
strconv: strip \r in raw strings passed to Unquote (CL 31210)
|
||||
strings, bytes: panic if Repeat overflows or if given a negative count (CL 29954)
|
||||
sync: enable Pool when using race detector (CL 31589)
|
||||
sync: throw, not panic, for unlock of unlocked mutex (CL 31359)
|
||||
syscall: add bounds checking and error returns to ParseNetlinkMessage (CL 26990)
|
||||
syscall: fix Send{msg,msgN}, Recvmsg and control message handling on solaris (CL 30171)
|
||||
syscall: make Getpagesize return system-reported page size (CL 25051)
|
||||
syscall: make Utimes on Solaris match all the other geese (CL 31446)
|
||||
syscall: remove X__cmsg_data from Cmsghdr (CL 32319)
|
||||
syscall: unify NsecToTime{spec,val}, fix for times < 1970 (CL 30826)
|
||||
syscall: validate ParseDirent inputs (CL 23780)
|
||||
testing/quick, text/tabwriter: freeze packages (CL 31910)
|
||||
testing: add Name method to *T and *B (CL 29970)
|
||||
testing: add a method testing.CoverMode (CL 32483)
|
||||
testing: respect benchtime on very fast benchmarks (CL 26664)
|
||||
text/template: add support for reflect.Value args, results in funcs (CL 31462)
|
||||
time: add Until helper function (CL 20118)
|
||||
time: allow long fractions in ParseDuration (CL 29338)
|
||||
time: be consistent about representation of UTC location in Time struct (CL 31144)
|
||||
unicode: change SimpleFold to handle invalid runes (CL 30935)
|
||||
website: recreate 16px and 32px favicon (CL 26850)
|
||||
|
||||
Optimizations:
|
||||
|
||||
bytes, strings: optimize for ASCII sets (CL 31593)
|
||||
bytes, strings: optimize multi-byte index operations on s390x (CL 32447)
|
||||
bytes,strings: use IndexByte more often in Index on AMD64 (CL 31690)
|
||||
bytes: Use the same algorithm as strings for Index (CL 22550)
|
||||
bytes: improve WriteRune performance (CL 28816)
|
||||
bytes: improve performance for bytes.Compare on ppc64x (CL 30949)
|
||||
bytes: make IndexRune faster (CL 28537)
|
||||
cmd/asm, go/build: invoke cmd/asm only once per package (CL 27636)
|
||||
cmd/compile, cmd/link: more efficient typelink generation (CL 31772)
|
||||
cmd/compile, cmd/link: stop generating unused go.string.hdr symbols. (CL 31030)
|
||||
cmd/compile,runtime: redo how map assignments work (CL 30815)
|
||||
cmd/compile/internal/obj/x86: eliminate some function prologues (CL 24814)
|
||||
cmd/compile: accept literals in samesafeexpr (CL 26666)
|
||||
cmd/compile: add more non-returning runtime calls (CL 28965)
|
||||
cmd/compile: add size hint to map literal allocations (CL 23558)
|
||||
cmd/compile: be more aggressive in tighten pass for booleans (CL 28390)
|
||||
cmd/compile: directly construct Fields instead of ODCLFIELD nodes (CL 31670)
|
||||
cmd/compile: don't reserve X15 for float sub/div any more (CL 28272)
|
||||
cmd/compile: don’t generate pointless gotos during inlining (CL 27461)
|
||||
cmd/compile: fold negation into comparison operators (CL 28232)
|
||||
cmd/compile: generate makeslice calls with int arguments (CL 27851)
|
||||
cmd/compile: handle e == T comparison more efficiently (CL 26660)
|
||||
cmd/compile: improve s390x SSA rules for logical ops (CL 31754)
|
||||
cmd/compile: improve s390x rules for folding ADDconst into loads/stores (CL 30616)
|
||||
cmd/compile: improve string iteration performance (CL 27853)
|
||||
cmd/compile: improve tighten pass (CL 28712)
|
||||
cmd/compile: inline _, ok = i.(T) (CL 26658)
|
||||
cmd/compile: inline atomics from runtime/internal/atomic on amd64 (CL 27641, CL 27813)
|
||||
cmd/compile: inline convT2{I,E} when result doesn't escape (CL 29373)
|
||||
cmd/compile: inline x, ok := y.(T) where T is a scalar (CL 26659)
|
||||
cmd/compile: intrinsify atomic operations on s390x (CL 31614)
|
||||
cmd/compile: intrinsify math/big.mulWW, divWW on AMD64 (CL 30542)
|
||||
cmd/compile: intrinsify runtime/internal/atomic.Xaddint64 (CL 29274)
|
||||
cmd/compile: intrinsify slicebytetostringtmp when not instrumenting (CL 29017)
|
||||
cmd/compile: intrinsify sync/atomic for amd64 (CL 28076)
|
||||
cmd/compile: make [0]T and [1]T SSAable types (CL 32416)
|
||||
cmd/compile: make link register allocatable in non-leaf functions (CL 30597)
|
||||
cmd/compile: missing float indexed loads/stores on amd64 (CL 28273)
|
||||
cmd/compile: move stringtoslicebytetmp to the backend (CL 32158)
|
||||
cmd/compile: only generate ·f symbols when necessary (CL 31031)
|
||||
cmd/compile: optimize bool to int conversion (CL 22711)
|
||||
cmd/compile: optimize integer "in range" expressions (CL 27652)
|
||||
cmd/compile: remove Zero and NilCheck for newobject (CL 27930)
|
||||
cmd/compile: remove duplicate nilchecks (CL 29952)
|
||||
cmd/compile: remove some write barriers for stack writes (CL 30290)
|
||||
cmd/compile: simplify div/mod on ARM (CL 29390)
|
||||
cmd/compile: statically initialize some interface values (CL 26668)
|
||||
cmd/compile: unroll comparisons to short constant strings (CL 26758)
|
||||
cmd/compile: use 2-result divide op (CL 25004)
|
||||
cmd/compile: use masks instead of branches for slicing (CL 32022)
|
||||
cmd/compile: when inlining ==, don’t take the address of the values (CL 22277)
|
||||
container/heap: remove one unnecessary comparison in Fix (CL 24273)
|
||||
crypto/sha256: improve performance for sha256.block on ppc64le (CL 32318)
|
||||
crypto/sha512: improve performance for sha512.block on ppc64le (CL 32320)
|
||||
crypto/{aes,cipher}: add optimized implementation of AES-GCM for s390x (CL 30361)
|
||||
encoding/asn1: reduce allocations in Marshal (CL 27030)
|
||||
encoding/csv: avoid allocations when reading records (CL 24723)
|
||||
encoding/hex: change lookup table from string to array (CL 27254)
|
||||
encoding/json: Use a lookup table for safe characters (CL 24466)
|
||||
hash/crc32: improve the AMD64 implementation using SSE4.2 (CL 24471)
|
||||
hash/crc32: improve the AMD64 implementation using SSE4.2 (CL 27931)
|
||||
hash/crc32: improve the processing of the last bytes in the SSE4.2 code for AMD64 (CL 24470)
|
||||
image/color: improve speed of RGBA methods (CL 31773)
|
||||
image/draw: optimize drawFillOver as drawFillSrc for opaque fills (CL 28790)
|
||||
math/big: avoid allocation in float.{Add, Sub} when there's no aliasing (CL 23568)
|
||||
math/big: make division faster (CL 30613)
|
||||
math/big: slightly faster float->decimal conversion (CL 31250)
|
||||
math/big: use array instead of slice for deBruijn lookups (CL 26663)
|
||||
math/big: uses SIMD for some math big functions on s390x (CL 32211)
|
||||
math: speed up Gamma(+Inf) (CL 31370)
|
||||
math: speed up bessel functions on AMD64 (CL 28086)
|
||||
reflect: avoid zeroing memory that will be overwritten (CL 28011)
|
||||
regexp: avoid alloc in QuoteMeta when not quoting (CL 31395)
|
||||
regexp: reduce mallocs in Regexp.Find* and Regexp.ReplaceAll* (CL 23030)
|
||||
runtime: cgo calls are about 100ns faster (CL 29656, CL 30080)
|
||||
runtime: defer is now 2X faster (CL 29656)
|
||||
runtime: implement getcallersp in Go (CL 29655)
|
||||
runtime: improve memmove for amd64 (CL 22515, CL 29590)
|
||||
runtime: increase malloc size classes (CL 24493)
|
||||
runtime: large objects no longer cause significant goroutine pauses (CL 23540)
|
||||
runtime: make append only clear uncopied memory (CL 30192)
|
||||
runtime: make assists perform root jobs (CL 32432)
|
||||
runtime: memclr perf improvements on ppc64x (CL 30373)
|
||||
runtime: minor string/rune optimizations (CL 27460)
|
||||
runtime: optimize defer code (CL 29656)
|
||||
runtime: remove a load and shift from scanobject (CL 22712)
|
||||
runtime: remove defer from standard cgo call (CL 30080)
|
||||
runtime: speed up StartTrace with lots of blocked goroutines (CL 25573)
|
||||
runtime: speed up non-ASCII rune decoding (CL 28490)
|
||||
strconv: make FormatFloat slowpath a little faster (CL 30099)
|
||||
strings: add special cases for Join of 2 and 3 strings (CL 25005)
|
||||
strings: make IndexRune faster (CL 28546)
|
||||
strings: use AVX2 for Index if available (CL 22551)
|
||||
strings: use Index in Count (CL 28586)
|
||||
syscall: avoid convT2I allocs for common Windows error values (CL 28484, CL 28990)
|
||||
text/template: improve lexer performance in finding left delimiters (CL 24863)
|
||||
unicode/utf8: optimize ValidRune (CL 32122)
|
||||
unicode/utf8: reduce bounds checks in EncodeRune (CL 28492)
|
||||
|
||||
Documentation:
|
||||
|
||||
all: many more examples in documentations (many CLs)
|
||||
runtime: runtime.MemStats has much more detailed documentation (CL 28972)
|
||||
|
||||
Binary Size:
|
||||
|
||||
cmd/link: more efficient encoding of DWARF line number information (CL 30577)
|
||||
cmd/compile: recognize integer ranges in switch statements (CL 26770)
|
||||
cmd/compile: use two tables for table-driven map inserts (CL 26669)
|
||||
cmd/link: when dynlinking, do not mangle short symbol names (CL 26890)
|
||||
cmd/compile, runtime: stop padding stackmaps to 4 bytes (CL 30817)
|
||||
|
||||
@@ -769,29 +769,6 @@ for i, v := range t {
|
||||
}
|
||||
</pre>
|
||||
|
||||
<h3 id="convert_slice_with_same_underlying_type">
|
||||
Can I convert []T1 to []T2 if T1 and T2 have the same underlying type?</h3>
|
||||
|
||||
This last line of this code sample does not compile.
|
||||
|
||||
<pre>
|
||||
type T1 int
|
||||
type T2 int
|
||||
var t1 T1
|
||||
var x = T2(t1) // OK
|
||||
var st1 []T1
|
||||
var sx = ([]T2)(st1) // NOT OK
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
In Go, types are closely tied to methods, in that every named type has
|
||||
a (possibly empty) method set.
|
||||
The general rule is that you can change the name of the type being
|
||||
converted (and thus possibly change its method set) but you can't
|
||||
change the name (and method set) of elements of a composite type.
|
||||
Go requires you to be explicit about type conversions.
|
||||
</p>
|
||||
|
||||
<h3 id="nil_error">
|
||||
Why is my nil error value not equal to nil?
|
||||
</h3>
|
||||
@@ -1094,7 +1071,7 @@ it's easy to work around this. For GitHub, try one of these solutions:
|
||||
<ul>
|
||||
<li>Manually clone the repository in the expected package directory:
|
||||
<pre>
|
||||
$ cd src/github.com/username
|
||||
$ cd $GOPATH/src/github.com/username
|
||||
$ git clone git@github.com:username/package.git
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!--{
|
||||
"Title": "The Go Programming Language Specification",
|
||||
"Subtitle": "Version of November 18, 2016",
|
||||
"Subtitle": "Version of November 4, 2016",
|
||||
"Path": "/ref/spec"
|
||||
}-->
|
||||
|
||||
@@ -265,7 +265,7 @@ The following character sequences represent <a href="#Operators">operators</a>,
|
||||
* ^ *= ^= <- > >= { }
|
||||
/ << /= <<= ++ = := , ;
|
||||
% >> %= >>= -- ! ... . :
|
||||
&^ &^=
|
||||
&^ &^= =>
|
||||
</pre>
|
||||
|
||||
<h3 id="Integer_literals">Integer literals</h3>
|
||||
@@ -2006,7 +2006,7 @@ _, y, _ := coord(p) // coord() returns three values; only interested in y coord
|
||||
<p>
|
||||
Unlike regular variable declarations, a short variable declaration may <i>redeclare</i>
|
||||
variables provided they were originally declared earlier in the same block
|
||||
(or the parameter lists if the block is the function body) with the same type,
|
||||
(or the parameter lists if the block is the function body) with the same type,
|
||||
and at least one of the non-<a href="#Blank_identifier">blank</a> variables is new.
|
||||
As a consequence, redeclaration can only appear in a multi-variable short declaration.
|
||||
Redeclaration does not introduce a new variable; it just assigns a new value to the original.
|
||||
@@ -2352,11 +2352,10 @@ the <code>&T</code> when the element or key type is <code>*T</code>.
|
||||
[][]int{{1, 2, 3}, {4, 5}} // same as [][]int{[]int{1, 2, 3}, []int{4, 5}}
|
||||
[][]Point{{{0, 1}, {1, 2}}} // same as [][]Point{[]Point{Point{0, 1}, Point{1, 2}}}
|
||||
map[string]Point{"orig": {0, 0}} // same as map[string]Point{"orig": Point{0, 0}}
|
||||
map[Point]string{{0, 0}: "orig"} // same as map[Point]string{Point{0, 0}: "orig"}
|
||||
|
||||
type PPoint *Point
|
||||
[2]*Point{{1.5, -3.5}, {}} // same as [2]*Point{&Point{1.5, -3.5}, &Point{}}
|
||||
[2]PPoint{{1.5, -3.5}, {}} // same as [2]PPoint{PPoint(&Point{1.5, -3.5}), PPoint(&Point{})}
|
||||
[...]*Point{{1.5, -3.5}, {0, 0}} // same as [...]*Point{&Point{1.5, -3.5}, &Point{0, 0}}
|
||||
|
||||
map[Point]string{{0, 0}: "orig"} // same as map[Point]string{Point{0, 0}: "orig"}
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -4799,8 +4798,8 @@ The "fallthrough" statement is not permitted in a type switch.
|
||||
<h3 id="For_statements">For statements</h3>
|
||||
|
||||
<p>
|
||||
A "for" statement specifies repeated execution of a block. There are three forms:
|
||||
The iteration may be controlled by a single condition, a "for" clause, or a "range" clause.
|
||||
A "for" statement specifies repeated execution of a block. The iteration is
|
||||
controlled by a condition, a "for" clause, or a "range" clause.
|
||||
</p>
|
||||
|
||||
<pre class="ebnf">
|
||||
@@ -4808,8 +4807,6 @@ ForStmt = "for" [ Condition | ForClause | RangeClause ] Block .
|
||||
Condition = Expression .
|
||||
</pre>
|
||||
|
||||
<h4 id="For_condition">For statements with single condition</h4>
|
||||
|
||||
<p>
|
||||
In its simplest form, a "for" statement specifies the repeated execution of
|
||||
a block as long as a boolean condition evaluates to true.
|
||||
@@ -4824,8 +4821,6 @@ for a < b {
|
||||
}
|
||||
</pre>
|
||||
|
||||
<h4 id="For_clause">For statements with <code>for</code> clause</h4>
|
||||
|
||||
<p>
|
||||
A "for" statement with a ForClause is also controlled by its condition, but
|
||||
additionally it may specify an <i>init</i>
|
||||
@@ -4864,8 +4859,6 @@ for cond { S() } is the same as for ; cond ; { S() }
|
||||
for { S() } is the same as for true { S() }
|
||||
</pre>
|
||||
|
||||
<h4 id="For_range">For statements with <code>range</code> clause</h4>
|
||||
|
||||
<p>
|
||||
A "for" statement with a "range" clause
|
||||
iterates through all entries of an array, slice, string or map,
|
||||
|
||||
@@ -430,7 +430,7 @@ to override the defaults.
|
||||
<ul>
|
||||
<li><code>$GOROOT</code>
|
||||
<p>
|
||||
The root of the Go tree, often <code>$HOME/go1.X</code>.
|
||||
The root of the Go tree, often <code>$HOME/go</code>.
|
||||
Its value is built into the tree when it is compiled, and
|
||||
defaults to the parent of the directory where <code>all.bash</code> was run.
|
||||
There is no need to set this unless you want to switch between multiple
|
||||
@@ -632,7 +632,7 @@ something like this:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
export GOROOT=$HOME/go1.X
|
||||
export GOROOT=$HOME/go
|
||||
export GOARCH=amd64
|
||||
export GOOS=linux
|
||||
</pre>
|
||||
|
||||
@@ -117,12 +117,12 @@ to point to the directory in which it was installed.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For example, if you installed Go to your home directory you should add
|
||||
commands like the following to <code>$HOME/.profile</code>:
|
||||
For example, if you installed Go to your home directory you should add the
|
||||
following commands to <code>$HOME/.profile</code>:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
export GOROOT=$HOME/go1.X
|
||||
export GOROOT=$HOME/go
|
||||
export PATH=$PATH:$GOROOT/bin
|
||||
</pre>
|
||||
|
||||
@@ -219,16 +219,37 @@ and building a simple program, as follows.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Create your <a href="code.html#Workspaces">workspace</a> directory,
|
||||
<code class="testUnix">$HOME/go</code><code class="testWindows">%USERPROFILE%\go</code>.
|
||||
(If you'd like to use a different directory,
|
||||
you will need to set the <code>GOPATH</code> environment variable;
|
||||
see <a href="code.html#Workspaces">How to Write Go Code</a> for details.)
|
||||
Create a directory to contain your <a href="code.html#Workspaces">workspace</a>,
|
||||
<code class="testUnix">$HOME/work</code>
|
||||
<code class="testWindows" style="display: none">C:\work</code>
|
||||
for example, and set the <code>GOPATH</code> environment
|
||||
variable to point to that location.
|
||||
</p>
|
||||
|
||||
<pre class="testUnix">
|
||||
$ <b>export GOPATH=$HOME/work</b>
|
||||
</pre>
|
||||
|
||||
<pre class="testWindows" style="display: none">
|
||||
C:\> <b>set GOPATH=C:\work</b>
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
<span class="testUnix">
|
||||
You should put the above command in your shell startup script
|
||||
(<code>$HOME/.profile</code> for example).
|
||||
</span>
|
||||
<span class="testWindows">
|
||||
On Windows, follow the <a href="#windows_env">instructions above</a> to set the
|
||||
<code>GOPATH</code> environment variable on your system.
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Next, make the directory <code>src/hello</code> inside your workspace,
|
||||
and in that directory create a file named <code>hello.go</code> that looks like:
|
||||
Next, make the directories <code>src/github.com/user/hello</code> inside your
|
||||
workspace (if you use GitHub, substitute your user name for <code>user</code>),
|
||||
and inside the <code>hello</code> directory create a file named <code>hello.go</code>
|
||||
with the following contents:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
@@ -242,33 +263,30 @@ func main() {
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Then build it with the <code>go</code> tool:
|
||||
Then compile it with the <code>go</code> tool:
|
||||
</p>
|
||||
|
||||
<pre class="testUnix">
|
||||
$ <b>cd $HOME/go/src/hello
|
||||
$ <b>go build</b>
|
||||
$ <b>go install github.com/user/hello</b>
|
||||
</pre>
|
||||
|
||||
<pre class="testWindows" style="display: none">
|
||||
C:\> <b>cd %USERPROFILE%\go\src\hello<b>
|
||||
C:\Users\Gopher\go\src\hello> <b>go build</b>
|
||||
C:\> <b>go install github.com/user/hello</b>
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The command above will build an executable named
|
||||
<code class="testUnix">hello</code><code class="testWindows">hello.exe</code>
|
||||
in the directory alongside your source code.
|
||||
Execute it to see the greeting:
|
||||
The command above will put an executable command named <code>hello</code>
|
||||
(or <code>hello.exe</code>) inside the <code>bin</code> directory of your workspace.
|
||||
Execute the command to see the greeting:
|
||||
</p>
|
||||
|
||||
<pre class="testUnix">
|
||||
$ <b>./hello</b>
|
||||
$ <b>$GOPATH/bin/hello</b>
|
||||
hello, world
|
||||
</pre>
|
||||
|
||||
<pre class="testWindows" style="display: none">
|
||||
C:\Users\Gopher\go\src\hello> <b>hello</b>
|
||||
C:\> <b>%GOPATH%\bin\hello</b>
|
||||
hello, world
|
||||
</pre>
|
||||
|
||||
@@ -276,12 +294,6 @@ hello, world
|
||||
If you see the "hello, world" message then your Go installation is working.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You can run <code>go</code> <code>install</code> to install the binary into
|
||||
your workspace's <code>bin</code> directory
|
||||
or <code>go</code> <code>clean</code> to remove it.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Before rushing off to write Go code please read the
|
||||
<a href="/doc/code.html">How to Write Go Code</a> document,
|
||||
|
||||
@@ -28,7 +28,7 @@ func Encode() {
|
||||
|
||||
expected := []byte(`{"Name":"Alice","Body":"Hello","Time":1294706395881547000}`)
|
||||
if !reflect.DeepEqual(b, expected) {
|
||||
log.Panicf("Error marshaling %q, expected %q, got %q.", m, expected, b)
|
||||
log.Panicf("Error marshalling %q, expected %q, got %q.", m, expected, b)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func Decode() {
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(m, expected) {
|
||||
log.Panicf("Error unmarshaling %q, expected %q, got %q.", b, expected, m)
|
||||
log.Panicf("Error unmarshalling %q, expected %q, got %q.", b, expected, m)
|
||||
}
|
||||
|
||||
m = Message{
|
||||
@@ -77,7 +77,7 @@ func PartialDecode() {
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(expected, m) {
|
||||
log.Panicf("Error unmarshaling %q, expected %q, got %q.", b, expected, m)
|
||||
log.Panicf("Error unmarshalling %q, expected %q, got %q.", b, expected, m)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ func Decode() {
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(f, expected) {
|
||||
log.Panicf("Error unmarshaling %q, expected %q, got %q", b, expected, f)
|
||||
log.Panicf("Error unmarshalling %q, expected %q, got %q", b, expected, f)
|
||||
}
|
||||
|
||||
f = map[string]interface{}{
|
||||
|
||||
@@ -36,7 +36,7 @@ func Decode() {
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(expected, m) {
|
||||
log.Panicf("Error unmarshaling %q, expected %q, got %q", b, expected, m)
|
||||
log.Panicf("Error unmarshalling %q, expected %q, got %q", b, expected, m)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -322,27 +322,6 @@ var ptrTests = []ptrTest{
|
||||
body: `p := &C.s{}; defer C.f(p); p.p = new(C.int)`,
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
// Check a pointer to a union if the union has any
|
||||
// pointer fields.
|
||||
name: "union1",
|
||||
c: `typedef union { char **p; unsigned long i; } u; void f(u *pu) {}`,
|
||||
imports: []string{"unsafe"},
|
||||
body: `var b C.char; p := &b; C.f((*C.u)(unsafe.Pointer(&p)))`,
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
// Don't check a pointer to a union if the union does
|
||||
// not have any pointer fields.
|
||||
// Like ptrdata1 above, the uintptr represents an
|
||||
// integer that happens to have the same
|
||||
// representation as a pointer.
|
||||
name: "union2",
|
||||
c: `typedef union { unsigned long i; } u; void f(u *pu) {}`,
|
||||
imports: []string{"unsafe"},
|
||||
body: `var b C.char; p := &b; C.f((*C.u)(unsafe.Pointer(&p)))`,
|
||||
fail: false,
|
||||
},
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -74,7 +74,5 @@ func Test8756(t *testing.T) { test8756(t) }
|
||||
func Test17065(t *testing.T) { test17065(t) }
|
||||
func TestThreadLock(t *testing.T) { testThreadLockFunc(t) }
|
||||
func TestCheckConst(t *testing.T) { testCheckConst(t) }
|
||||
func Test17537(t *testing.T) { test17537(t) }
|
||||
func Test18126(t *testing.T) { test18126(t) }
|
||||
|
||||
func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Issue 17537. The void* cast introduced by cgo to avoid problems
|
||||
// with const/volatile qualifiers breaks C preprocessor macros that
|
||||
// emulate functions.
|
||||
|
||||
package cgotest
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct {
|
||||
int i;
|
||||
} S17537;
|
||||
|
||||
int I17537(S17537 *p);
|
||||
|
||||
#define I17537(p) ((p)->i)
|
||||
|
||||
// Calling this function used to fail without the cast.
|
||||
const int F17537(const char **p) {
|
||||
return **p;
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import "testing"
|
||||
|
||||
func test17537(t *testing.T) {
|
||||
v := C.S17537{i: 17537}
|
||||
if got, want := C.I17537(&v), C.int(17537); got != want {
|
||||
t.Errorf("got %d, want %d", got, want)
|
||||
}
|
||||
|
||||
p := (*C.char)(C.malloc(1))
|
||||
*p = 17
|
||||
if got, want := C.F17537(&p), C.int(17); got != want {
|
||||
t.Errorf("got %d, want %d", got, want)
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Issue 18126: cgo check of void function returning errno.
|
||||
|
||||
package cgotest
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
|
||||
void Issue18126C(void **p) {
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func test18126(t *testing.T) {
|
||||
p := C.malloc(1)
|
||||
_, err := C.Issue18126C(&p)
|
||||
C.free(p)
|
||||
_ = err
|
||||
}
|
||||
@@ -88,20 +88,9 @@ func issue7978wait(store uint32, wait uint32) {
|
||||
|
||||
//export issue7978cb
|
||||
func issue7978cb() {
|
||||
// Force a stack growth from the callback to put extra
|
||||
// pressure on the runtime. See issue #17785.
|
||||
growStack(64)
|
||||
issue7978wait(3, 4)
|
||||
}
|
||||
|
||||
func growStack(n int) int {
|
||||
var buf [128]int
|
||||
if n == 0 {
|
||||
return 0
|
||||
}
|
||||
return buf[growStack(n-1)]
|
||||
}
|
||||
|
||||
func issue7978go() {
|
||||
C.issue7978c((*C.uint32_t)(&issue7978sync))
|
||||
issue7978wait(7, 8)
|
||||
|
||||
@@ -265,25 +265,6 @@ func TestSignalForwarding(t *testing.T) {
|
||||
t.Logf("%s", out)
|
||||
t.Errorf("got %v; expected SIGSEGV", ee)
|
||||
}
|
||||
|
||||
// Test SIGPIPE forwarding
|
||||
cmd = exec.Command(bin[0], append(bin[1:], "3")...)
|
||||
|
||||
out, err = cmd.CombinedOutput()
|
||||
|
||||
if err == nil {
|
||||
t.Logf("%s", out)
|
||||
t.Error("test program succeeded unexpectedly")
|
||||
} else if ee, ok := err.(*exec.ExitError); !ok {
|
||||
t.Logf("%s", out)
|
||||
t.Errorf("error (%v) has type %T; expected exec.ExitError", err, err)
|
||||
} else if ws, ok := ee.Sys().(syscall.WaitStatus); !ok {
|
||||
t.Logf("%s", out)
|
||||
t.Errorf("error.Sys (%v) has type %T; expected syscall.WaitStatus", ee.Sys(), ee.Sys())
|
||||
} else if !ws.Signaled() || ws.Signal() != syscall.SIGPIPE {
|
||||
t.Logf("%s", out)
|
||||
t.Errorf("got %v; expected SIGPIPE", ee)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSignalForwardingExternal(t *testing.T) {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <unistd.h>
|
||||
#include <sched.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "libgo2.h"
|
||||
|
||||
@@ -27,7 +26,6 @@ static void die(const char* msg) {
|
||||
}
|
||||
|
||||
static volatile sig_atomic_t sigioSeen;
|
||||
static volatile sig_atomic_t sigpipeSeen;
|
||||
|
||||
// Use up some stack space.
|
||||
static void recur(int i, char *p) {
|
||||
@@ -39,11 +37,6 @@ static void recur(int i, char *p) {
|
||||
}
|
||||
}
|
||||
|
||||
// Signal handler that uses up more stack space than a goroutine will have.
|
||||
static void pipeHandler(int signo, siginfo_t* info, void* ctxt) {
|
||||
sigpipeSeen = 1;
|
||||
}
|
||||
|
||||
// Signal handler that uses up more stack space than a goroutine will have.
|
||||
static void ioHandler(int signo, siginfo_t* info, void* ctxt) {
|
||||
char a[1024];
|
||||
@@ -113,17 +106,12 @@ static void init() {
|
||||
die("sigaction");
|
||||
}
|
||||
|
||||
sa.sa_sigaction = pipeHandler;
|
||||
if (sigaction(SIGPIPE, &sa, NULL) < 0) {
|
||||
die("sigaction");
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int verbose;
|
||||
sigset_t mask;
|
||||
int i;
|
||||
struct timespec ts;
|
||||
|
||||
verbose = argc > 1;
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
@@ -173,35 +161,12 @@ int main(int argc, char** argv) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (!sigioSeen) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
fprintf(stderr, "looping too long waiting for SIGIO\n");
|
||||
exit(EXIT_FAILURE);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
printf("provoking SIGPIPE\n");
|
||||
}
|
||||
|
||||
GoRaiseSIGPIPE();
|
||||
|
||||
if (verbose) {
|
||||
printf("waiting for sigpipeSeen\n");
|
||||
}
|
||||
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (!sigpipeSeen) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
i++;
|
||||
if (i > 1000) {
|
||||
fprintf(stderr, "looping too long waiting for SIGPIPE\n");
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sched.h>
|
||||
|
||||
#include "libgo3.h"
|
||||
@@ -29,18 +28,10 @@ int main(int argc, char** argv) {
|
||||
int verbose;
|
||||
struct sigaction sa;
|
||||
int i;
|
||||
struct timespec ts;
|
||||
|
||||
verbose = argc > 2;
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
|
||||
if (verbose) {
|
||||
printf("raising SIGPIPE\n");
|
||||
}
|
||||
|
||||
// Test that the Go runtime handles SIGPIPE.
|
||||
ProvokeSIGPIPE();
|
||||
|
||||
if (verbose) {
|
||||
printf("calling sigaction\n");
|
||||
}
|
||||
@@ -73,11 +64,11 @@ int main(int argc, char** argv) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (!sigioSeen) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -147,11 +138,11 @@ int main(int argc, char** argv) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (!sigioSeen) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sched.h>
|
||||
#include <pthread.h>
|
||||
|
||||
@@ -49,7 +48,6 @@ static void* thread1(void* arg __attribute__ ((unused))) {
|
||||
stack_t ss;
|
||||
int i;
|
||||
stack_t nss;
|
||||
struct timespec ts;
|
||||
|
||||
// Set up an alternate signal stack for this thread.
|
||||
memset(&ss, 0, sizeof ss);
|
||||
@@ -75,11 +73,11 @@ static void* thread1(void* arg __attribute__ ((unused))) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (SIGIOCount() == 0) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -107,7 +105,6 @@ static void* thread2(void* arg __attribute__ ((unused))) {
|
||||
int i;
|
||||
int oldcount;
|
||||
pthread_t tid;
|
||||
struct timespec ts;
|
||||
stack_t nss;
|
||||
|
||||
// Set up an alternate signal stack for this thread.
|
||||
@@ -132,11 +129,11 @@ static void* thread2(void* arg __attribute__ ((unused))) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (SIGIOCount() == oldcount) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -68,24 +68,6 @@ int main(int argc, char** argv) {
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
if (verbose) {
|
||||
printf("attempting SIGPIPE\n");
|
||||
}
|
||||
|
||||
int fd[2];
|
||||
if (pipe(fd) != 0) {
|
||||
printf("pipe(2) failed\n");
|
||||
return 0;
|
||||
}
|
||||
// Close the reading end.
|
||||
close(fd[0]);
|
||||
// Expect that write(2) fails (EPIPE)
|
||||
if (write(fd[1], "some data", 9) != -1) {
|
||||
printf("write(2) unexpectedly succeeded\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
default:
|
||||
printf("Unknown test: %d\n", test);
|
||||
return 0;
|
||||
|
||||
@@ -4,30 +4,6 @@
|
||||
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Raise SIGPIPE.
|
||||
static void CRaiseSIGPIPE() {
|
||||
int fds[2];
|
||||
|
||||
if (pipe(fds) == -1) {
|
||||
perror("pipe");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// Close the reader end
|
||||
close(fds[0]);
|
||||
// Write to the writer end to provoke a SIGPIPE
|
||||
if (write(fds[1], "some data", 9) != -1) {
|
||||
fprintf(stderr, "write to a closed pipe succeeded\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
close(fds[1]);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
@@ -70,11 +46,5 @@ func TestSEGV() {
|
||||
func Noop() {
|
||||
}
|
||||
|
||||
// Raise SIGPIPE.
|
||||
//export GoRaiseSIGPIPE
|
||||
func GoRaiseSIGPIPE() {
|
||||
C.CRaiseSIGPIPE()
|
||||
}
|
||||
|
||||
func main() {
|
||||
}
|
||||
|
||||
@@ -40,17 +40,5 @@ func SawSIGIO() C.int {
|
||||
}
|
||||
}
|
||||
|
||||
// ProvokeSIGPIPE provokes a kernel-initiated SIGPIPE
|
||||
//export ProvokeSIGPIPE
|
||||
func ProvokeSIGPIPE() {
|
||||
r, w, err := os.Pipe()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
r.Close()
|
||||
defer w.Close()
|
||||
w.Write([]byte("some data"))
|
||||
}
|
||||
|
||||
func main() {
|
||||
}
|
||||
|
||||
@@ -77,7 +77,6 @@ int main(int argc, char** argv) {
|
||||
void (*fn)(void);
|
||||
sigset_t mask;
|
||||
int i;
|
||||
struct timespec ts;
|
||||
|
||||
verbose = argc > 2;
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
@@ -167,11 +166,11 @@ int main(int argc, char** argv) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (!sigioSeen) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sched.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
@@ -32,7 +31,6 @@ int main(int argc, char** argv) {
|
||||
void (*fn1)(void);
|
||||
int (*sawSIGIO)(void);
|
||||
int i;
|
||||
struct timespec ts;
|
||||
|
||||
verbose = argc > 2;
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
@@ -79,11 +77,11 @@ int main(int argc, char** argv) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (!sigioSeen) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -184,11 +182,11 @@ int main(int argc, char** argv) {
|
||||
// Wait until the signal has been delivered.
|
||||
i = 0;
|
||||
while (!sigioSeen) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000;
|
||||
nanosleep(&ts, NULL);
|
||||
if (sched_yield() < 0) {
|
||||
perror("sched_yield");
|
||||
}
|
||||
i++;
|
||||
if (i > 5000) {
|
||||
if (i > 100000) {
|
||||
fprintf(stderr, "looping too long waiting for signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ status=0
|
||||
|
||||
# test0: exported symbols in shared lib are accessible.
|
||||
# TODO(iant): using _shared here shouldn't really be necessary.
|
||||
$(go env CC) ${GOGCCFLAGS} -I ${installdir} -o testp main0.c ./libgo.$libext
|
||||
$(go env CC) ${GOGCCFLAGS} -I ${installdir} -o testp main0.c libgo.$libext
|
||||
binpush testp
|
||||
|
||||
output=$(run LD_LIBRARY_PATH=. ./testp)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package common
|
||||
|
||||
var X int
|
||||
|
||||
func init() {
|
||||
X = 4
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
// // No C code required.
|
||||
import "C"
|
||||
|
||||
// The common package imported here does not match the common package
|
||||
// imported by plugin1. A program that attempts to load plugin1 and
|
||||
// plugin-mismatch should produce an error.
|
||||
import "common"
|
||||
|
||||
func ReadCommonX() int {
|
||||
return common.X
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"log"
|
||||
"path/filepath"
|
||||
"plugin"
|
||||
"strings"
|
||||
|
||||
"common"
|
||||
)
|
||||
@@ -18,35 +17,6 @@ func init() {
|
||||
common.X *= 5
|
||||
}
|
||||
|
||||
// testUnnamed tests that two plugins built with .go files passed on
|
||||
// the command line do not have overlapping symbols. That is,
|
||||
// unnamed1.so/FuncInt and unnamed2.so/FuncInt should be distinct functions.
|
||||
func testUnnamed() {
|
||||
p, err := plugin.Open("unnamed1.so")
|
||||
if err != nil {
|
||||
log.Fatalf(`plugin.Open("unnamed1.so"): %v`, err)
|
||||
}
|
||||
fn, err := p.Lookup("FuncInt")
|
||||
if err != nil {
|
||||
log.Fatalf(`unnamed1.so: Lookup("FuncInt") failed: %v`, err)
|
||||
}
|
||||
if got, want := fn.(func() int)(), 1; got != want {
|
||||
log.Fatalf("unnamed1.so: FuncInt()=%d, want %d", got, want)
|
||||
}
|
||||
|
||||
p, err = plugin.Open("unnamed2.so")
|
||||
if err != nil {
|
||||
log.Fatalf(`plugin.Open("unnamed2.so"): %v`, err)
|
||||
}
|
||||
fn, err = p.Lookup("FuncInt")
|
||||
if err != nil {
|
||||
log.Fatalf(`unnamed2.so: Lookup("FuncInt") failed: %v`, err)
|
||||
}
|
||||
if got, want := fn.(func() int)(), 2; got != want {
|
||||
log.Fatalf("unnamed2.so: FuncInt()=%d, want %d", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
if got, want := common.X, 3*5; got != want {
|
||||
log.Fatalf("before plugin load common.X=%d, want %d", got, want)
|
||||
@@ -134,15 +104,5 @@ func main() {
|
||||
log.Fatalf("after loading plugin2, common.X=%d, want %d", got, want)
|
||||
}
|
||||
|
||||
_, err = plugin.Open("plugin-mismatch.so")
|
||||
if err == nil {
|
||||
log.Fatal(`plugin.Open("plugin-mismatch.so"): should have failed`)
|
||||
}
|
||||
if s := err.Error(); !strings.Contains(s, "different version") {
|
||||
log.Fatalf(`plugin.Open("plugin-mismatch.so"): error does not mention "different version": %v`, s)
|
||||
}
|
||||
|
||||
testUnnamed()
|
||||
|
||||
fmt.Println("PASS")
|
||||
}
|
||||
|
||||
@@ -17,17 +17,9 @@ func ReadCommonX() int {
|
||||
|
||||
var Seven int
|
||||
|
||||
func call(fn func()) {
|
||||
fn()
|
||||
}
|
||||
|
||||
func g() {
|
||||
common.X *= Seven
|
||||
}
|
||||
|
||||
func init() {
|
||||
Seven = 7
|
||||
call(g)
|
||||
common.X *= Seven
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -15,8 +15,7 @@ goos=$(go env GOOS)
|
||||
goarch=$(go env GOARCH)
|
||||
|
||||
function cleanup() {
|
||||
rm -f plugin*.so unnamed*.so
|
||||
rm -rf host pkg sub
|
||||
rm -rf plugin1.so host pkg sub
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
@@ -25,10 +24,7 @@ mkdir sub
|
||||
|
||||
GOPATH=$(pwd) go build -buildmode=plugin plugin1
|
||||
GOPATH=$(pwd) go build -buildmode=plugin plugin2
|
||||
GOPATH=$(pwd)/altpath go build -buildmode=plugin plugin-mismatch
|
||||
GOPATH=$(pwd) go build -buildmode=plugin -o=sub/plugin1.so sub/plugin1
|
||||
GOPATH=$(pwd) go build -buildmode=plugin unnamed1.go
|
||||
GOPATH=$(pwd) go build -buildmode=plugin unnamed2.go
|
||||
GOPATH=$(pwd) go build host
|
||||
|
||||
LD_LIBRARY_PATH=$(pwd) ./host
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
// // No C code required.
|
||||
import "C"
|
||||
|
||||
func FuncInt() int { return 1 }
|
||||
|
||||
func main() {}
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
// // No C code required.
|
||||
import "C"
|
||||
|
||||
func FuncInt() int { return 2 }
|
||||
|
||||
func main() {}
|
||||
@@ -144,7 +144,6 @@ if test "$tsan" = "yes"; then
|
||||
testtsan tsan2.go
|
||||
testtsan tsan3.go
|
||||
testtsan tsan4.go
|
||||
testtsan tsan8.go
|
||||
|
||||
# These tests are only reliable using clang or GCC version 7 or later.
|
||||
# Otherwise runtime/cgo/libcgo.h can't tell whether TSAN is in use.
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
// This program failed when run under the C/C++ ThreadSanitizer. The TSAN
|
||||
// sigaction function interceptor returned SIG_DFL instead of the Go runtime's
|
||||
// handler in registerSegvForwarder.
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -fsanitize=thread
|
||||
#cgo LDFLAGS: -fsanitize=thread
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct sigaction prev_sa;
|
||||
|
||||
void forwardSignal(int signo, siginfo_t *info, void *context) {
|
||||
// One of sa_sigaction and/or sa_handler
|
||||
if ((prev_sa.sa_flags&SA_SIGINFO) != 0) {
|
||||
prev_sa.sa_sigaction(signo, info, context);
|
||||
return;
|
||||
}
|
||||
if (prev_sa.sa_handler != SIG_IGN && prev_sa.sa_handler != SIG_DFL) {
|
||||
prev_sa.sa_handler(signo);
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, "No Go handler to forward to!\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
void registerSegvFowarder() {
|
||||
struct sigaction sa;
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
|
||||
sa.sa_sigaction = forwardSignal;
|
||||
|
||||
if (sigaction(SIGSEGV, &sa, &prev_sa) != 0) {
|
||||
perror("failed to register SEGV forwarder");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func main() {
|
||||
C.registerSegvFowarder()
|
||||
|
||||
defer func() {
|
||||
recover()
|
||||
}()
|
||||
var nilp *int
|
||||
*nilp = 42
|
||||
}
|
||||
@@ -22,10 +22,6 @@ type Writer struct {
|
||||
last *fileWriter
|
||||
closed bool
|
||||
compressors map[uint16]Compressor
|
||||
|
||||
// testHookCloseSizeOffset if non-nil is called with the size
|
||||
// of offset of the central directory at Close.
|
||||
testHookCloseSizeOffset func(size, offset uint64)
|
||||
}
|
||||
|
||||
type header struct {
|
||||
@@ -144,11 +140,7 @@ func (w *Writer) Close() error {
|
||||
size := uint64(end - start)
|
||||
offset := uint64(start)
|
||||
|
||||
if f := w.testHookCloseSizeOffset; f != nil {
|
||||
f(size, offset)
|
||||
}
|
||||
|
||||
if records >= uint16max || size >= uint32max || offset >= uint32max {
|
||||
if records > uint16max || size > uint32max || offset > uint32max {
|
||||
var buf [directory64EndLen + directory64LocLen]byte
|
||||
b := writeBuf(buf[:])
|
||||
|
||||
|
||||
@@ -8,10 +8,8 @@ package zip
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"hash"
|
||||
"internal/race"
|
||||
"internal/testenv"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -273,7 +271,6 @@ func TestZip64(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("slow test; skipping")
|
||||
}
|
||||
t.Parallel()
|
||||
const size = 1 << 32 // before the "END\n" part
|
||||
buf := testZip64(t, size)
|
||||
testZip64DirectoryRecordLength(buf, t)
|
||||
@@ -283,7 +280,6 @@ func TestZip64EdgeCase(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("slow test; skipping")
|
||||
}
|
||||
t.Parallel()
|
||||
// Test a zip file with uncompressed size 0xFFFFFFFF.
|
||||
// That's the magic marker for a 64-bit file, so even though
|
||||
// it fits in a 32-bit field we must use the 64-bit field.
|
||||
@@ -294,256 +290,6 @@ func TestZip64EdgeCase(t *testing.T) {
|
||||
testZip64DirectoryRecordLength(buf, t)
|
||||
}
|
||||
|
||||
// Tests that we generate a zip64 file if the the directory at offset
|
||||
// 0xFFFFFFFF, but not before.
|
||||
func TestZip64DirectoryOffset(t *testing.T) {
|
||||
if testing.Short() && race.Enabled {
|
||||
t.Skip("skipping in short mode")
|
||||
}
|
||||
t.Parallel()
|
||||
const filename = "huge.txt"
|
||||
gen := func(wantOff uint64) func(*Writer) {
|
||||
return func(w *Writer) {
|
||||
w.testHookCloseSizeOffset = func(size, off uint64) {
|
||||
if off != wantOff {
|
||||
t.Errorf("central directory offset = %d (%x); want %d", off, off, wantOff)
|
||||
}
|
||||
}
|
||||
f, err := w.CreateHeader(&FileHeader{
|
||||
Name: filename,
|
||||
Method: Store,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f.(*fileWriter).crc32 = fakeHash32{}
|
||||
size := wantOff - fileHeaderLen - uint64(len(filename)) - dataDescriptorLen
|
||||
if _, err := io.CopyN(f, zeros{}, int64(size)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := w.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
t.Run("uint32max-2_NoZip64", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if generatesZip64(t, gen(0xfffffffe)) {
|
||||
t.Error("unexpected zip64")
|
||||
}
|
||||
})
|
||||
t.Run("uint32max-1_Zip64", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if !generatesZip64(t, gen(0xffffffff)) {
|
||||
t.Error("expected zip64")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// At 16k records, we need to generate a zip64 file.
|
||||
func TestZip64ManyRecords(t *testing.T) {
|
||||
if testing.Short() && race.Enabled {
|
||||
t.Skip("skipping in short mode")
|
||||
}
|
||||
t.Parallel()
|
||||
gen := func(numRec int) func(*Writer) {
|
||||
return func(w *Writer) {
|
||||
for i := 0; i < numRec; i++ {
|
||||
_, err := w.CreateHeader(&FileHeader{
|
||||
Name: "a.txt",
|
||||
Method: Store,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := w.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 16k-1 records shouldn't make a zip64:
|
||||
t.Run("uint16max-1_NoZip64", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if generatesZip64(t, gen(0xfffe)) {
|
||||
t.Error("unexpected zip64")
|
||||
}
|
||||
})
|
||||
// 16k records should make a zip64:
|
||||
t.Run("uint16max_Zip64", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if !generatesZip64(t, gen(0xffff)) {
|
||||
t.Error("expected zip64")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// suffixSaver is an io.Writer & io.ReaderAt that remembers the last 0
|
||||
// to 'keep' bytes of data written to it. Call Suffix to get the
|
||||
// suffix bytes.
|
||||
type suffixSaver struct {
|
||||
keep int
|
||||
buf []byte
|
||||
start int
|
||||
size int64
|
||||
}
|
||||
|
||||
func (ss *suffixSaver) Size() int64 { return ss.size }
|
||||
|
||||
var errDiscardedBytes = errors.New("ReadAt of discarded bytes")
|
||||
|
||||
func (ss *suffixSaver) ReadAt(p []byte, off int64) (n int, err error) {
|
||||
back := ss.size - off
|
||||
if back > int64(ss.keep) {
|
||||
return 0, errDiscardedBytes
|
||||
}
|
||||
suf := ss.Suffix()
|
||||
n = copy(p, suf[len(suf)-int(back):])
|
||||
if n != len(p) {
|
||||
err = io.EOF
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (ss *suffixSaver) Suffix() []byte {
|
||||
if len(ss.buf) < ss.keep {
|
||||
return ss.buf
|
||||
}
|
||||
buf := make([]byte, ss.keep)
|
||||
n := copy(buf, ss.buf[ss.start:])
|
||||
copy(buf[n:], ss.buf[:])
|
||||
return buf
|
||||
}
|
||||
|
||||
func (ss *suffixSaver) Write(p []byte) (n int, err error) {
|
||||
n = len(p)
|
||||
ss.size += int64(len(p))
|
||||
if len(ss.buf) < ss.keep {
|
||||
space := ss.keep - len(ss.buf)
|
||||
add := len(p)
|
||||
if add > space {
|
||||
add = space
|
||||
}
|
||||
ss.buf = append(ss.buf, p[:add]...)
|
||||
p = p[add:]
|
||||
}
|
||||
for len(p) > 0 {
|
||||
n := copy(ss.buf[ss.start:], p)
|
||||
p = p[n:]
|
||||
ss.start += n
|
||||
if ss.start == ss.keep {
|
||||
ss.start = 0
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// generatesZip64 reports whether f wrote a zip64 file.
|
||||
// f is also responsible for closing w.
|
||||
func generatesZip64(t *testing.T, f func(w *Writer)) bool {
|
||||
ss := &suffixSaver{keep: 10 << 20}
|
||||
w := NewWriter(ss)
|
||||
f(w)
|
||||
return suffixIsZip64(t, ss)
|
||||
}
|
||||
|
||||
type sizedReaderAt interface {
|
||||
io.ReaderAt
|
||||
Size() int64
|
||||
}
|
||||
|
||||
func suffixIsZip64(t *testing.T, zip sizedReaderAt) bool {
|
||||
d := make([]byte, 1024)
|
||||
if _, err := zip.ReadAt(d, zip.Size()-int64(len(d))); err != nil {
|
||||
t.Fatalf("ReadAt: %v", err)
|
||||
}
|
||||
|
||||
sigOff := findSignatureInBlock(d)
|
||||
if sigOff == -1 {
|
||||
t.Errorf("failed to find signature in block")
|
||||
return false
|
||||
}
|
||||
|
||||
dirOff, err := findDirectory64End(zip, zip.Size()-int64(len(d))+int64(sigOff))
|
||||
if err != nil {
|
||||
t.Fatalf("findDirectory64End: %v", err)
|
||||
}
|
||||
if dirOff == -1 {
|
||||
return false
|
||||
}
|
||||
|
||||
d = make([]byte, directory64EndLen)
|
||||
if _, err := zip.ReadAt(d, dirOff); err != nil {
|
||||
t.Fatalf("ReadAt(off=%d): %v", dirOff, err)
|
||||
}
|
||||
|
||||
b := readBuf(d)
|
||||
if sig := b.uint32(); sig != directory64EndSignature {
|
||||
return false
|
||||
}
|
||||
|
||||
size := b.uint64()
|
||||
if size != directory64EndLen-12 {
|
||||
t.Errorf("expected length of %d, got %d", directory64EndLen-12, size)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Zip64 is required if the total size of the records is uint32max.
|
||||
func TestZip64LargeDirectory(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping in short mode")
|
||||
}
|
||||
t.Parallel()
|
||||
// gen returns a func that writes a zip with a wantLen bytes
|
||||
// of central directory.
|
||||
gen := func(wantLen int64) func(*Writer) {
|
||||
return func(w *Writer) {
|
||||
w.testHookCloseSizeOffset = func(size, off uint64) {
|
||||
if size != uint64(wantLen) {
|
||||
t.Errorf("Close central directory size = %d; want %d", size, wantLen)
|
||||
}
|
||||
}
|
||||
|
||||
uint16string := strings.Repeat(".", uint16max)
|
||||
remain := wantLen
|
||||
for remain > 0 {
|
||||
commentLen := int(uint16max) - directoryHeaderLen - 1
|
||||
thisRecLen := directoryHeaderLen + int(uint16max) + commentLen
|
||||
if int64(thisRecLen) > remain {
|
||||
remove := thisRecLen - int(remain)
|
||||
commentLen -= remove
|
||||
thisRecLen -= remove
|
||||
}
|
||||
remain -= int64(thisRecLen)
|
||||
f, err := w.CreateHeader(&FileHeader{
|
||||
Name: uint16string,
|
||||
Comment: uint16string[:commentLen],
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateHeader: %v", err)
|
||||
}
|
||||
f.(*fileWriter).crc32 = fakeHash32{}
|
||||
}
|
||||
if err := w.Close(); err != nil {
|
||||
t.Fatalf("Close: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
t.Run("uint32max-1_NoZip64", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if generatesZip64(t, gen(uint32max-1)) {
|
||||
t.Error("unexpected zip64")
|
||||
}
|
||||
})
|
||||
t.Run("uint32max_HasZip64", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if !generatesZip64(t, gen(uint32max)) {
|
||||
t.Error("expected zip64")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func testZip64(t testing.TB, size int64) *rleBuffer {
|
||||
const chunkSize = 1024
|
||||
chunks := int(size / chunkSize)
|
||||
@@ -632,8 +378,30 @@ func testZip64(t testing.TB, size int64) *rleBuffer {
|
||||
|
||||
// Issue 9857
|
||||
func testZip64DirectoryRecordLength(buf *rleBuffer, t *testing.T) {
|
||||
if !suffixIsZip64(t, buf) {
|
||||
t.Fatal("not a zip64")
|
||||
d := make([]byte, 1024)
|
||||
if _, err := buf.ReadAt(d, buf.Size()-int64(len(d))); err != nil {
|
||||
t.Fatal("read:", err)
|
||||
}
|
||||
|
||||
sigOff := findSignatureInBlock(d)
|
||||
dirOff, err := findDirectory64End(buf, buf.Size()-int64(len(d))+int64(sigOff))
|
||||
if err != nil {
|
||||
t.Fatal("findDirectory64End:", err)
|
||||
}
|
||||
|
||||
d = make([]byte, directory64EndLen)
|
||||
if _, err := buf.ReadAt(d, dirOff); err != nil {
|
||||
t.Fatal("read:", err)
|
||||
}
|
||||
|
||||
b := readBuf(d)
|
||||
if sig := b.uint32(); sig != directory64EndSignature {
|
||||
t.Fatalf("Expected directory64EndSignature (%d), got %d", directory64EndSignature, sig)
|
||||
}
|
||||
|
||||
size := b.uint64()
|
||||
if size != directory64EndLen-12 {
|
||||
t.Fatalf("Expected length of %d, got %d", directory64EndLen-12, size)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -719,47 +487,3 @@ func BenchmarkZip64Test(b *testing.B) {
|
||||
testZip64(b, 1<<26)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuffixSaver(t *testing.T) {
|
||||
const keep = 10
|
||||
ss := &suffixSaver{keep: keep}
|
||||
ss.Write([]byte("abc"))
|
||||
if got := string(ss.Suffix()); got != "abc" {
|
||||
t.Errorf("got = %q; want abc", got)
|
||||
}
|
||||
ss.Write([]byte("defghijklmno"))
|
||||
if got := string(ss.Suffix()); got != "fghijklmno" {
|
||||
t.Errorf("got = %q; want fghijklmno", got)
|
||||
}
|
||||
if got, want := ss.Size(), int64(len("abc")+len("defghijklmno")); got != want {
|
||||
t.Errorf("Size = %d; want %d", got, want)
|
||||
}
|
||||
buf := make([]byte, ss.Size())
|
||||
for off := int64(0); off < ss.Size(); off++ {
|
||||
for size := 1; size <= int(ss.Size()-off); size++ {
|
||||
readBuf := buf[:size]
|
||||
n, err := ss.ReadAt(readBuf, off)
|
||||
if off < ss.Size()-keep {
|
||||
if err != errDiscardedBytes {
|
||||
t.Errorf("off %d, size %d = %v, %v (%q); want errDiscardedBytes", off, size, n, err, readBuf[:n])
|
||||
}
|
||||
continue
|
||||
}
|
||||
want := "abcdefghijklmno"[off : off+int64(size)]
|
||||
got := string(readBuf[:n])
|
||||
if err != nil || got != want {
|
||||
t.Errorf("off %d, size %d = %v, %v (%q); want %q", off, size, n, err, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
type zeros struct{}
|
||||
|
||||
func (zeros) Read(p []byte) (int, error) {
|
||||
for i := range p {
|
||||
p[i] = 0
|
||||
}
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func main() {
|
||||
}
|
||||
|
||||
out, err := exec.Command("go", "tool", "api",
|
||||
"-c", file("go1", "go1.1", "go1.2", "go1.3", "go1.4", "go1.5", "go1.6", "go1.7", "go1.8"),
|
||||
"-c", file("go1", "go1.1", "go1.2", "go1.3", "go1.4", "go1.5", "go1.6", "go1.7"),
|
||||
"-next", file("next"),
|
||||
"-except", file("except")).CombinedOutput()
|
||||
if err != nil {
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
"cmd/internal/obj/x86"
|
||||
)
|
||||
|
||||
// IsAMD4OP reports whether the op (as defined by an amd64.A* constant) is
|
||||
// a 4-operand instruction.
|
||||
// IsAMD4OP reports whether the op (as defined by an ppc64.A* constant) is
|
||||
// The FMADD-like instructions behave similarly.
|
||||
func IsAMD4OP(op obj.As) bool {
|
||||
switch op {
|
||||
case x86.AVPERM2F128,
|
||||
|
||||
@@ -110,8 +110,6 @@ func IsS390xWithIndex(op obj.As) bool {
|
||||
return true
|
||||
case s390x.AVLEG, s390x.AVLEF, s390x.AVLEH, s390x.AVLEB:
|
||||
return true
|
||||
case s390x.AVSTEG, s390x.AVSTEF, s390x.AVSTEH, s390x.AVSTEB:
|
||||
return true
|
||||
case s390x.AVPDI:
|
||||
return true
|
||||
}
|
||||
|
||||
5
src/cmd/asm/internal/asm/testdata/s390x.s
vendored
5
src/cmd/asm/internal/asm/testdata/s390x.s
vendored
@@ -333,10 +333,7 @@ TEXT main·foo(SB),7,$16-0 // TEXT main.foo(SB), 7, $16-0
|
||||
VLEF $2, (R0), V31 // VLEF (R0), $2, V31 // e7f000002803
|
||||
VLEH $3, (R12), V16 // VLEH (R12), $3, V16 // e700c0003801
|
||||
VLEB $15, 4095(R9), V15 // VLEB 4095(R9), $15, V15 // e7f09ffff000
|
||||
VSTEG $1, V30, (R1)(R2*1) // VSTEG V30, $1, (R1)(R2*1) // e7e21000180a
|
||||
VSTEF $3, V2, (R9) // VSTEF V2, $3, (R9) // e7209000300b
|
||||
VSTEH $7, V31, (R2) // VSTEH V31, $7, (R2) // e7f020007809
|
||||
VSTEB $15, V29, 4094(R12) // VSTEB V29, $15, 4094(R12) // e7d0cffef808
|
||||
|
||||
|
||||
RET
|
||||
|
||||
|
||||
@@ -713,7 +713,15 @@ func (p *Package) rewriteCall(f *File, call *Call, name *Name) bool {
|
||||
List: params,
|
||||
},
|
||||
}
|
||||
if name.FuncType.Result != nil {
|
||||
var fbody ast.Stmt
|
||||
if name.FuncType.Result == nil {
|
||||
fbody = &ast.ExprStmt{
|
||||
X: fcall,
|
||||
}
|
||||
} else {
|
||||
fbody = &ast.ReturnStmt{
|
||||
Results: []ast.Expr{fcall},
|
||||
}
|
||||
rtype := p.rewriteUnsafe(name.FuncType.Result.Go)
|
||||
if rtype != name.FuncType.Result.Go {
|
||||
needsUnsafe = true
|
||||
@@ -726,45 +734,6 @@ func (p *Package) rewriteCall(f *File, call *Call, name *Name) bool {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// There is a Ref pointing to the old call.Call.Fun.
|
||||
for _, ref := range f.Ref {
|
||||
if ref.Expr == &call.Call.Fun {
|
||||
ref.Expr = &fcall.Fun
|
||||
|
||||
// If this call expects two results, we have to
|
||||
// adjust the results of the function we generated.
|
||||
if ref.Context == "call2" {
|
||||
if ftype.Results == nil {
|
||||
// An explicit void argument
|
||||
// looks odd but it seems to
|
||||
// be how cgo has worked historically.
|
||||
ftype.Results = &ast.FieldList{
|
||||
List: []*ast.Field{
|
||||
&ast.Field{
|
||||
Type: ast.NewIdent("_Ctype_void"),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
ftype.Results.List = append(ftype.Results.List,
|
||||
&ast.Field{
|
||||
Type: ast.NewIdent("error"),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var fbody ast.Stmt
|
||||
if ftype.Results == nil {
|
||||
fbody = &ast.ExprStmt{
|
||||
X: fcall,
|
||||
}
|
||||
} else {
|
||||
fbody = &ast.ReturnStmt{
|
||||
Results: []ast.Expr{fcall},
|
||||
}
|
||||
}
|
||||
call.Call.Fun = &ast.FuncLit{
|
||||
Type: ftype,
|
||||
Body: &ast.BlockStmt{
|
||||
@@ -774,6 +743,22 @@ func (p *Package) rewriteCall(f *File, call *Call, name *Name) bool {
|
||||
call.Call.Lparen = token.NoPos
|
||||
call.Call.Rparen = token.NoPos
|
||||
|
||||
// There is a Ref pointing to the old call.Call.Fun.
|
||||
for _, ref := range f.Ref {
|
||||
if ref.Expr == &call.Call.Fun {
|
||||
ref.Expr = &fcall.Fun
|
||||
|
||||
// If this call expects two results, we have to
|
||||
// adjust the results of the function we generated.
|
||||
if ref.Context == "call2" {
|
||||
ftype.Results.List = append(ftype.Results.List,
|
||||
&ast.Field{
|
||||
Type: ast.NewIdent("error"),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return needsUnsafe
|
||||
}
|
||||
|
||||
@@ -817,11 +802,6 @@ func (p *Package) hasPointer(f *File, t ast.Expr, top bool) bool {
|
||||
if !top {
|
||||
return true
|
||||
}
|
||||
// Check whether this is a pointer to a C union (or class)
|
||||
// type that contains a pointer.
|
||||
if unionWithPointer[t.X] {
|
||||
return true
|
||||
}
|
||||
return p.hasPointer(f, t.X, false)
|
||||
case *ast.FuncType, *ast.InterfaceType, *ast.MapType, *ast.ChanType:
|
||||
return true
|
||||
@@ -1438,10 +1418,6 @@ var tagGen int
|
||||
var typedef = make(map[string]*Type)
|
||||
var goIdent = make(map[string]*ast.Ident)
|
||||
|
||||
// unionWithPointer is true for a Go type that represents a C union (or class)
|
||||
// that may contain a pointer. This is used for cgo pointer checking.
|
||||
var unionWithPointer = make(map[ast.Expr]bool)
|
||||
|
||||
func (c *typeConv) Init(ptrSize, intSize int64) {
|
||||
c.ptrSize = ptrSize
|
||||
c.intSize = intSize
|
||||
@@ -1491,19 +1467,6 @@ func base(dt dwarf.Type) dwarf.Type {
|
||||
return dt
|
||||
}
|
||||
|
||||
// unqual strips away qualifiers from a DWARF type.
|
||||
// In general we don't care about top-level qualifiers.
|
||||
func unqual(dt dwarf.Type) dwarf.Type {
|
||||
for {
|
||||
if d, ok := dt.(*dwarf.QualType); ok {
|
||||
dt = d.Type
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return dt
|
||||
}
|
||||
|
||||
// Map from dwarf text names to aliases we use in package "C".
|
||||
var dwarfToName = map[string]string{
|
||||
"long int": "long",
|
||||
@@ -1739,16 +1702,9 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type {
|
||||
c.ptrs[dt.Type] = append(c.ptrs[dt.Type], t)
|
||||
|
||||
case *dwarf.QualType:
|
||||
t1 := c.Type(dt.Type, pos)
|
||||
t.Size = t1.Size
|
||||
t.Align = t1.Align
|
||||
t.Go = t1.Go
|
||||
if unionWithPointer[t1.Go] {
|
||||
unionWithPointer[t.Go] = true
|
||||
}
|
||||
t.EnumValues = nil
|
||||
t.Typedef = ""
|
||||
t.C.Set("%s "+dt.Qual, t1.C)
|
||||
// Ignore qualifier.
|
||||
t = c.Type(dt.Type, pos)
|
||||
c.m[dtype] = t
|
||||
return t
|
||||
|
||||
case *dwarf.StructType:
|
||||
@@ -1780,9 +1736,6 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type {
|
||||
switch dt.Kind {
|
||||
case "class", "union":
|
||||
t.Go = c.Opaque(t.Size)
|
||||
if c.dwarfHasPointer(dt, pos) {
|
||||
unionWithPointer[t.Go] = true
|
||||
}
|
||||
if t.C.Empty() {
|
||||
t.C.Set("__typeof__(unsigned char[%d])", t.Size)
|
||||
}
|
||||
@@ -1825,9 +1778,6 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type {
|
||||
goIdent[name.Name] = name
|
||||
sub := c.Type(dt.Type, pos)
|
||||
t.Go = name
|
||||
if unionWithPointer[sub.Go] {
|
||||
unionWithPointer[t.Go] = true
|
||||
}
|
||||
t.Size = sub.Size
|
||||
t.Align = sub.Align
|
||||
oldType := typedef[name.Name]
|
||||
@@ -1958,7 +1908,7 @@ func isStructUnionClass(x ast.Expr) bool {
|
||||
// FuncArg returns a Go type with the same memory layout as
|
||||
// dtype when used as the type of a C function argument.
|
||||
func (c *typeConv) FuncArg(dtype dwarf.Type, pos token.Pos) *Type {
|
||||
t := c.Type(unqual(dtype), pos)
|
||||
t := c.Type(dtype, pos)
|
||||
switch dt := dtype.(type) {
|
||||
case *dwarf.ArrayType:
|
||||
// Arrays are passed implicitly as pointers in C.
|
||||
@@ -2022,7 +1972,7 @@ func (c *typeConv) FuncType(dtype *dwarf.FuncType, pos token.Pos) *FuncType {
|
||||
if _, ok := dtype.ReturnType.(*dwarf.VoidType); ok {
|
||||
gr = []*ast.Field{{Type: c.goVoid}}
|
||||
} else if dtype.ReturnType != nil {
|
||||
r = c.Type(unqual(dtype.ReturnType), pos)
|
||||
r = c.Type(dtype.ReturnType, pos)
|
||||
gr = []*ast.Field{{Type: r.Go}}
|
||||
}
|
||||
return &FuncType{
|
||||
@@ -2209,44 +2159,6 @@ func (c *typeConv) Struct(dt *dwarf.StructType, pos token.Pos) (expr *ast.Struct
|
||||
return
|
||||
}
|
||||
|
||||
// dwarfHasPointer returns whether the DWARF type dt contains a pointer.
|
||||
func (c *typeConv) dwarfHasPointer(dt dwarf.Type, pos token.Pos) bool {
|
||||
switch dt := dt.(type) {
|
||||
default:
|
||||
fatalf("%s: unexpected type: %s", lineno(pos), dt)
|
||||
return false
|
||||
|
||||
case *dwarf.AddrType, *dwarf.BoolType, *dwarf.CharType, *dwarf.EnumType,
|
||||
*dwarf.FloatType, *dwarf.ComplexType, *dwarf.FuncType,
|
||||
*dwarf.IntType, *dwarf.UcharType, *dwarf.UintType, *dwarf.VoidType:
|
||||
|
||||
return false
|
||||
|
||||
case *dwarf.ArrayType:
|
||||
return c.dwarfHasPointer(dt.Type, pos)
|
||||
|
||||
case *dwarf.PtrType:
|
||||
return true
|
||||
|
||||
case *dwarf.QualType:
|
||||
return c.dwarfHasPointer(dt.Type, pos)
|
||||
|
||||
case *dwarf.StructType:
|
||||
for _, f := range dt.Field {
|
||||
if c.dwarfHasPointer(f.Type, pos) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
case *dwarf.TypedefType:
|
||||
if dt.Name == "_GoString_" || dt.Name == "_GoBytes_" {
|
||||
return true
|
||||
}
|
||||
return c.dwarfHasPointer(dt.Type, pos)
|
||||
}
|
||||
}
|
||||
|
||||
func upper(s string) string {
|
||||
if s == "" {
|
||||
return ""
|
||||
|
||||
@@ -355,7 +355,11 @@ func (p *Package) structType(n *Name) (string, int64) {
|
||||
fmt.Fprintf(&buf, "\t\tchar __pad%d[%d];\n", off, pad)
|
||||
off += pad
|
||||
}
|
||||
fmt.Fprintf(&buf, "\t\t%s r;\n", t.C)
|
||||
qual := ""
|
||||
if c := t.C.String(); c[len(c)-1] == '*' {
|
||||
qual = "const "
|
||||
}
|
||||
fmt.Fprintf(&buf, "\t\t%s%s r;\n", qual, t.C)
|
||||
off += t.Size
|
||||
}
|
||||
if off%p.PtrSize != 0 {
|
||||
@@ -616,10 +620,20 @@ func (p *Package) writeOutputFunc(fgcc *os.File, n *Name) {
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(fgcc, "%s(", n.C)
|
||||
for i := range n.FuncType.Params {
|
||||
for i, t := range n.FuncType.Params {
|
||||
if i > 0 {
|
||||
fmt.Fprintf(fgcc, ", ")
|
||||
}
|
||||
// We know the type params are correct, because
|
||||
// the Go equivalents had good type params.
|
||||
// However, our version of the type omits the magic
|
||||
// words const and volatile, which can provoke
|
||||
// C compiler warnings. Silence them by casting
|
||||
// all pointers to void*. (Eventually that will produce
|
||||
// other warnings.)
|
||||
if c := t.C.String(); c[len(c)-1] == '*' {
|
||||
fmt.Fprintf(fgcc, "(void*)")
|
||||
}
|
||||
fmt.Fprintf(fgcc, "a->p%d", i)
|
||||
}
|
||||
fmt.Fprintf(fgcc, ");\n")
|
||||
@@ -679,10 +693,14 @@ func (p *Package) writeGccgoOutputFunc(fgcc *os.File, n *Name) {
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(fgcc, "%s(", n.C)
|
||||
for i := range n.FuncType.Params {
|
||||
for i, t := range n.FuncType.Params {
|
||||
if i > 0 {
|
||||
fmt.Fprintf(fgcc, ", ")
|
||||
}
|
||||
// Cast to void* to avoid warnings due to omitted qualifiers.
|
||||
if c := t.C.String(); c[len(c)-1] == '*' {
|
||||
fmt.Fprintf(fgcc, "(void*)")
|
||||
}
|
||||
fmt.Fprintf(fgcc, "p%d", i)
|
||||
}
|
||||
fmt.Fprintf(fgcc, ");\n")
|
||||
|
||||
@@ -119,12 +119,8 @@ var linkobj string
|
||||
|
||||
var bout *bio.Writer
|
||||
|
||||
// nerrors is the number of compiler errors reported
|
||||
// since the last call to saveerrors.
|
||||
var nerrors int
|
||||
|
||||
// nsavederrors is the total number of compiler errors
|
||||
// reported before the last call to saveerrors.
|
||||
var nsavederrors int
|
||||
|
||||
var nsyntaxerrors int
|
||||
|
||||
@@ -781,9 +781,10 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
|
||||
as.Right = nodnil()
|
||||
as.Right.Type = varargtype
|
||||
} else {
|
||||
varslicetype := typSlice(varargtype.Elem())
|
||||
as.Right = nod(OCOMPLIT, nil, typenod(varslicetype))
|
||||
vararrtype := typArray(varargtype.Elem(), int64(varargcount))
|
||||
as.Right = nod(OCOMPLIT, nil, typenod(vararrtype))
|
||||
as.Right.List.Set(varargs)
|
||||
as.Right = nod(OSLICE, as.Right, nil)
|
||||
}
|
||||
|
||||
as = typecheck(as, Etop)
|
||||
|
||||
@@ -98,9 +98,6 @@ func supportsDynlink(arch *sys.Arch) bool {
|
||||
var timings Timings
|
||||
var benchfile string
|
||||
|
||||
// Main parses flags and Go source files specified in the command-line
|
||||
// arguments, type-checks the parsed Go package, compiles functions to machine
|
||||
// code, and finally writes the compiled package definition to disk.
|
||||
func Main() {
|
||||
timings.Start("fe", "init")
|
||||
|
||||
@@ -486,7 +483,6 @@ func Main() {
|
||||
errorexit()
|
||||
}
|
||||
|
||||
// Write object data to disk.
|
||||
timings.Start("be", "dumpobj")
|
||||
dumpobj()
|
||||
if asmhdr != "" {
|
||||
|
||||
@@ -29,7 +29,7 @@ func parseFile(filename string) {
|
||||
|
||||
if !imported_unsafe {
|
||||
for _, x := range p.linknames {
|
||||
p.error(syntax.Error{Line: x, Msg: "//go:linkname only allowed in Go files that import \"unsafe\""})
|
||||
p.error(syntax.Error{0, x, "//go:linkname only allowed in Go files that import \"unsafe\""})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1032,7 +1032,7 @@ func (p *noder) pragma(pos, line int, text string) syntax.Pragma {
|
||||
break
|
||||
}
|
||||
if n > 1e8 {
|
||||
p.error(syntax.Error{Pos: pos, Line: line, Msg: "line number out of range"})
|
||||
p.error(syntax.Error{pos, line, "line number out of range"})
|
||||
errorexit()
|
||||
}
|
||||
if n <= 0 {
|
||||
@@ -1048,7 +1048,7 @@ func (p *noder) pragma(pos, line int, text string) syntax.Pragma {
|
||||
|
||||
f := strings.Fields(text)
|
||||
if len(f) != 3 {
|
||||
p.error(syntax.Error{Pos: pos, Line: line, Msg: "usage: //go:linkname localname linkname"})
|
||||
p.error(syntax.Error{pos, line, "usage: //go:linkname localname linkname"})
|
||||
break
|
||||
}
|
||||
lookup(f[1]).Linkname = f[2]
|
||||
|
||||
@@ -354,12 +354,6 @@ func dsymptrOffLSym(s *obj.LSym, off int, x *obj.LSym, xoff int) int {
|
||||
return off
|
||||
}
|
||||
|
||||
func dsymptrWeakOffLSym(s *obj.LSym, off int, x *obj.LSym) int {
|
||||
s.WriteWeakOff(Ctxt, int64(off), x, 0)
|
||||
off += 4
|
||||
return off
|
||||
}
|
||||
|
||||
func gdata(nam *Node, nr *Node, wid int) {
|
||||
if nam.Op != ONAME {
|
||||
Fatalf("gdata nam op %v", nam.Op)
|
||||
|
||||
@@ -427,8 +427,9 @@ func compile(fn *Node) {
|
||||
}
|
||||
fallthrough
|
||||
case PPARAM, PPARAMOUT:
|
||||
// The symbol is excluded later from debugging info if its name begins ".autotmp_", but the type is still necessary.
|
||||
// See bugs #17644 and #17830 and cmd/internal/dwarf/dwarf.go
|
||||
if n.IsAutoTmp() { // skip debugging info for temporaries
|
||||
continue
|
||||
}
|
||||
p := Gins(obj.ATYPE, n, nil)
|
||||
p.From.Sym = obj.Linklookup(Ctxt, n.Sym.Name, 0)
|
||||
p.To.Type = obj.TYPE_MEM
|
||||
|
||||
@@ -494,31 +494,26 @@ func dgopkgpathOffLSym(s *obj.LSym, ot int, pkg *Pkg) int {
|
||||
}
|
||||
|
||||
// isExportedField reports whether a struct field is exported.
|
||||
// It also returns the package to use for PkgPath for an unexported field.
|
||||
func isExportedField(ft *Field) (bool, *Pkg) {
|
||||
func isExportedField(ft *Field) bool {
|
||||
if ft.Sym != nil && ft.Embedded == 0 {
|
||||
return exportname(ft.Sym.Name), ft.Sym.Pkg
|
||||
return exportname(ft.Sym.Name)
|
||||
} else {
|
||||
if ft.Type.Sym != nil &&
|
||||
(ft.Type.Sym.Pkg == builtinpkg || !exportname(ft.Type.Sym.Name)) {
|
||||
return false, ft.Type.Sym.Pkg
|
||||
return false
|
||||
} else {
|
||||
return true, nil
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dnameField dumps a reflect.name for a struct field.
|
||||
func dnameField(s *Sym, ot int, spkg *Pkg, ft *Field) int {
|
||||
func dnameField(s *Sym, ot int, ft *Field) int {
|
||||
var name string
|
||||
if ft.Sym != nil && ft.Embedded == 0 {
|
||||
name = ft.Sym.Name
|
||||
}
|
||||
isExported, fpkg := isExportedField(ft)
|
||||
if isExported || fpkg == spkg {
|
||||
fpkg = nil
|
||||
}
|
||||
nsym := dname(name, ft.Note, fpkg, isExported)
|
||||
nsym := dname(name, ft.Note, nil, isExportedField(ft))
|
||||
return dsymptrLSym(Linksym(s), ot, nsym, 0)
|
||||
}
|
||||
|
||||
@@ -834,13 +829,9 @@ func dcommontype(s *Sym, ot int, t *Type) int {
|
||||
algsym = dalgsym(t)
|
||||
}
|
||||
|
||||
sptrWeak := true
|
||||
var sptr *Sym
|
||||
if !t.IsPtr() || t.ptrTo != nil {
|
||||
tptr := ptrto(t)
|
||||
if t.Sym != nil || methods(tptr) != nil {
|
||||
sptrWeak = false
|
||||
}
|
||||
tptr := ptrto(t)
|
||||
if !t.IsPtr() && (t.Sym != nil || methods(tptr) != nil) {
|
||||
sptr = dtypesym(tptr)
|
||||
}
|
||||
|
||||
@@ -927,13 +918,10 @@ func dcommontype(s *Sym, ot int, t *Type) int {
|
||||
|
||||
nsym := dname(p, "", nil, exported)
|
||||
ot = dsymptrOffLSym(Linksym(s), ot, nsym, 0) // str
|
||||
// ptrToThis
|
||||
if sptr == nil {
|
||||
ot = duint32(s, ot, 0)
|
||||
} else if sptrWeak {
|
||||
ot = dsymptrWeakOffLSym(Linksym(s), ot, Linksym(sptr))
|
||||
} else {
|
||||
ot = dsymptrOffLSym(Linksym(s), ot, Linksym(sptr), 0)
|
||||
ot = dsymptrOffLSym(Linksym(s), ot, Linksym(sptr), 0) // ptrToThis
|
||||
}
|
||||
|
||||
return ot
|
||||
@@ -1344,7 +1332,7 @@ ok:
|
||||
|
||||
for _, f := range t.Fields().Slice() {
|
||||
// ../../../../runtime/type.go:/structField
|
||||
ot = dnameField(s, ot, pkg, f)
|
||||
ot = dnameField(s, ot, f)
|
||||
ot = dsymptr(s, ot, dtypesym(f.Type), 0)
|
||||
ot = duintptr(s, ot, uint64(f.Offset))
|
||||
}
|
||||
|
||||
@@ -58,8 +58,6 @@ func (x byLineno) Len() int { return len(x) }
|
||||
func (x byLineno) Less(i, j int) bool { return x[i].lineno < x[j].lineno }
|
||||
func (x byLineno) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
|
||||
|
||||
// flusherrors sorts errors seen so far by line number, prints them to stdout,
|
||||
// and empties the errors array.
|
||||
func flusherrors() {
|
||||
Ctxt.Bso.Flush()
|
||||
if len(errors) == 0 {
|
||||
|
||||
@@ -11,6 +11,9 @@ const (
|
||||
switchKindExpr = iota // switch a {...} or switch 5 {...}
|
||||
switchKindTrue // switch true {...} or switch {...}
|
||||
switchKindFalse // switch false {...}
|
||||
|
||||
// type switch
|
||||
switchKindType // switch a.(type) {...}
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -433,6 +433,38 @@ func convFuncName(from, to *Type) string {
|
||||
panic("unreachable")
|
||||
}
|
||||
|
||||
// Build name of function: assertI2E etc.
|
||||
// If with2suffix is true, the form ending in "2" is returned".
|
||||
func assertFuncName(from, to *Type, with2suffix bool) string {
|
||||
l := len("assertX2X2")
|
||||
if !with2suffix {
|
||||
l--
|
||||
}
|
||||
tkind := to.iet()
|
||||
switch from.iet() {
|
||||
case 'E':
|
||||
switch tkind {
|
||||
case 'I':
|
||||
return "assertE2I2"[:l]
|
||||
case 'E':
|
||||
return "assertE2E2"[:l]
|
||||
case 'T':
|
||||
return "assertE2T2"[:l]
|
||||
}
|
||||
case 'I':
|
||||
switch tkind {
|
||||
case 'I':
|
||||
return "assertI2I2"[:l]
|
||||
case 'E':
|
||||
return "assertI2E2"[:l]
|
||||
case 'T':
|
||||
return "assertI2T2"[:l]
|
||||
}
|
||||
}
|
||||
Fatalf("unknown assert func %c2%c", from.iet(), to.iet())
|
||||
panic("unreachable")
|
||||
}
|
||||
|
||||
// The result of walkexpr MUST be assigned back to n, e.g.
|
||||
// n.Left = walkexpr(n.Left, init)
|
||||
func walkexpr(n *Node, init *Nodes) *Node {
|
||||
@@ -2067,6 +2099,11 @@ func isstack(n *Node) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (n *Node) isGlobal() bool {
|
||||
n = outervalue(n)
|
||||
return n.Op == ONAME && n.Class == PEXTERN
|
||||
}
|
||||
|
||||
// Do we need a write barrier for the assignment l = r?
|
||||
func needwritebarrier(l *Node, r *Node) bool {
|
||||
if !use_writebarrier {
|
||||
|
||||
@@ -188,10 +188,7 @@ func cse(f *Func) {
|
||||
for _, b := range f.Blocks {
|
||||
out:
|
||||
for _, v := range b.Values {
|
||||
// New values are created when selectors are copied to
|
||||
// a new block. We can safely ignore those new values,
|
||||
// since they have already been copied (issue 17918).
|
||||
if int(v.ID) >= len(rewrite) || rewrite[v.ID] != nil {
|
||||
if rewrite[v.ID] != nil {
|
||||
continue
|
||||
}
|
||||
if v.Op != OpSelect0 && v.Op != OpSelect1 {
|
||||
|
||||
@@ -869,6 +869,7 @@ func (s *regAllocState) regalloc(f *Func) {
|
||||
m := s.values[a.ID].regs &^ phiUsed & s.allocatable
|
||||
if m != 0 {
|
||||
r := pickReg(m)
|
||||
s.freeReg(r)
|
||||
phiUsed |= regMask(1) << r
|
||||
phiRegs = append(phiRegs, r)
|
||||
} else {
|
||||
@@ -877,7 +878,7 @@ func (s *regAllocState) regalloc(f *Func) {
|
||||
}
|
||||
|
||||
// Second pass - deallocate any phi inputs which are now dead.
|
||||
for i, v := range phis {
|
||||
for _, v := range phis {
|
||||
if !s.values[v.ID].needReg {
|
||||
continue
|
||||
}
|
||||
@@ -886,31 +887,6 @@ func (s *regAllocState) regalloc(f *Func) {
|
||||
// Input is dead beyond the phi, deallocate
|
||||
// anywhere else it might live.
|
||||
s.freeRegs(s.values[a.ID].regs)
|
||||
} else {
|
||||
// Input is still live.
|
||||
// Try to move it around before kicking out, if there is a free register.
|
||||
// We generate a Copy in the predecessor block and record it. It will be
|
||||
// deleted if never used.
|
||||
r := phiRegs[i]
|
||||
if r == noRegister {
|
||||
continue
|
||||
}
|
||||
// Pick a free register. At this point some registers used in the predecessor
|
||||
// block may have been deallocated. Those are the ones used for Phis. Exclude
|
||||
// them (and they are not going to be helpful anyway).
|
||||
m := s.compatRegs(a.Type) &^ s.used &^ phiUsed
|
||||
if m != 0 && !s.values[a.ID].rematerializeable && countRegs(s.values[a.ID].regs) == 1 {
|
||||
r2 := pickReg(m)
|
||||
c := p.NewValue1(a.Line, OpCopy, a.Type, s.regs[r].c)
|
||||
s.copies[c] = false
|
||||
if s.f.pass.debug > regDebug {
|
||||
fmt.Printf("copy %s to %s : %s\n", a, c, s.registers[r2].Name())
|
||||
}
|
||||
s.setOrig(c, a)
|
||||
s.assignReg(r2, a, c)
|
||||
s.endRegs[p.ID] = append(s.endRegs[p.ID], endReg{r2, a, c})
|
||||
}
|
||||
s.freeReg(r)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,7 @@ type Node interface {
|
||||
}
|
||||
|
||||
type node struct {
|
||||
// commented out for now since not yet used
|
||||
// doc *Comment // nil means no comment(s) attached
|
||||
doc *Comment // nil means no comment(s) attached
|
||||
pos uint32
|
||||
line uint32
|
||||
}
|
||||
|
||||
@@ -1809,19 +1809,24 @@ func (p *parser) commClause() *CommClause {
|
||||
switch p.tok {
|
||||
case _Case:
|
||||
p.next()
|
||||
c.Comm = p.simpleStmt(nil, false)
|
||||
lhs := p.exprList()
|
||||
|
||||
// The syntax restricts the possible simple statements here to:
|
||||
//
|
||||
// lhs <- x (send statement)
|
||||
// <-x
|
||||
// lhs = <-x
|
||||
// lhs := <-x
|
||||
//
|
||||
// All these (and more) are recognized by simpleStmt and invalid
|
||||
// syntax trees are flagged later, during type checking.
|
||||
// TODO(gri) eventually may want to restrict valid syntax trees
|
||||
// here.
|
||||
if _, ok := lhs.(*ListExpr); !ok && p.tok == _Arrow {
|
||||
// lhs <- x
|
||||
} else {
|
||||
// lhs
|
||||
// lhs = <-x
|
||||
// lhs := <-x
|
||||
if p.tok == _Assign || p.tok == _Define {
|
||||
// TODO(gri) check that lhs has at most 2 entries
|
||||
} else if p.tok == _Colon {
|
||||
// TODO(gri) check that lhs has at most 1 entry
|
||||
} else {
|
||||
panic("unimplemented")
|
||||
}
|
||||
}
|
||||
|
||||
c.Comm = p.simpleStmt(lhs, false)
|
||||
|
||||
case _Default:
|
||||
p.next()
|
||||
|
||||
@@ -179,6 +179,6 @@ func TestParseFile(t *testing.T) {
|
||||
t.Error("missing io error")
|
||||
}
|
||||
if err != first {
|
||||
t.Errorf("got %v; want first error %v", err, first)
|
||||
t.Error("got %v; want first error %v", err, first)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"cmd/compile/internal/arm"
|
||||
"cmd/compile/internal/arm64"
|
||||
"cmd/compile/internal/gc"
|
||||
"cmd/compile/internal/mips"
|
||||
"cmd/compile/internal/mips64"
|
||||
"cmd/compile/internal/ppc64"
|
||||
"cmd/compile/internal/s390x"
|
||||
@@ -37,8 +36,6 @@ func main() {
|
||||
arm.Init()
|
||||
case "arm64":
|
||||
arm64.Init()
|
||||
case "mips", "mipsle":
|
||||
mips.Init()
|
||||
case "mips64", "mips64le":
|
||||
mips64.Init()
|
||||
case "ppc64", "ppc64le":
|
||||
|
||||
@@ -64,12 +64,9 @@ func htmlOutput(profile, outfile string) error {
|
||||
} else {
|
||||
out, err = os.Create(outfile)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = htmlTemplate.Execute(out, d)
|
||||
if err2 := out.Close(); err == nil {
|
||||
err = err2
|
||||
if err == nil {
|
||||
err = out.Close()
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -93,29 +93,6 @@ func ParseProfiles(fileName string) ([]*Profile, error) {
|
||||
}
|
||||
for _, p := range files {
|
||||
sort.Sort(blocksByStart(p.Blocks))
|
||||
// Merge samples from the same location.
|
||||
j := 1
|
||||
for i := 1; i < len(p.Blocks); i++ {
|
||||
b := p.Blocks[i]
|
||||
last := p.Blocks[j-1]
|
||||
if b.StartLine == last.StartLine &&
|
||||
b.StartCol == last.StartCol &&
|
||||
b.EndLine == last.EndLine &&
|
||||
b.EndCol == last.EndCol {
|
||||
if b.NumStmt != last.NumStmt {
|
||||
return nil, fmt.Errorf("inconsistent NumStmt: changed from %d to %d", last.NumStmt, b.NumStmt)
|
||||
}
|
||||
if mode == "set" {
|
||||
p.Blocks[j-1].Count |= b.Count
|
||||
} else {
|
||||
p.Blocks[j-1].Count += b.Count
|
||||
}
|
||||
continue
|
||||
}
|
||||
p.Blocks[j] = b
|
||||
j++
|
||||
}
|
||||
p.Blocks = p.Blocks[:j]
|
||||
}
|
||||
// Generate a sorted slice.
|
||||
profiles := make([]*Profile, 0, len(files))
|
||||
|
||||
2
src/cmd/dist/build.go
vendored
2
src/cmd/dist/build.go
vendored
@@ -1107,8 +1107,6 @@ var cgoEnabled = map[string]bool{
|
||||
"linux/arm64": true,
|
||||
"linux/ppc64": false,
|
||||
"linux/ppc64le": true,
|
||||
"linux/mips": false,
|
||||
"linux/mipsle": false,
|
||||
"linux/mips64": true,
|
||||
"linux/mips64le": true,
|
||||
"linux/s390x": true,
|
||||
|
||||
2
src/cmd/dist/buildtool.go
vendored
2
src/cmd/dist/buildtool.go
vendored
@@ -37,7 +37,6 @@ var bootstrapDirs = []string{
|
||||
"cmd/compile/internal/arm",
|
||||
"cmd/compile/internal/arm64",
|
||||
"cmd/compile/internal/gc",
|
||||
"cmd/compile/internal/mips",
|
||||
"cmd/compile/internal/mips64",
|
||||
"cmd/compile/internal/ppc64",
|
||||
"cmd/compile/internal/s390x",
|
||||
@@ -60,7 +59,6 @@ var bootstrapDirs = []string{
|
||||
"cmd/link/internal/arm",
|
||||
"cmd/link/internal/arm64",
|
||||
"cmd/link/internal/ld",
|
||||
"cmd/link/internal/mips",
|
||||
"cmd/link/internal/mips64",
|
||||
"cmd/link/internal/ppc64",
|
||||
"cmd/link/internal/s390x",
|
||||
|
||||
12
src/cmd/dist/test.go
vendored
12
src/cmd/dist/test.go
vendored
@@ -746,14 +746,6 @@ func (t *tester) supportedBuildmode(mode string) bool {
|
||||
}
|
||||
return false
|
||||
case "plugin":
|
||||
if os.Getenv("GO_BUILDER_NAME") == "linux-amd64-noopt" {
|
||||
// Skip the plugin tests on noopt. They're
|
||||
// causing build failures potentially
|
||||
// obscuring other issues. This is hopefully a
|
||||
// temporary workaround. See golang.org/issue/17937.
|
||||
return false
|
||||
}
|
||||
|
||||
// linux-arm64 is missing because it causes the external linker
|
||||
// to crash, see https://golang.org/issue/17138
|
||||
switch pair {
|
||||
@@ -1063,7 +1055,7 @@ func (t *tester) runFlag(rx string) string {
|
||||
func (t *tester) raceTest(dt *distTest) error {
|
||||
t.addCmd(dt, "src", "go", "test", "-race", "-i", "runtime/race", "flag", "os/exec")
|
||||
t.addCmd(dt, "src", "go", "test", "-race", t.runFlag("Output"), "runtime/race")
|
||||
t.addCmd(dt, "src", "go", "test", "-race", "-short", t.runFlag("TestParse|TestEcho|TestStdinCloseRace"), "flag", "os/exec")
|
||||
t.addCmd(dt, "src", "go", "test", "-race", "-short", t.runFlag("TestParse|TestEcho"), "flag", "os/exec")
|
||||
// We don't want the following line, because it
|
||||
// slows down all.bash (by 10 seconds on my laptop).
|
||||
// The race builder should catch any error here, but doesn't.
|
||||
@@ -1076,7 +1068,7 @@ func (t *tester) raceTest(dt *distTest) error {
|
||||
}
|
||||
if t.extLink() {
|
||||
// Test with external linking; see issue 9133.
|
||||
t.addCmd(dt, "src", "go", "test", "-race", "-short", "-ldflags=-linkmode=external", t.runFlag("TestParse|TestEcho|TestStdinCloseRace"), "flag", "os/exec")
|
||||
t.addCmd(dt, "src", "go", "test", "-race", "-short", "-ldflags=-linkmode=external", t.runFlag("TestParse|TestEcho"), "flag", "os/exec")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
5
src/cmd/dist/util.go
vendored
5
src/cmd/dist/util.go
vendored
@@ -445,11 +445,6 @@ func main() {
|
||||
if elfIsLittleEndian(os.Args[0]) {
|
||||
gohostarch = "mips64le"
|
||||
}
|
||||
case strings.Contains(out, "mips"):
|
||||
gohostarch = "mips"
|
||||
if elfIsLittleEndian(os.Args[0]) {
|
||||
gohostarch = "mipsle"
|
||||
}
|
||||
case strings.Contains(out, "s390x"):
|
||||
gohostarch = "s390x"
|
||||
case gohostos == "darwin":
|
||||
|
||||
@@ -929,11 +929,8 @@
|
||||
// On Windows, the value is a semicolon-separated string.
|
||||
// On Plan 9, the value is a list.
|
||||
//
|
||||
// If the environment variable is unset, GOPATH defaults
|
||||
// to a subdirectory named "go" in the user's home directory
|
||||
// ($HOME/go on Unix, %USERPROFILE%\go on Windows),
|
||||
// unless that directory holds a Go distribution.
|
||||
// Run "go env GOPATH" to see the current GOPATH.
|
||||
// GOPATH must be set to get, build and install packages outside the
|
||||
// standard Go tree.
|
||||
//
|
||||
// Each directory listed in GOPATH must have a prescribed structure:
|
||||
//
|
||||
@@ -961,9 +958,9 @@
|
||||
//
|
||||
// Here's an example directory layout:
|
||||
//
|
||||
// GOPATH=/home/user/go
|
||||
// GOPATH=/home/user/gocode
|
||||
//
|
||||
// /home/user/go/
|
||||
// /home/user/gocode/
|
||||
// src/
|
||||
// foo/
|
||||
// bar/ (go code in package bar)
|
||||
@@ -989,7 +986,7 @@
|
||||
// by code in the directory tree rooted at the parent of "internal".
|
||||
// Here's an extended version of the directory layout above:
|
||||
//
|
||||
// /home/user/go/
|
||||
// /home/user/gocode/
|
||||
// src/
|
||||
// crash/
|
||||
// bang/ (go code in package bang)
|
||||
@@ -1027,7 +1024,7 @@
|
||||
// but with the "internal" directory renamed to "vendor"
|
||||
// and a new foo/vendor/crash/bang directory added:
|
||||
//
|
||||
// /home/user/go/
|
||||
// /home/user/gocode/
|
||||
// src/
|
||||
// crash/
|
||||
// bang/ (go code in package bang)
|
||||
|
||||
@@ -39,7 +39,7 @@ func runBug(cmd *Command, args []string) {
|
||||
fmt.Fprint(&buf, "#### System details\n\n")
|
||||
fmt.Fprintln(&buf, "```")
|
||||
fmt.Fprintf(&buf, "go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
||||
env := newEnv
|
||||
env := mkEnv()
|
||||
env = append(env, extraEnvVars()...)
|
||||
for _, e := range env {
|
||||
fmt.Fprintf(&buf, "%s=\"%s\"\n", e.name, e.value)
|
||||
|
||||
@@ -2580,11 +2580,7 @@ func (gcToolchain) ld(b *builder, root *action, out string, allactions []*action
|
||||
ldflags = append(ldflags, "-w")
|
||||
}
|
||||
if buildBuildmode == "plugin" {
|
||||
pluginpath := root.p.ImportPath
|
||||
if pluginpath == "command-line-arguments" {
|
||||
pluginpath = "plugin/unnamed-" + root.p.buildID
|
||||
}
|
||||
ldflags = append(ldflags, "-pluginpath", pluginpath)
|
||||
ldflags = append(ldflags, "-pluginpath", root.p.ImportPath)
|
||||
}
|
||||
|
||||
// If the user has not specified the -extld option, then specify the
|
||||
|
||||
@@ -40,7 +40,7 @@ func mkEnv() []envVar {
|
||||
{"GOHOSTARCH", runtime.GOARCH},
|
||||
{"GOHOSTOS", runtime.GOOS},
|
||||
{"GOOS", goos},
|
||||
{"GOPATH", buildContext.GOPATH},
|
||||
{"GOPATH", os.Getenv("GOPATH")},
|
||||
{"GORACE", os.Getenv("GORACE")},
|
||||
{"GOROOT", goroot},
|
||||
{"GOTOOLDIR", toolDir},
|
||||
@@ -62,11 +62,13 @@ func mkEnv() []envVar {
|
||||
env = append(env, envVar{"GO386", os.Getenv("GO386")})
|
||||
}
|
||||
|
||||
cmd := b.gccCmd(".")
|
||||
env = append(env, envVar{"CC", cmd[0]})
|
||||
env = append(env, envVar{"GOGCCFLAGS", strings.Join(cmd[3:], " ")})
|
||||
cmd = b.gxxCmd(".")
|
||||
env = append(env, envVar{"CXX", cmd[0]})
|
||||
if goos != "plan9" {
|
||||
cmd := b.gccCmd(".")
|
||||
env = append(env, envVar{"CC", cmd[0]})
|
||||
env = append(env, envVar{"GOGCCFLAGS", strings.Join(cmd[3:], " ")})
|
||||
cmd = b.gxxCmd(".")
|
||||
env = append(env, envVar{"CXX", cmd[0]})
|
||||
}
|
||||
|
||||
if buildContext.CgoEnabled {
|
||||
env = append(env, envVar{"CGO_ENABLED", "1"})
|
||||
@@ -102,7 +104,7 @@ func extraEnvVars() []envVar {
|
||||
}
|
||||
|
||||
func runEnv(cmd *Command, args []string) {
|
||||
env := newEnv
|
||||
env := mkEnv()
|
||||
env = append(env, extraEnvVars()...)
|
||||
if len(args) > 0 {
|
||||
for _, name := range args {
|
||||
|
||||
@@ -417,10 +417,6 @@ func downloadPackage(p *Package) error {
|
||||
if list[0] == goroot {
|
||||
return fmt.Errorf("cannot download, $GOPATH must not be set to $GOROOT. For more details see: 'go help gopath'")
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(list[0], "src/cmd/go/alldocs.go")); err == nil {
|
||||
return fmt.Errorf("cannot download, %s is a GOROOT, not a GOPATH. For more details see: 'go help gopath'", list[0])
|
||||
}
|
||||
p.build.Root = list[0]
|
||||
p.build.SrcRoot = filepath.Join(list[0], "src")
|
||||
p.build.PkgRoot = filepath.Join(list[0], "pkg")
|
||||
}
|
||||
@@ -449,19 +445,11 @@ func downloadPackage(p *Package) error {
|
||||
if _, err := os.Stat(root); err == nil {
|
||||
return fmt.Errorf("%s exists but %s does not - stale checkout?", root, meta)
|
||||
}
|
||||
|
||||
_, err := os.Stat(p.build.Root)
|
||||
gopathExisted := err == nil
|
||||
|
||||
// Some version control tools require the parent of the target to exist.
|
||||
parent, _ := filepath.Split(root)
|
||||
if err = os.MkdirAll(parent, 0777); err != nil {
|
||||
return err
|
||||
}
|
||||
if buildV && !gopathExisted && p.build.Root == buildContext.GOPATH {
|
||||
fmt.Fprintf(os.Stderr, "created GOPATH=%s; see 'go help gopath'\n", p.build.Root)
|
||||
}
|
||||
|
||||
if err = vcs.create(root, repo); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package main_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"go/build"
|
||||
"go/format"
|
||||
@@ -49,17 +50,6 @@ func init() {
|
||||
// many linux/arm machines are too slow to run
|
||||
// the full set of external tests.
|
||||
skipExternal = true
|
||||
case "mips", "mipsle", "mips64", "mips64le":
|
||||
// Also slow.
|
||||
skipExternal = true
|
||||
if testenv.Builder() != "" {
|
||||
// On the builders, skip the cmd/go
|
||||
// tests. They're too slow and already
|
||||
// covered by other ports. There's
|
||||
// nothing os/arch specific in the
|
||||
// tests.
|
||||
canRun = false
|
||||
}
|
||||
}
|
||||
case "freebsd":
|
||||
switch runtime.GOARCH {
|
||||
@@ -77,6 +67,8 @@ func init() {
|
||||
// The TestMain function creates a go command for testing purposes and
|
||||
// deletes it after the tests have been run.
|
||||
func TestMain(m *testing.M) {
|
||||
flag.Parse()
|
||||
|
||||
if canRun {
|
||||
args := []string{"build", "-tags", "testgo", "-o", "testgo" + exeSuffix}
|
||||
if race.Enabled {
|
||||
@@ -1063,14 +1055,14 @@ func TestInternalPackagesInGOROOTAreRespected(t *testing.T) {
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
tg.runFail("build", "-v", "./testdata/testinternal")
|
||||
tg.grepBoth(`testinternal(\/|\\)p\.go\:3\:8\: use of internal package not allowed`, "wrong error message for testdata/testinternal")
|
||||
tg.grepBoth("use of internal package not allowed", "wrong error message for testdata/testinternal")
|
||||
}
|
||||
|
||||
func TestInternalPackagesOutsideGOROOTAreRespected(t *testing.T) {
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
tg.runFail("build", "-v", "./testdata/testinternal2")
|
||||
tg.grepBoth(`testinternal2(\/|\\)p\.go\:3\:8\: use of internal package not allowed`, "wrote error message for testdata/testinternal2")
|
||||
tg.grepBoth("use of internal package not allowed", "wrote error message for testdata/testinternal2")
|
||||
}
|
||||
|
||||
func TestRunInternal(t *testing.T) {
|
||||
@@ -1080,7 +1072,7 @@ func TestRunInternal(t *testing.T) {
|
||||
tg.setenv("GOPATH", dir)
|
||||
tg.run("run", filepath.Join(dir, "src/run/good.go"))
|
||||
tg.runFail("run", filepath.Join(dir, "src/run/bad.go"))
|
||||
tg.grepStderr(`testdata(\/|\\)src(\/|\\)run(\/|\\)bad\.go\:3\:8\: use of internal package not allowed`, "unexpected error for run/bad.go")
|
||||
tg.grepStderr("use of internal package not allowed", "unexpected error for run/bad.go")
|
||||
}
|
||||
|
||||
func testMove(t *testing.T, vcs, url, base, config string) {
|
||||
@@ -1672,150 +1664,15 @@ func TestMentionGOPATHNotOnSecondEntry(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func homeEnvName() string {
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
return "USERPROFILE"
|
||||
case "plan9":
|
||||
return "home"
|
||||
default:
|
||||
return "HOME"
|
||||
}
|
||||
}
|
||||
|
||||
// Test go env missing GOPATH shows default.
|
||||
func TestMissingGOPATHEnvShowsDefault(t *testing.T) {
|
||||
// Test missing GOPATH is reported.
|
||||
func TestMissingGOPATHIsReported(t *testing.T) {
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
tg.parallel()
|
||||
tg.setenv("GOPATH", "")
|
||||
tg.run("env", "GOPATH")
|
||||
|
||||
want := filepath.Join(os.Getenv(homeEnvName()), "go")
|
||||
got := strings.TrimSpace(tg.getStdout())
|
||||
if got != want {
|
||||
t.Errorf("got %q; want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// Test go get missing GOPATH causes go get to warn if directory doesn't exist.
|
||||
func TestMissingGOPATHGetWarnsIfNotExists(t *testing.T) {
|
||||
if _, err := exec.LookPath("git"); err != nil {
|
||||
t.Skip("skipping because git binary not found")
|
||||
}
|
||||
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
|
||||
// setenv variables for test and defer deleting temporary home directory.
|
||||
tg.setenv("GOPATH", "")
|
||||
tmp, err := ioutil.TempDir("", "")
|
||||
if err != nil {
|
||||
t.Fatalf("could not create tmp home: %v", err)
|
||||
}
|
||||
defer os.RemoveAll(tmp)
|
||||
tg.setenv(homeEnvName(), tmp)
|
||||
|
||||
tg.run("get", "-v", "github.com/golang/example/hello")
|
||||
|
||||
want := fmt.Sprintf("created GOPATH=%s; see 'go help gopath'", filepath.Join(tmp, "go"))
|
||||
got := strings.TrimSpace(tg.getStderr())
|
||||
if !strings.Contains(got, want) {
|
||||
t.Errorf("got %q; want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// Test go get missing GOPATH causes no warning if directory exists.
|
||||
func TestMissingGOPATHGetDoesntWarnIfExists(t *testing.T) {
|
||||
if _, err := exec.LookPath("git"); err != nil {
|
||||
t.Skip("skipping because git binary not found")
|
||||
}
|
||||
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
|
||||
// setenv variables for test and defer resetting them.
|
||||
tg.setenv("GOPATH", "")
|
||||
tmp, err := ioutil.TempDir("", "")
|
||||
if err != nil {
|
||||
t.Fatalf("could not create tmp home: %v", err)
|
||||
}
|
||||
defer os.RemoveAll(tmp)
|
||||
if err := os.Mkdir(filepath.Join(tmp, "go"), 0777); err != nil {
|
||||
t.Fatalf("could not create $HOME/go: %v", err)
|
||||
}
|
||||
|
||||
tg.setenv(homeEnvName(), tmp)
|
||||
|
||||
tg.run("get", "github.com/golang/example/hello")
|
||||
|
||||
got := strings.TrimSpace(tg.getStderr())
|
||||
if got != "" {
|
||||
t.Errorf("got %q; wants empty", got)
|
||||
}
|
||||
}
|
||||
|
||||
// Test go get missing GOPATH fails if pointed file is not a directory.
|
||||
func TestMissingGOPATHGetFailsIfItsNotDirectory(t *testing.T) {
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
|
||||
// setenv variables for test and defer resetting them.
|
||||
tg.setenv("GOPATH", "")
|
||||
tmp, err := ioutil.TempDir("", "")
|
||||
if err != nil {
|
||||
t.Fatalf("could not create tmp home: %v", err)
|
||||
}
|
||||
defer os.RemoveAll(tmp)
|
||||
|
||||
path := filepath.Join(tmp, "go")
|
||||
if err := ioutil.WriteFile(path, nil, 0777); err != nil {
|
||||
t.Fatalf("could not create GOPATH at %s: %v", path, err)
|
||||
}
|
||||
tg.setenv(homeEnvName(), tmp)
|
||||
|
||||
const pkg = "github.com/golang/example/hello"
|
||||
tg.runFail("get", pkg)
|
||||
|
||||
msg := "not a directory"
|
||||
if runtime.GOOS == "windows" {
|
||||
msg = "The system cannot find the path specified."
|
||||
}
|
||||
want := fmt.Sprintf("package %s: mkdir %s: %s", pkg, filepath.Join(tmp, "go"), msg)
|
||||
got := strings.TrimSpace(tg.getStderr())
|
||||
if got != want {
|
||||
t.Errorf("got %q; wants %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// Test go install of missing package when missing GOPATH fails and shows default GOPATH.
|
||||
func TestMissingGOPATHInstallMissingPackageFailsAndShowsDefault(t *testing.T) {
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
|
||||
// setenv variables for test and defer resetting them.
|
||||
tg.setenv("GOPATH", "")
|
||||
tmp, err := ioutil.TempDir("", "")
|
||||
if err != nil {
|
||||
t.Fatalf("could not create tmp home: %v", err)
|
||||
}
|
||||
defer os.RemoveAll(tmp)
|
||||
if err := os.Mkdir(filepath.Join(tmp, "go"), 0777); err != nil {
|
||||
t.Fatalf("could not create $HOME/go: %v", err)
|
||||
}
|
||||
tg.setenv(homeEnvName(), tmp)
|
||||
|
||||
const pkg = "github.com/golang/example/hello"
|
||||
tg.runFail("install", pkg)
|
||||
|
||||
pkgPath := filepath.Join(strings.Split(pkg, "/")...)
|
||||
want := fmt.Sprintf("can't load package: package %s: cannot find package \"%s\" in any of:", pkg, pkg) +
|
||||
fmt.Sprintf("\n\t%s (from $GOROOT)", filepath.Join(runtime.GOROOT(), "src", pkgPath)) +
|
||||
fmt.Sprintf("\n\t%s (from $GOPATH)", filepath.Join(tmp, "go", "src", pkgPath))
|
||||
|
||||
got := strings.TrimSpace(tg.getStderr())
|
||||
if got != want {
|
||||
t.Errorf("got %q; wants %q", got, want)
|
||||
tg.runFail("install", "foo/quxx")
|
||||
if tg.grepCountBoth(`\(\$GOPATH not set\. For more details see: 'go help gopath'\)$`) != 1 {
|
||||
t.Error(`go install foo/quxx expected error: ($GOPATH not set. For more details see: 'go help gopath')`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2353,9 +2210,8 @@ func TestCgoPkgConfig(t *testing.T) {
|
||||
tg.parallel()
|
||||
|
||||
tg.run("env", "PKG_CONFIG")
|
||||
pkgConfig := strings.TrimSpace(tg.getStdout())
|
||||
if out, err := exec.Command(pkgConfig, "--atleast-pkgconfig-version", "0.24").CombinedOutput(); err != nil {
|
||||
t.Skipf("%s --atleast-pkgconfig-version 0.24: %v\n%s", pkgConfig, err, out)
|
||||
if _, err := exec.LookPath(strings.TrimSpace(tg.getStdout())); err != nil {
|
||||
t.Skip("skipping because pkg-config could not be found")
|
||||
}
|
||||
|
||||
// OpenBSD's pkg-config is strict about whitespace and only
|
||||
@@ -3586,12 +3442,6 @@ func TestGoEnv(t *testing.T) {
|
||||
tg.setenv("CGO_CFLAGS", "-foobar")
|
||||
tg.run("env", "CGO_CFLAGS")
|
||||
tg.grepStdout("^-foobar$", "CGO_CFLAGS not honored")
|
||||
|
||||
tg.setenv("CC", "gcc -fmust -fgo -ffaster")
|
||||
tg.run("env", "CC")
|
||||
tg.grepStdout("gcc", "CC not found")
|
||||
tg.run("env", "GOGCCFLAGS")
|
||||
tg.grepStdout("-ffaster", "CC arguments not found")
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
@@ -289,11 +289,8 @@ On Unix, the value is a colon-separated string.
|
||||
On Windows, the value is a semicolon-separated string.
|
||||
On Plan 9, the value is a list.
|
||||
|
||||
If the environment variable is unset, GOPATH defaults
|
||||
to a subdirectory named "go" in the user's home directory
|
||||
($HOME/go on Unix, %USERPROFILE%\go on Windows),
|
||||
unless that directory holds a Go distribution.
|
||||
Run "go env GOPATH" to see the current GOPATH.
|
||||
GOPATH must be set to get, build and install packages outside the
|
||||
standard Go tree.
|
||||
|
||||
Each directory listed in GOPATH must have a prescribed structure:
|
||||
|
||||
@@ -321,9 +318,9 @@ of DIR/bin. GOBIN must be an absolute path.
|
||||
|
||||
Here's an example directory layout:
|
||||
|
||||
GOPATH=/home/user/go
|
||||
GOPATH=/home/user/gocode
|
||||
|
||||
/home/user/go/
|
||||
/home/user/gocode/
|
||||
src/
|
||||
foo/
|
||||
bar/ (go code in package bar)
|
||||
@@ -349,7 +346,7 @@ Code in or below a directory named "internal" is importable only
|
||||
by code in the directory tree rooted at the parent of "internal".
|
||||
Here's an extended version of the directory layout above:
|
||||
|
||||
/home/user/go/
|
||||
/home/user/gocode/
|
||||
src/
|
||||
crash/
|
||||
bang/ (go code in package bang)
|
||||
@@ -387,7 +384,7 @@ Here's the example from the previous section,
|
||||
but with the "internal" directory renamed to "vendor"
|
||||
and a new foo/vendor/crash/bang directory added:
|
||||
|
||||
/home/user/go/
|
||||
/home/user/gocode/
|
||||
src/
|
||||
crash/
|
||||
bang/ (go code in package bang)
|
||||
|
||||
@@ -115,7 +115,6 @@ func setExitStatus(n int) {
|
||||
}
|
||||
|
||||
var origEnv []string
|
||||
var newEnv []envVar
|
||||
|
||||
func main() {
|
||||
_ = go11tag
|
||||
@@ -136,7 +135,7 @@ func main() {
|
||||
// Diagnose common mistake: GOPATH==GOROOT.
|
||||
// This setting is equivalent to not setting GOPATH at all,
|
||||
// which is not what most people want when they do it.
|
||||
if gopath := buildContext.GOPATH; gopath == runtime.GOROOT() {
|
||||
if gopath := os.Getenv("GOPATH"); gopath == runtime.GOROOT() {
|
||||
fmt.Fprintf(os.Stderr, "warning: GOPATH set to GOROOT (%s) has no effect\n", gopath)
|
||||
} else {
|
||||
for _, p := range filepath.SplitList(gopath) {
|
||||
@@ -165,8 +164,7 @@ func main() {
|
||||
// but in practice there might be skew
|
||||
// This makes sure we all agree.
|
||||
origEnv = os.Environ()
|
||||
newEnv = mkEnv()
|
||||
for _, env := range newEnv {
|
||||
for _, env := range mkEnv() {
|
||||
if os.Getenv(env.name) != env.value {
|
||||
os.Setenv(env.name, env.value)
|
||||
}
|
||||
|
||||
@@ -371,8 +371,10 @@ func loadImport(path, srcDir string, parent *Package, stk *importStack, importPo
|
||||
err = fmt.Errorf("code in directory %s expects import %q", bp.Dir, bp.ImportComment)
|
||||
}
|
||||
p.load(stk, bp, err)
|
||||
if p.Error != nil && p.Error.Pos == "" {
|
||||
p = setErrorPos(p, importPos)
|
||||
if p.Error != nil && p.Error.Pos == "" && len(importPos) > 0 {
|
||||
pos := importPos[0]
|
||||
pos.Filename = shortPath(pos.Filename)
|
||||
p.Error.Pos = pos.String()
|
||||
}
|
||||
|
||||
if origPath != cleanImport(origPath) {
|
||||
@@ -386,11 +388,11 @@ func loadImport(path, srcDir string, parent *Package, stk *importStack, importPo
|
||||
|
||||
// Checked on every import because the rules depend on the code doing the importing.
|
||||
if perr := disallowInternal(srcDir, p, stk); perr != p {
|
||||
return setErrorPos(perr, importPos)
|
||||
return perr
|
||||
}
|
||||
if mode&useVendor != 0 {
|
||||
if perr := disallowVendor(srcDir, origPath, p, stk); perr != p {
|
||||
return setErrorPos(perr, importPos)
|
||||
return perr
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,7 +402,12 @@ func loadImport(path, srcDir string, parent *Package, stk *importStack, importPo
|
||||
ImportStack: stk.copy(),
|
||||
Err: fmt.Sprintf("import %q is a program, not an importable package", path),
|
||||
}
|
||||
return setErrorPos(&perr, importPos)
|
||||
if len(importPos) > 0 {
|
||||
pos := importPos[0]
|
||||
pos.Filename = shortPath(pos.Filename)
|
||||
perr.Error.Pos = pos.String()
|
||||
}
|
||||
return &perr
|
||||
}
|
||||
|
||||
if p.local && parent != nil && !parent.local {
|
||||
@@ -409,21 +416,17 @@ func loadImport(path, srcDir string, parent *Package, stk *importStack, importPo
|
||||
ImportStack: stk.copy(),
|
||||
Err: fmt.Sprintf("local import %q in non-local package", path),
|
||||
}
|
||||
return setErrorPos(&perr, importPos)
|
||||
if len(importPos) > 0 {
|
||||
pos := importPos[0]
|
||||
pos.Filename = shortPath(pos.Filename)
|
||||
perr.Error.Pos = pos.String()
|
||||
}
|
||||
return &perr
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func setErrorPos(p *Package, importPos []token.Position) *Package {
|
||||
if len(importPos) > 0 {
|
||||
pos := importPos[0]
|
||||
pos.Filename = shortPath(pos.Filename)
|
||||
p.Error.Pos = pos.String()
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func cleanImport(path string) string {
|
||||
orig := path
|
||||
path = pathpkg.Clean(path)
|
||||
@@ -583,11 +586,6 @@ func disallowInternal(srcDir string, p *Package, stk *importStack) *Package {
|
||||
return p
|
||||
}
|
||||
|
||||
// We can't check standard packages with gccgo.
|
||||
if buildContext.Compiler == "gccgo" && p.Standard {
|
||||
return p
|
||||
}
|
||||
|
||||
// The stack includes p.ImportPath.
|
||||
// If that's the only thing on the stack, we started
|
||||
// with a name given on the command line, not an
|
||||
@@ -1636,7 +1634,7 @@ func computeBuildID(p *Package) {
|
||||
// Include the content of runtime/internal/sys/zversion.go in the hash
|
||||
// for package runtime. This will give package runtime a
|
||||
// different build ID in each Go release.
|
||||
if p.Standard && p.ImportPath == "runtime/internal/sys" && buildContext.Compiler != "gccgo" {
|
||||
if p.Standard && p.ImportPath == "runtime/internal/sys" {
|
||||
data, err := ioutil.ReadFile(filepath.Join(p.Dir, "zversion.go"))
|
||||
if err != nil {
|
||||
fatalf("go: %s", err)
|
||||
|
||||
2
src/cmd/go/testdata/src/dupload/dupload.go
vendored
2
src/cmd/go/testdata/src/dupload/dupload.go
vendored
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "dupload/p2"
|
||||
_"dupload/p2"
|
||||
_ "p"
|
||||
)
|
||||
|
||||
|
||||
1
src/cmd/go/testdata/src/my.pkg/pkg.go
vendored
1
src/cmd/go/testdata/src/my.pkg/pkg.go
vendored
@@ -1,3 +1,2 @@
|
||||
package pkg
|
||||
|
||||
var Text = "unset"
|
||||
|
||||
@@ -32,8 +32,8 @@ The flags are:
|
||||
-w
|
||||
Do not print reformatted sources to standard output.
|
||||
If a file's formatting is different from gofmt's, overwrite it
|
||||
with gofmt's version. If an error occurred during overwriting,
|
||||
the original file is restored from an automatic backup.
|
||||
with gofmt's version. If an error occured during overwriting,
|
||||
the orginal file is restored from an automatic backup.
|
||||
|
||||
Debugging support:
|
||||
-cpuprofile filename
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"runtime/pprof"
|
||||
"strings"
|
||||
)
|
||||
@@ -253,8 +252,6 @@ func diff(b1, b2 []byte) (data []byte, err error) {
|
||||
|
||||
}
|
||||
|
||||
const chmodSupported = runtime.GOOS != "windows"
|
||||
|
||||
// backupFile writes data to a new file named filename<number> with permissions perm,
|
||||
// with <number randomly chosen such that the file name is unique. backupFile returns
|
||||
// the chosen file name.
|
||||
@@ -265,13 +262,11 @@ func backupFile(filename string, data []byte, perm os.FileMode) (string, error)
|
||||
return "", err
|
||||
}
|
||||
bakname := f.Name()
|
||||
if chmodSupported {
|
||||
err = f.Chmod(perm)
|
||||
if err != nil {
|
||||
f.Close()
|
||||
os.Remove(bakname)
|
||||
return bakname, err
|
||||
}
|
||||
err = f.Chmod(perm)
|
||||
if err != nil {
|
||||
f.Close()
|
||||
os.Remove(bakname)
|
||||
return bakname, err
|
||||
}
|
||||
|
||||
// write data to backup file
|
||||
|
||||
@@ -171,16 +171,3 @@ func TestCRLF(t *testing.T) {
|
||||
t.Errorf("%s contains CR's", golden)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBackupFile(t *testing.T) {
|
||||
dir, err := ioutil.TempDir("", "gofmt_test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
name, err := backupFile(filepath.Join(dir, "foo.go"), []byte(" package main"), 0644)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("Created: %s", name)
|
||||
}
|
||||
|
||||
@@ -25,12 +25,7 @@ func Commands() [][]string {
|
||||
default:
|
||||
cmds = append(cmds, []string{"xdg-open"})
|
||||
}
|
||||
cmds = append(cmds,
|
||||
[]string{"chrome"},
|
||||
[]string{"google-chrome"},
|
||||
[]string{"chromium"},
|
||||
[]string{"firefox"},
|
||||
)
|
||||
cmds = append(cmds, []string{"chrome"}, []string{"google-chrome"}, []string{"firefox"})
|
||||
return cmds
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ package dwarf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// InfoPrefix is the prefix for all the symbols containing DWARF info entries.
|
||||
@@ -577,9 +576,6 @@ func PutFunc(ctxt Context, s Sym, name string, external bool, startPC Sym, size
|
||||
putattr(ctxt, s, DW_ABRV_FUNCTION, DW_FORM_flag, DW_CLS_FLAG, ev, 0)
|
||||
names := make(map[string]bool)
|
||||
for v := vars; v != nil; v = v.Link {
|
||||
if strings.Contains(v.Name, ".autotmp_") {
|
||||
continue
|
||||
}
|
||||
var n string
|
||||
if names[v.Name] {
|
||||
n = fmt.Sprintf("%s#%d", v.Name, len(names))
|
||||
|
||||
@@ -601,7 +601,7 @@ func span7(ctxt *obj.Link, cursym *obj.LSym) {
|
||||
o = oplook(ctxt, p)
|
||||
|
||||
/* very large branches */
|
||||
if (o.type_ == 7 || o.type_ == 39) && p.Pcond != nil { // 7: BEQ and like, 39: CBZ and like
|
||||
if o.type_ == 7 && p.Pcond != nil {
|
||||
otxt := p.Pcond.Pc - c
|
||||
if otxt <= -(1<<18)+10 || otxt >= (1<<18)-10 {
|
||||
q := ctxt.NewProg()
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package arm64
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"internal/testenv"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestLarge generates a very large file to verify that large
|
||||
// program builds successfully, in particular, too-far
|
||||
// conditional branches are fixed.
|
||||
func TestLarge(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("Skip in short mode")
|
||||
}
|
||||
testenv.MustHaveGoBuild(t)
|
||||
|
||||
dir, err := ioutil.TempDir("", "testlarge")
|
||||
if err != nil {
|
||||
t.Fatalf("could not create directory: %v", err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
// generate a very large function
|
||||
buf := bytes.NewBuffer(make([]byte, 0, 7000000))
|
||||
gen(buf)
|
||||
|
||||
tmpfile := filepath.Join(dir, "x.s")
|
||||
err = ioutil.WriteFile(tmpfile, buf.Bytes(), 0644)
|
||||
if err != nil {
|
||||
t.Fatalf("can't write output: %v\n", err)
|
||||
}
|
||||
|
||||
// build generated file
|
||||
cmd := exec.Command(testenv.GoToolPath(t), "tool", "asm", "-o", filepath.Join(dir, "x.o"), tmpfile)
|
||||
cmd.Env = []string{"GOARCH=arm64", "GOOS=linux"}
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Errorf("Build failed: %v, output: %s", err, out)
|
||||
}
|
||||
}
|
||||
|
||||
// gen generates a very large program, with a very far conditional branch.
|
||||
func gen(buf *bytes.Buffer) {
|
||||
fmt.Fprintln(buf, "TEXT f(SB),0,$0-0")
|
||||
fmt.Fprintln(buf, "CBZ R0, label")
|
||||
fmt.Fprintln(buf, "BEQ label")
|
||||
for i := 0; i < 1<<19; i++ {
|
||||
fmt.Fprintln(buf, "MOVD R0, R1")
|
||||
}
|
||||
fmt.Fprintln(buf, "label:")
|
||||
fmt.Fprintln(buf, "RET")
|
||||
}
|
||||
@@ -145,22 +145,6 @@ func (s *LSym) WriteOff(ctxt *Link, off int64, rsym *LSym, roff int64) {
|
||||
r.Add = roff
|
||||
}
|
||||
|
||||
// WriteWeakOff writes a weak 4 byte offset to rsym+roff into s at offset off.
|
||||
// After linking the 4 bytes stored at s+off will be
|
||||
// rsym+roff-(start of section that s is in).
|
||||
func (s *LSym) WriteWeakOff(ctxt *Link, off int64, rsym *LSym, roff int64) {
|
||||
s.prepwrite(ctxt, off, 4)
|
||||
r := Addrel(s)
|
||||
r.Off = int32(off)
|
||||
if int64(r.Off) != off {
|
||||
ctxt.Diag("WriteOff: off overflow %d in %s", off, s.Name)
|
||||
}
|
||||
r.Siz = 4
|
||||
r.Sym = rsym
|
||||
r.Type = R_WEAKADDROFF
|
||||
r.Add = roff
|
||||
}
|
||||
|
||||
// WriteString writes a string of size siz into s at offset off.
|
||||
func (s *LSym) WriteString(ctxt *Link, off int64, siz int, str string) {
|
||||
if siz < len(str) {
|
||||
|
||||
@@ -538,11 +538,6 @@ const (
|
||||
// R_ADDROFF resolves to a 32-bit offset from the beginning of the section
|
||||
// holding the data being relocated to the referenced symbol.
|
||||
R_ADDROFF
|
||||
// R_WEAKADDROFF resolves just like R_ADDROFF but is a weak relocation.
|
||||
// A weak relocation does not make the symbol it refers to reachable,
|
||||
// and is only honored by the linker if the symbol is in some other way
|
||||
// reachable.
|
||||
R_WEAKADDROFF
|
||||
R_SIZE
|
||||
R_CALL
|
||||
R_CALLARM
|
||||
|
||||
@@ -413,7 +413,7 @@ func relocsym(ctxt *Link, s *Symbol) {
|
||||
Errorf(s, "unhandled relocation for %s (type %d rtype %d)", r.Sym.Name, r.Sym.Type, r.Type)
|
||||
}
|
||||
}
|
||||
if r.Sym != nil && r.Sym.Type != obj.STLSBSS && r.Type != obj.R_WEAKADDROFF && !r.Sym.Attr.Reachable() {
|
||||
if r.Sym != nil && r.Sym.Type != obj.STLSBSS && !r.Sym.Attr.Reachable() {
|
||||
Errorf(s, "unreachable sym in relocation: %s", r.Sym.Name)
|
||||
}
|
||||
|
||||
@@ -588,11 +588,6 @@ func relocsym(ctxt *Link, s *Symbol) {
|
||||
}
|
||||
o = Symaddr(r.Sym) + r.Add - int64(r.Sym.Sect.Vaddr)
|
||||
|
||||
case obj.R_WEAKADDROFF:
|
||||
if !r.Sym.Attr.Reachable() {
|
||||
continue
|
||||
}
|
||||
fallthrough
|
||||
case obj.R_ADDROFF:
|
||||
// The method offset tables using this relocation expect the offset to be relative
|
||||
// to the start of the first text section, even if there are multiple.
|
||||
@@ -604,19 +599,7 @@ func relocsym(ctxt *Link, s *Symbol) {
|
||||
}
|
||||
|
||||
// r->sym can be null when CALL $(constant) is transformed from absolute PC to relative PC call.
|
||||
case obj.R_GOTPCREL:
|
||||
if ctxt.DynlinkingGo() && Headtype == obj.Hdarwin && r.Sym != nil && r.Sym.Type != obj.SCONST {
|
||||
r.Done = 0
|
||||
r.Xadd = r.Add
|
||||
r.Xadd -= int64(r.Siz) // relative to address after the relocated chunk
|
||||
r.Xsym = r.Sym
|
||||
|
||||
o = r.Xadd
|
||||
o += int64(r.Siz)
|
||||
break
|
||||
}
|
||||
fallthrough
|
||||
case obj.R_CALL, obj.R_PCREL:
|
||||
case obj.R_CALL, obj.R_GOTPCREL, obj.R_PCREL:
|
||||
if Linkmode == LinkExternal && r.Sym != nil && r.Sym.Type != obj.SCONST && (r.Sym.Sect != s.Sect || r.Type == obj.R_GOTPCREL) {
|
||||
r.Done = 0
|
||||
|
||||
@@ -753,9 +736,6 @@ func dynrelocsym(ctxt *Link, s *Symbol) {
|
||||
continue
|
||||
}
|
||||
if !targ.Attr.Reachable() {
|
||||
if r.Type == obj.R_WEAKADDROFF {
|
||||
continue
|
||||
}
|
||||
Errorf(s, "dynamic relocation to unreachable symbol %s", targ.Name)
|
||||
}
|
||||
if r.Sym.Plt == -2 && r.Sym.Got != -2 { // make dynimport JMP table for PE object files.
|
||||
|
||||
@@ -308,12 +308,6 @@ func (d *deadcodepass) flood() {
|
||||
if r.Sym == nil {
|
||||
continue
|
||||
}
|
||||
if r.Type == obj.R_WEAKADDROFF {
|
||||
// An R_WEAKADDROFF relocation is not reason
|
||||
// enough to mark the pointed-to symbol as
|
||||
// reachable.
|
||||
continue
|
||||
}
|
||||
if r.Type != obj.R_METHODOFF {
|
||||
d.mark(r.Sym, s)
|
||||
continue
|
||||
|
||||
@@ -137,8 +137,6 @@ const (
|
||||
ElfSymTypeFunc = 2
|
||||
ElfSymTypeSection = 3
|
||||
ElfSymTypeFile = 4
|
||||
ElfSymTypeCommon = 5
|
||||
ElfSymTypeTLS = 6
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -753,10 +751,10 @@ func ldelf(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
|
||||
goto bad
|
||||
}
|
||||
symbols[i] = sym.sym
|
||||
if sym.type_ != ElfSymTypeFunc && sym.type_ != ElfSymTypeObject && sym.type_ != ElfSymTypeNone && sym.type_ != ElfSymTypeCommon {
|
||||
if sym.type_ != ElfSymTypeFunc && sym.type_ != ElfSymTypeObject && sym.type_ != ElfSymTypeNone {
|
||||
continue
|
||||
}
|
||||
if sym.shndx == ElfSymShnCommon || sym.type_ == ElfSymTypeCommon {
|
||||
if sym.shndx == ElfSymShnCommon {
|
||||
s = sym.sym
|
||||
if uint64(s.Size) < sym.size {
|
||||
s.Size = int64(sym.size)
|
||||
@@ -1037,7 +1035,7 @@ func readelfsym(ctxt *Link, elfobj *ElfObj, i int, sym *ElfSym, needSym int, loc
|
||||
case ElfSymTypeSection:
|
||||
s = elfobj.sect[sym.shndx].sym
|
||||
|
||||
case ElfSymTypeObject, ElfSymTypeFunc, ElfSymTypeNone, ElfSymTypeCommon:
|
||||
case ElfSymTypeObject, ElfSymTypeFunc, ElfSymTypeNone:
|
||||
switch sym.bind {
|
||||
case ElfSymBindGlobal:
|
||||
if needSym != 0 {
|
||||
|
||||
@@ -720,7 +720,7 @@ func objfile(ctxt *Link, lib *Library) {
|
||||
goto out
|
||||
}
|
||||
|
||||
if Buildmode == BuildmodeShared || Buildmode == BuildmodePlugin || ctxt.Syms.ROLookup("plugin.Open", 0) != nil {
|
||||
if Buildmode == BuildmodeShared {
|
||||
before := f.Offset()
|
||||
pkgdefBytes := make([]byte, atolwhex(arhdr.size))
|
||||
if _, err := io.ReadFull(f, pkgdefBytes); err != nil {
|
||||
@@ -1134,16 +1134,21 @@ func (l *Link) hostlink() {
|
||||
}
|
||||
}
|
||||
|
||||
sanitizers := *flagRace
|
||||
|
||||
for _, flag := range ldflag {
|
||||
if strings.HasPrefix(flag, "-fsanitize=") {
|
||||
sanitizers = true
|
||||
}
|
||||
}
|
||||
|
||||
argv = append(argv, ldflag...)
|
||||
|
||||
// When building a program with the default -buildmode=exe the
|
||||
// gc compiler generates code requires DT_TEXTREL in a
|
||||
// position independent executable (PIE). On systems where the
|
||||
// toolchain creates PIEs by default, and where DT_TEXTREL
|
||||
// does not work, the resulting programs will not run. See
|
||||
// issue #17847. To avoid this problem pass -no-pie to the
|
||||
// toolchain if it is supported.
|
||||
if Buildmode == BuildmodeExe {
|
||||
if sanitizers {
|
||||
// On a system where the toolchain creates position independent
|
||||
// executables by default, tsan/msan/asan/etc initialization can
|
||||
// fail. So we pass -no-pie here, but support for that flag is quite
|
||||
// new and we test for its support first.
|
||||
src := filepath.Join(*flagTmpdir, "trivial.c")
|
||||
if err := ioutil.WriteFile(src, []byte{}, 0666); err != nil {
|
||||
Errorf(nil, "WriteFile trivial.c failed: %v", err)
|
||||
@@ -2033,7 +2038,7 @@ func undefsym(ctxt *Link, s *Symbol) {
|
||||
if r.Sym.Type == obj.Sxxx || r.Sym.Type == obj.SXREF {
|
||||
Errorf(s, "undefined: %q", r.Sym.Name)
|
||||
}
|
||||
if !r.Sym.Attr.Reachable() && r.Type != obj.R_WEAKADDROFF {
|
||||
if !r.Sym.Attr.Reachable() {
|
||||
Errorf(s, "relocation target %q", r.Sym.Name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -530,20 +530,6 @@ func (ctxt *Link) symtab() {
|
||||
Addaddr(ctxt, abihashgostr, hashsym)
|
||||
adduint(ctxt, abihashgostr, uint64(hashsym.Size))
|
||||
}
|
||||
if Buildmode == BuildmodePlugin || ctxt.Syms.ROLookup("plugin.Open", 0) != nil {
|
||||
for _, l := range ctxt.Library {
|
||||
s := ctxt.Syms.Lookup("go.link.pkghashbytes."+l.Pkg, 0)
|
||||
s.Attr |= AttrReachable
|
||||
s.Type = obj.SRODATA
|
||||
s.Size = int64(len(l.hash))
|
||||
s.P = []byte(l.hash)
|
||||
str := ctxt.Syms.Lookup("go.link.pkghash."+l.Pkg, 0)
|
||||
str.Attr |= AttrReachable
|
||||
str.Type = obj.SRODATA
|
||||
Addaddr(ctxt, str, s)
|
||||
adduint(ctxt, str, uint64(len(l.hash)))
|
||||
}
|
||||
}
|
||||
|
||||
nsections := textsectionmap(ctxt)
|
||||
|
||||
@@ -618,28 +604,7 @@ func (ctxt *Link) symtab() {
|
||||
}
|
||||
if Buildmode == BuildmodePlugin {
|
||||
addgostring(ctxt, moduledata, "go.link.thispluginpath", *flagPluginPath)
|
||||
|
||||
pkghashes := ctxt.Syms.Lookup("go.link.pkghashes", 0)
|
||||
pkghashes.Attr |= AttrReachable
|
||||
pkghashes.Attr |= AttrLocal
|
||||
pkghashes.Type = obj.SRODATA
|
||||
|
||||
for i, l := range ctxt.Library {
|
||||
// pkghashes[i].name
|
||||
addgostring(ctxt, pkghashes, fmt.Sprintf("go.link.pkgname.%d", i), l.Pkg)
|
||||
// pkghashes[i].linktimehash
|
||||
addgostring(ctxt, pkghashes, fmt.Sprintf("go.link.pkglinkhash.%d", i), string(l.hash))
|
||||
// pkghashes[i].runtimehash
|
||||
hash := ctxt.Syms.ROLookup("go.link.pkghash."+l.Pkg, 0)
|
||||
Addaddr(ctxt, pkghashes, hash)
|
||||
}
|
||||
Addaddr(ctxt, moduledata, pkghashes)
|
||||
adduint(ctxt, moduledata, uint64(len(ctxt.Library)))
|
||||
adduint(ctxt, moduledata, uint64(len(ctxt.Library)))
|
||||
} else {
|
||||
adduint(ctxt, moduledata, 0) // pluginpath
|
||||
adduint(ctxt, moduledata, 0)
|
||||
adduint(ctxt, moduledata, 0) // pkghashes slice
|
||||
adduint(ctxt, moduledata, 0)
|
||||
adduint(ctxt, moduledata, 0)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"cmd/link/internal/arm"
|
||||
"cmd/link/internal/arm64"
|
||||
"cmd/link/internal/ld"
|
||||
"cmd/link/internal/mips"
|
||||
"cmd/link/internal/mips64"
|
||||
"cmd/link/internal/ppc64"
|
||||
"cmd/link/internal/s390x"
|
||||
@@ -46,8 +45,6 @@ func main() {
|
||||
arm.Init()
|
||||
case "arm64":
|
||||
arm64.Init()
|
||||
case "mips", "mipsle":
|
||||
mips.Init()
|
||||
case "mips64", "mips64le":
|
||||
mips64.Init()
|
||||
case "ppc64", "ppc64le":
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
var tmp, exe string // populated by buildObjdump
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
flag.Parse()
|
||||
if !testenv.HasGoBuild() {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -58,26 +58,26 @@ func PProf(c Completer, interactive **bool) Commands {
|
||||
"peek": {c, report.Tree, nil, true, "Output callers/callees of functions matching regexp"},
|
||||
|
||||
// Save binary formats to a file
|
||||
"callgrind": {c, report.Callgrind, awayFromTTY(interactive, "callgraph.out"), false, "Outputs a graph in callgrind format"},
|
||||
"proto": {c, report.Proto, awayFromTTY(interactive, "pb.gz"), false, "Outputs the profile in compressed protobuf format"},
|
||||
"callgrind": {c, report.Callgrind, awayFromTTY("callgraph.out"), false, "Outputs a graph in callgrind format"},
|
||||
"proto": {c, report.Proto, awayFromTTY("pb.gz"), false, "Outputs the profile in compressed protobuf format"},
|
||||
|
||||
// Generate report in DOT format and postprocess with dot
|
||||
"gif": {c, report.Dot, invokeDot(interactive, "gif"), false, "Outputs a graph image in GIF format"},
|
||||
"pdf": {c, report.Dot, invokeDot(interactive, "pdf"), false, "Outputs a graph in PDF format"},
|
||||
"png": {c, report.Dot, invokeDot(interactive, "png"), false, "Outputs a graph image in PNG format"},
|
||||
"ps": {c, report.Dot, invokeDot(interactive, "ps"), false, "Outputs a graph in PS format"},
|
||||
"gif": {c, report.Dot, invokeDot("gif"), false, "Outputs a graph image in GIF format"},
|
||||
"pdf": {c, report.Dot, invokeDot("pdf"), false, "Outputs a graph in PDF format"},
|
||||
"png": {c, report.Dot, invokeDot("png"), false, "Outputs a graph image in PNG format"},
|
||||
"ps": {c, report.Dot, invokeDot("ps"), false, "Outputs a graph in PS format"},
|
||||
|
||||
// Save SVG output into a file after including svgpan library
|
||||
"svg": {c, report.Dot, saveSVGToFile(interactive), false, "Outputs a graph in SVG format"},
|
||||
"svg": {c, report.Dot, saveSVGToFile(), false, "Outputs a graph in SVG format"},
|
||||
|
||||
// Visualize postprocessed dot output
|
||||
"eog": {c, report.Dot, invokeVisualizer(interactive, invokeDot(nil, "svg"), "svg", []string{"eog"}), false, "Visualize graph through eog"},
|
||||
"evince": {c, report.Dot, invokeVisualizer(interactive, invokeDot(nil, "pdf"), "pdf", []string{"evince"}), false, "Visualize graph through evince"},
|
||||
"gv": {c, report.Dot, invokeVisualizer(interactive, invokeDot(nil, "ps"), "ps", []string{"gv --noantialias"}), false, "Visualize graph through gv"},
|
||||
"web": {c, report.Dot, invokeVisualizer(interactive, saveSVGToFile(nil), "svg", browsers()), false, "Visualize graph through web browser"},
|
||||
"eog": {c, report.Dot, invokeVisualizer(interactive, invokeDot("svg"), "svg", []string{"eog"}), false, "Visualize graph through eog"},
|
||||
"evince": {c, report.Dot, invokeVisualizer(interactive, invokeDot("pdf"), "pdf", []string{"evince"}), false, "Visualize graph through evince"},
|
||||
"gv": {c, report.Dot, invokeVisualizer(interactive, invokeDot("ps"), "ps", []string{"gv --noantialias"}), false, "Visualize graph through gv"},
|
||||
"web": {c, report.Dot, invokeVisualizer(interactive, saveSVGToFile(), "svg", browsers()), false, "Visualize graph through web browser"},
|
||||
|
||||
// Visualize HTML directly generated by report.
|
||||
"weblist": {c, report.WebList, invokeVisualizer(interactive, awayFromTTY(nil, "html"), "html", browsers()), true, "Output annotated source in HTML for functions matching regexp or address"},
|
||||
"weblist": {c, report.WebList, invokeVisualizer(interactive, awayFromTTY("html"), "html", browsers()), true, "Output annotated source in HTML for functions matching regexp or address"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,9 +133,9 @@ func NewCompleter(cs Commands) Completer {
|
||||
// awayFromTTY saves the output in a file if it would otherwise go to
|
||||
// the terminal screen. This is used to avoid dumping binary data on
|
||||
// the screen.
|
||||
func awayFromTTY(interactive **bool, format string) PostProcessor {
|
||||
func awayFromTTY(format string) PostProcessor {
|
||||
return func(input *bytes.Buffer, output io.Writer, ui plugin.UI) error {
|
||||
if output == os.Stdout && (ui.IsTerminal() || interactive != nil && **interactive) {
|
||||
if output == os.Stdout && ui.IsTerminal() {
|
||||
tempFile, err := tempfile.New("", "profile", "."+format)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -149,8 +149,8 @@ func awayFromTTY(interactive **bool, format string) PostProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
func invokeDot(interactive **bool, format string) PostProcessor {
|
||||
divert := awayFromTTY(interactive, format)
|
||||
func invokeDot(format string) PostProcessor {
|
||||
divert := awayFromTTY(format)
|
||||
return func(input *bytes.Buffer, output io.Writer, ui plugin.UI) error {
|
||||
if _, err := exec.LookPath("dot"); err != nil {
|
||||
ui.PrintErr("Cannot find dot, have you installed Graphviz?")
|
||||
@@ -166,9 +166,9 @@ func invokeDot(interactive **bool, format string) PostProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
func saveSVGToFile(interactive **bool) PostProcessor {
|
||||
generateSVG := invokeDot(nil, "svg")
|
||||
divert := awayFromTTY(interactive, "svg")
|
||||
func saveSVGToFile() PostProcessor {
|
||||
generateSVG := invokeDot("svg")
|
||||
divert := awayFromTTY("svg")
|
||||
return func(input *bytes.Buffer, output io.Writer, ui plugin.UI) error {
|
||||
baseSVG := &bytes.Buffer{}
|
||||
generateSVG(input, baseSVG, ui)
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
package fetch
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -73,26 +72,11 @@ func PostURL(source, post string) ([]byte, error) {
|
||||
|
||||
// httpGet is a wrapper around http.Get; it is defined as a variable
|
||||
// so it can be redefined during for testing.
|
||||
var httpGet = func(source string, timeout time.Duration) (*http.Response, error) {
|
||||
url, err := url.Parse(source)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var tlsConfig *tls.Config
|
||||
if url.Scheme == "https+insecure" {
|
||||
tlsConfig = &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
}
|
||||
url.Scheme = "https"
|
||||
source = url.String()
|
||||
}
|
||||
|
||||
var httpGet = func(url string, timeout time.Duration) (*http.Response, error) {
|
||||
client := &http.Client{
|
||||
Transport: &http.Transport{
|
||||
ResponseHeaderTimeout: timeout + 5*time.Second,
|
||||
TLSClientConfig: tlsConfig,
|
||||
},
|
||||
}
|
||||
return client.Get(source)
|
||||
return client.Get(url)
|
||||
}
|
||||
|
||||
@@ -254,19 +254,10 @@ type traceContext struct {
|
||||
frameTree frameNode
|
||||
frameSeq int
|
||||
arrowSeq uint64
|
||||
gcount uint64
|
||||
|
||||
heapStats, prevHeapStats heapStats
|
||||
threadStats, prevThreadStats threadStats
|
||||
gstates, prevGstates [gStateCount]uint64
|
||||
}
|
||||
|
||||
type heapStats struct {
|
||||
heapAlloc uint64
|
||||
nextGC uint64
|
||||
}
|
||||
|
||||
type threadStats struct {
|
||||
gcount uint64
|
||||
gstates [gStateCount]uint64
|
||||
insyscall uint64
|
||||
prunning uint64
|
||||
}
|
||||
@@ -353,12 +344,12 @@ func generateTrace(params *traceParams) (ViewerData, error) {
|
||||
ctx.gstates[gstates[g]]--
|
||||
ctx.gstates[newState]++
|
||||
gstates[g] = newState
|
||||
ctx.emitGoroutineCounters(ev)
|
||||
}
|
||||
for _, ev := range ctx.events {
|
||||
// Handle state transitions before we filter out events.
|
||||
switch ev.Type {
|
||||
case trace.EvGoStart, trace.EvGoStartLabel:
|
||||
setGState(ev, ev.G, gRunnable, gRunning)
|
||||
// Handle trace.EvGoStart separately, because we need the goroutine name
|
||||
// even if ignore the event otherwise.
|
||||
if ev.Type == trace.EvGoStart {
|
||||
if _, ok := gnames[ev.G]; !ok {
|
||||
if len(ev.Stk) > 0 {
|
||||
gnames[ev.G] = fmt.Sprintf("G%v %s", ev.G, ev.Stk[0].Fn)
|
||||
@@ -366,48 +357,6 @@ func generateTrace(params *traceParams) (ViewerData, error) {
|
||||
gnames[ev.G] = fmt.Sprintf("G%v", ev.G)
|
||||
}
|
||||
}
|
||||
case trace.EvProcStart:
|
||||
ctx.threadStats.prunning++
|
||||
case trace.EvProcStop:
|
||||
ctx.threadStats.prunning--
|
||||
case trace.EvGoCreate:
|
||||
ctx.gcount++
|
||||
setGState(ev, ev.Args[0], gDead, gRunnable)
|
||||
case trace.EvGoEnd:
|
||||
ctx.gcount--
|
||||
setGState(ev, ev.G, gRunning, gDead)
|
||||
case trace.EvGoUnblock:
|
||||
setGState(ev, ev.Args[0], gWaiting, gRunnable)
|
||||
case trace.EvGoSysExit:
|
||||
setGState(ev, ev.G, gWaiting, gRunnable)
|
||||
ctx.threadStats.insyscall--
|
||||
case trace.EvGoSysBlock:
|
||||
setGState(ev, ev.G, gRunning, gWaiting)
|
||||
ctx.threadStats.insyscall++
|
||||
case trace.EvGoSched, trace.EvGoPreempt:
|
||||
setGState(ev, ev.G, gRunning, gRunnable)
|
||||
case trace.EvGoStop,
|
||||
trace.EvGoSleep, trace.EvGoBlock, trace.EvGoBlockSend, trace.EvGoBlockRecv,
|
||||
trace.EvGoBlockSelect, trace.EvGoBlockSync, trace.EvGoBlockCond, trace.EvGoBlockNet:
|
||||
setGState(ev, ev.G, gRunning, gWaiting)
|
||||
case trace.EvGoBlockGC:
|
||||
setGState(ev, ev.G, gRunning, gWaitingGC)
|
||||
case trace.EvGoWaiting:
|
||||
setGState(ev, ev.G, gRunnable, gWaiting)
|
||||
case trace.EvGoInSyscall:
|
||||
// Cancel out the effect of EvGoCreate at the beginning.
|
||||
setGState(ev, ev.G, gRunnable, gWaiting)
|
||||
ctx.threadStats.insyscall++
|
||||
case trace.EvHeapAlloc:
|
||||
ctx.heapStats.heapAlloc = ev.Args[0]
|
||||
case trace.EvNextGC:
|
||||
ctx.heapStats.nextGC = ev.Args[0]
|
||||
}
|
||||
if setGStateErr != nil {
|
||||
return ctx.data, setGStateErr
|
||||
}
|
||||
if ctx.gstates[gRunnable] < 0 || ctx.gstates[gRunning] < 0 || ctx.threadStats.insyscall < 0 {
|
||||
return ctx.data, fmt.Errorf("invalid state after processing %v: runnable=%d running=%d insyscall=%d", ev, ctx.gstates[gRunnable], ctx.gstates[gRunning], ctx.threadStats.insyscall)
|
||||
}
|
||||
|
||||
// Ignore events that are from uninteresting goroutines
|
||||
@@ -423,17 +372,20 @@ func generateTrace(params *traceParams) (ViewerData, error) {
|
||||
maxProc = ev.P
|
||||
}
|
||||
|
||||
// Emit trace objects.
|
||||
switch ev.Type {
|
||||
case trace.EvProcStart:
|
||||
if ctx.gtrace {
|
||||
continue
|
||||
}
|
||||
ctx.prunning++
|
||||
ctx.emitThreadCounters(ev)
|
||||
ctx.emitInstant(ev, "proc start")
|
||||
case trace.EvProcStop:
|
||||
if ctx.gtrace {
|
||||
continue
|
||||
}
|
||||
ctx.prunning--
|
||||
ctx.emitThreadCounters(ev)
|
||||
ctx.emitInstant(ev, "proc stop")
|
||||
case trace.EvGCStart:
|
||||
ctx.emitSlice(ev, "GC")
|
||||
@@ -447,23 +399,62 @@ func generateTrace(params *traceParams) (ViewerData, error) {
|
||||
case trace.EvGCSweepStart:
|
||||
ctx.emitSlice(ev, "SWEEP")
|
||||
case trace.EvGCSweepDone:
|
||||
case trace.EvGoStart:
|
||||
ctx.emitSlice(ev, gnames[ev.G])
|
||||
case trace.EvGoStartLabel:
|
||||
ctx.emitSlice(ev, ev.SArgs[0])
|
||||
case trace.EvGoStart, trace.EvGoStartLabel:
|
||||
setGState(ev, ev.G, gRunnable, gRunning)
|
||||
if ev.Type == trace.EvGoStartLabel {
|
||||
ctx.emitSlice(ev, ev.SArgs[0])
|
||||
} else {
|
||||
ctx.emitSlice(ev, gnames[ev.G])
|
||||
}
|
||||
case trace.EvGoCreate:
|
||||
ctx.gcount++
|
||||
setGState(ev, ev.Args[0], gDead, gRunnable)
|
||||
ctx.emitArrow(ev, "go")
|
||||
case trace.EvGoEnd:
|
||||
ctx.gcount--
|
||||
setGState(ev, ev.G, gRunning, gDead)
|
||||
case trace.EvGoUnblock:
|
||||
setGState(ev, ev.Args[0], gWaiting, gRunnable)
|
||||
ctx.emitArrow(ev, "unblock")
|
||||
case trace.EvGoSysCall:
|
||||
ctx.emitInstant(ev, "syscall")
|
||||
case trace.EvGoSysExit:
|
||||
setGState(ev, ev.G, gWaiting, gRunnable)
|
||||
ctx.insyscall--
|
||||
ctx.emitThreadCounters(ev)
|
||||
ctx.emitArrow(ev, "sysexit")
|
||||
case trace.EvGoSysBlock:
|
||||
setGState(ev, ev.G, gRunning, gWaiting)
|
||||
ctx.insyscall++
|
||||
ctx.emitThreadCounters(ev)
|
||||
case trace.EvGoSched, trace.EvGoPreempt:
|
||||
setGState(ev, ev.G, gRunning, gRunnable)
|
||||
case trace.EvGoStop,
|
||||
trace.EvGoSleep, trace.EvGoBlock, trace.EvGoBlockSend, trace.EvGoBlockRecv,
|
||||
trace.EvGoBlockSelect, trace.EvGoBlockSync, trace.EvGoBlockCond, trace.EvGoBlockNet:
|
||||
setGState(ev, ev.G, gRunning, gWaiting)
|
||||
case trace.EvGoBlockGC:
|
||||
setGState(ev, ev.G, gRunning, gWaitingGC)
|
||||
case trace.EvGoWaiting:
|
||||
setGState(ev, ev.G, gRunnable, gWaiting)
|
||||
case trace.EvGoInSyscall:
|
||||
// Cancel out the effect of EvGoCreate at the beginning.
|
||||
setGState(ev, ev.G, gRunnable, gWaiting)
|
||||
ctx.insyscall++
|
||||
ctx.emitThreadCounters(ev)
|
||||
case trace.EvHeapAlloc:
|
||||
ctx.heapAlloc = ev.Args[0]
|
||||
ctx.emitHeapCounters(ev)
|
||||
case trace.EvNextGC:
|
||||
ctx.nextGC = ev.Args[0]
|
||||
ctx.emitHeapCounters(ev)
|
||||
}
|
||||
if setGStateErr != nil {
|
||||
return ctx.data, setGStateErr
|
||||
}
|
||||
if ctx.gstates[gRunnable] < 0 || ctx.gstates[gRunning] < 0 || ctx.insyscall < 0 {
|
||||
return ctx.data, fmt.Errorf("invalid state after processing %v: runnable=%d running=%d insyscall=%d", ev, ctx.gstates[gRunnable], ctx.gstates[gRunning], ctx.insyscall)
|
||||
}
|
||||
// Emit any counter updates.
|
||||
ctx.emitThreadCounters(ev)
|
||||
ctx.emitHeapCounters(ev)
|
||||
ctx.emitGoroutineCounters(ev)
|
||||
}
|
||||
|
||||
ctx.data.footer = len(ctx.data.Events)
|
||||
@@ -544,15 +535,11 @@ func (ctx *traceContext) emitHeapCounters(ev *trace.Event) {
|
||||
if ctx.gtrace {
|
||||
return
|
||||
}
|
||||
if ctx.prevHeapStats == ctx.heapStats {
|
||||
return
|
||||
}
|
||||
diff := uint64(0)
|
||||
if ctx.heapStats.nextGC > ctx.heapStats.heapAlloc {
|
||||
diff = ctx.heapStats.nextGC - ctx.heapStats.heapAlloc
|
||||
if ctx.nextGC > ctx.heapAlloc {
|
||||
diff = ctx.nextGC - ctx.heapAlloc
|
||||
}
|
||||
ctx.emit(&ViewerEvent{Name: "Heap", Phase: "C", Time: ctx.time(ev), Pid: 1, Arg: &heapCountersArg{ctx.heapStats.heapAlloc, diff}})
|
||||
ctx.prevHeapStats = ctx.heapStats
|
||||
ctx.emit(&ViewerEvent{Name: "Heap", Phase: "C", Time: ctx.time(ev), Pid: 1, Arg: &heapCountersArg{ctx.heapAlloc, diff}})
|
||||
}
|
||||
|
||||
type goroutineCountersArg struct {
|
||||
@@ -565,11 +552,7 @@ func (ctx *traceContext) emitGoroutineCounters(ev *trace.Event) {
|
||||
if ctx.gtrace {
|
||||
return
|
||||
}
|
||||
if ctx.prevGstates == ctx.gstates {
|
||||
return
|
||||
}
|
||||
ctx.emit(&ViewerEvent{Name: "Goroutines", Phase: "C", Time: ctx.time(ev), Pid: 1, Arg: &goroutineCountersArg{ctx.gstates[gRunning], ctx.gstates[gRunnable], ctx.gstates[gWaitingGC]}})
|
||||
ctx.prevGstates = ctx.gstates
|
||||
}
|
||||
|
||||
type threadCountersArg struct {
|
||||
@@ -581,11 +564,7 @@ func (ctx *traceContext) emitThreadCounters(ev *trace.Event) {
|
||||
if ctx.gtrace {
|
||||
return
|
||||
}
|
||||
if ctx.prevThreadStats == ctx.threadStats {
|
||||
return
|
||||
}
|
||||
ctx.emit(&ViewerEvent{Name: "Threads", Phase: "C", Time: ctx.time(ev), Pid: 1, Arg: &threadCountersArg{ctx.threadStats.prunning, ctx.threadStats.insyscall}})
|
||||
ctx.prevThreadStats = ctx.threadStats
|
||||
ctx.emit(&ViewerEvent{Name: "Threads", Phase: "C", Time: ctx.time(ev), Pid: 1, Arg: &threadCountersArg{ctx.prunning, ctx.insyscall}})
|
||||
}
|
||||
|
||||
func (ctx *traceContext) emitInstant(ev *trace.Event, name string) {
|
||||
|
||||
@@ -60,42 +60,3 @@ func TestGoroutineCount(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGoroutineFilter(t *testing.T) {
|
||||
// Test that we handle state changes to selected goroutines
|
||||
// caused by events on goroutines that are not selected.
|
||||
|
||||
w := trace.NewWriter()
|
||||
w.Emit(trace.EvBatch, 0, 0) // start of per-P batch event [pid, timestamp]
|
||||
w.Emit(trace.EvFrequency, 1) // [ticks per second]
|
||||
|
||||
// goroutine 10: blocked
|
||||
w.Emit(trace.EvGoCreate, 1, 10, 1, 1) // [timestamp, new goroutine id, new stack id, stack id]
|
||||
w.Emit(trace.EvGoWaiting, 1, 10) // [timestamp, goroutine id]
|
||||
|
||||
// goroutine 20: runnable->running->unblock 10
|
||||
w.Emit(trace.EvGoCreate, 1, 20, 7, 1)
|
||||
w.Emit(trace.EvGoStartLocal, 1, 20) // [timestamp, goroutine id]
|
||||
w.Emit(trace.EvGoUnblockLocal, 1, 10, 8) // [timestamp, goroutine id, stack]
|
||||
w.Emit(trace.EvGoEnd, 1) // [timestamp]
|
||||
|
||||
// goroutine 10: runnable->running->block
|
||||
w.Emit(trace.EvGoStartLocal, 1, 10) // [timestamp, goroutine id]
|
||||
w.Emit(trace.EvGoBlock, 1, 9) // [timestamp, stack]
|
||||
|
||||
events, err := trace.Parse(w, "")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse test trace: %v", err)
|
||||
}
|
||||
|
||||
params := &traceParams{
|
||||
events: events,
|
||||
endTime: int64(1<<63 - 1),
|
||||
gs: map[uint64]bool{10: true},
|
||||
}
|
||||
|
||||
_, err = generateTrace(params)
|
||||
if err != nil {
|
||||
t.Fatalf("generateTrace failed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +265,15 @@ NextLine:
|
||||
}
|
||||
}
|
||||
|
||||
// Temporarily ignore unrecognized printf verbs from cmd.
|
||||
// The compiler now has several fancy verbs (CL 28339)
|
||||
// used with types implementing fmt.Formatters,
|
||||
// and I believe gri has plans to add many more.
|
||||
// TODO: remove when issue 17057 is fixed.
|
||||
if strings.HasPrefix(file, "cmd/") && strings.HasPrefix(msg, "unrecognized printf verb") {
|
||||
continue
|
||||
}
|
||||
|
||||
key := file + ": " + msg
|
||||
if w[key] == 0 {
|
||||
// Vet error with no match in the whitelist. Print it.
|
||||
@@ -312,8 +321,6 @@ var nbits = map[string]int{
|
||||
"amd64p32": 32,
|
||||
"arm": 32,
|
||||
"arm64": 64,
|
||||
"mips": 32,
|
||||
"mipsle": 32,
|
||||
"mips64": 64,
|
||||
"mips64le": 64,
|
||||
"ppc64": 64,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user