mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
std: remove unused bits of code all over the place
Some were never used, and some haven't been used for years. One exception is net/http's readerAndCloser, which was only used in a test. Move it to a test file. While at it, remove a check in regexp that could never fire; the field is an uint32, so it can never be negative. Change-Id: Ia2200f6afa106bae4034045ea8233b452f38747b Reviewed-on: https://go-review.googlesource.com/c/go/+/192621 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
d5fe73393c
commit
03ac39ce5e
9 changed files with 6 additions and 84 deletions
|
|
@ -94,8 +94,6 @@ func ctxDriverStmtQuery(ctx context.Context, si driver.Stmt, nvdargs []driver.Na
|
||||||
return si.Query(dargs)
|
return si.Query(dargs)
|
||||||
}
|
}
|
||||||
|
|
||||||
var errLevelNotSupported = errors.New("sql: selected isolation level is not supported")
|
|
||||||
|
|
||||||
func ctxDriverBegin(ctx context.Context, opts *TxOptions, ci driver.Conn) (driver.Tx, error) {
|
func ctxDriverBegin(ctx context.Context, opts *TxOptions, ci driver.Conn) (driver.Tx, error) {
|
||||||
if ciCtx, is := ci.(driver.ConnBeginTx); is {
|
if ciCtx, is := ci.(driver.ConnBeginTx); is {
|
||||||
dopts := driver.TxOptions{}
|
dopts := driver.TxOptions{}
|
||||||
|
|
|
||||||
|
|
@ -1744,41 +1744,6 @@ type NullTest struct {
|
||||||
Struct struct{}
|
Struct struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type NullTestStrings struct {
|
|
||||||
Bool bool `json:",string"`
|
|
||||||
Int int `json:",string"`
|
|
||||||
Int8 int8 `json:",string"`
|
|
||||||
Int16 int16 `json:",string"`
|
|
||||||
Int32 int32 `json:",string"`
|
|
||||||
Int64 int64 `json:",string"`
|
|
||||||
Uint uint `json:",string"`
|
|
||||||
Uint8 uint8 `json:",string"`
|
|
||||||
Uint16 uint16 `json:",string"`
|
|
||||||
Uint32 uint32 `json:",string"`
|
|
||||||
Uint64 uint64 `json:",string"`
|
|
||||||
Float32 float32 `json:",string"`
|
|
||||||
Float64 float64 `json:",string"`
|
|
||||||
String string `json:",string"`
|
|
||||||
PBool *bool `json:",string"`
|
|
||||||
Map map[string]string `json:",string"`
|
|
||||||
Slice []string `json:",string"`
|
|
||||||
Interface interface{} `json:",string"`
|
|
||||||
|
|
||||||
PRaw *RawMessage `json:",string"`
|
|
||||||
PTime *time.Time `json:",string"`
|
|
||||||
PBigInt *big.Int `json:",string"`
|
|
||||||
PText *MustNotUnmarshalText `json:",string"`
|
|
||||||
PBuffer *bytes.Buffer `json:",string"`
|
|
||||||
PStruct *struct{} `json:",string"`
|
|
||||||
|
|
||||||
Raw RawMessage `json:",string"`
|
|
||||||
Time time.Time `json:",string"`
|
|
||||||
BigInt big.Int `json:",string"`
|
|
||||||
Text MustNotUnmarshalText `json:",string"`
|
|
||||||
Buffer bytes.Buffer `json:",string"`
|
|
||||||
Struct struct{} `json:",string"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// JSON null values should be ignored for primitives and string values instead of resulting in an error.
|
// JSON null values should be ignored for primitives and string values instead of resulting in an error.
|
||||||
// Issue 2540
|
// Issue 2540
|
||||||
func TestUnmarshalNulls(t *testing.T) {
|
func TestUnmarshalNulls(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,6 @@ func stringptr(x string) *string {
|
||||||
|
|
||||||
type T1 struct{}
|
type T1 struct{}
|
||||||
type T2 struct{}
|
type T2 struct{}
|
||||||
type T3 struct{}
|
|
||||||
|
|
||||||
type IndirComment struct {
|
type IndirComment struct {
|
||||||
T1 T1
|
T1 T1
|
||||||
|
|
|
||||||
|
|
@ -179,19 +179,6 @@ type emptyInterface struct {
|
||||||
word unsafe.Pointer
|
word unsafe.Pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
// nonEmptyInterface is the header for an interface value with methods.
|
|
||||||
type nonEmptyInterface struct {
|
|
||||||
// see ../runtime/iface.go:/Itab
|
|
||||||
itab *struct {
|
|
||||||
ityp *rtype // static interface type
|
|
||||||
typ *rtype // dynamic concrete type
|
|
||||||
hash uint32 // copy of typ.hash
|
|
||||||
_ [4]byte
|
|
||||||
fun [100000]unsafe.Pointer // method table
|
|
||||||
}
|
|
||||||
word unsafe.Pointer
|
|
||||||
}
|
|
||||||
|
|
||||||
// mustBeExported panics if f records that the value was obtained using
|
// mustBeExported panics if f records that the value was obtained using
|
||||||
// an unexported field.
|
// an unexported field.
|
||||||
func (f flag) mustBeExported() {
|
func (f flag) mustBeExported() {
|
||||||
|
|
|
||||||
|
|
@ -636,6 +636,11 @@ var readResponseCloseInMiddleTests = []struct {
|
||||||
{true, true},
|
{true, true},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type readerAndCloser struct {
|
||||||
|
io.Reader
|
||||||
|
io.Closer
|
||||||
|
}
|
||||||
|
|
||||||
// TestReadResponseCloseInMiddle tests that closing a body after
|
// TestReadResponseCloseInMiddle tests that closing a body after
|
||||||
// reading only part of its contents advances the read to the end of
|
// reading only part of its contents advances the read to the end of
|
||||||
// the request, right up until the next request.
|
// the request, right up until the next request.
|
||||||
|
|
|
||||||
|
|
@ -743,7 +743,6 @@ var (
|
||||||
errCloseIdleConns = errors.New("http: CloseIdleConnections called")
|
errCloseIdleConns = errors.New("http: CloseIdleConnections called")
|
||||||
errReadLoopExiting = errors.New("http: persistConn.readLoop exiting")
|
errReadLoopExiting = errors.New("http: persistConn.readLoop exiting")
|
||||||
errIdleConnTimeout = errors.New("http: idle connection timeout")
|
errIdleConnTimeout = errors.New("http: idle connection timeout")
|
||||||
errNotCachingH2Conn = errors.New("http: not caching alternate protocol's connections")
|
|
||||||
|
|
||||||
// errServerClosedIdle is not seen by users for idempotent requests, but may be
|
// errServerClosedIdle is not seen by users for idempotent requests, but may be
|
||||||
// seen by a user if the server shuts down an idle connection and sends its FIN
|
// seen by a user if the server shuts down an idle connection and sends its FIN
|
||||||
|
|
@ -1350,19 +1349,6 @@ func (t *Transport) decConnsPerHost(key connectMethodKey) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The connect method and the transport can both specify a TLS
|
|
||||||
// Host name. The transport's name takes precedence if present.
|
|
||||||
func chooseTLSHost(cm connectMethod, t *Transport) string {
|
|
||||||
tlsHost := ""
|
|
||||||
if t.TLSClientConfig != nil {
|
|
||||||
tlsHost = t.TLSClientConfig.ServerName
|
|
||||||
}
|
|
||||||
if tlsHost == "" {
|
|
||||||
tlsHost = cm.tlsHost()
|
|
||||||
}
|
|
||||||
return tlsHost
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add TLS to a persistent connection, i.e. negotiate a TLS session. If pconn is already a TLS
|
// Add TLS to a persistent connection, i.e. negotiate a TLS session. If pconn is already a TLS
|
||||||
// tunnel, this function establishes a nested TLS session inside the encrypted channel.
|
// tunnel, this function establishes a nested TLS session inside the encrypted channel.
|
||||||
// The remote endpoint's name may be overridden by TLSClientConfig.ServerName.
|
// The remote endpoint's name may be overridden by TLSClientConfig.ServerName.
|
||||||
|
|
@ -2625,11 +2611,6 @@ func (gz *gzipReader) Close() error {
|
||||||
return gz.body.Close()
|
return gz.body.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
type readerAndCloser struct {
|
|
||||||
io.Reader
|
|
||||||
io.Closer
|
|
||||||
}
|
|
||||||
|
|
||||||
type tlsHandshakeTimeoutError struct{}
|
type tlsHandshakeTimeoutError struct{}
|
||||||
|
|
||||||
func (tlsHandshakeTimeoutError) Timeout() bool { return true }
|
func (tlsHandshakeTimeoutError) Timeout() bool { return true }
|
||||||
|
|
|
||||||
|
|
@ -129,10 +129,6 @@ func buildUser(pwd *C.struct_passwd) *User {
|
||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
func currentGroup() (*Group, error) {
|
|
||||||
return lookupUnixGid(syscall.Getgid())
|
|
||||||
}
|
|
||||||
|
|
||||||
func lookupGroup(groupname string) (*Group, error) {
|
func lookupGroup(groupname string) (*Group, error) {
|
||||||
var grp C.struct_group
|
var grp C.struct_group
|
||||||
var result *C.struct_group
|
var result *C.struct_group
|
||||||
|
|
|
||||||
|
|
@ -527,11 +527,6 @@ func (n name) pkgPath() string {
|
||||||
return pkgPathName.name()
|
return pkgPathName.name()
|
||||||
}
|
}
|
||||||
|
|
||||||
// round n up to a multiple of a. a must be a power of 2.
|
|
||||||
func round(n, a uintptr) uintptr {
|
|
||||||
return (n + a - 1) &^ (a - 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func newName(n, tag string, exported bool) name {
|
func newName(n, tag string, exported bool) name {
|
||||||
if len(n) > 1<<16-1 {
|
if len(n) > 1<<16-1 {
|
||||||
panic("reflect.nameFrom: name too long: " + n)
|
panic("reflect.nameFrom: name too long: " + n)
|
||||||
|
|
@ -867,10 +862,6 @@ func (t *rtype) PkgPath() string {
|
||||||
return t.nameOff(ut.pkgPath).name()
|
return t.nameOff(ut.pkgPath).name()
|
||||||
}
|
}
|
||||||
|
|
||||||
func hasPrefix(s, prefix string) bool {
|
|
||||||
return len(s) >= len(prefix) && s[:len(prefix)] == prefix
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *rtype) hasName() bool {
|
func (t *rtype) hasName() bool {
|
||||||
return t.tflag&tflagNamed != 0
|
return t.tflag&tflagNamed != 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,7 @@ func (re *Regexp) tryBacktrack(b *bitState, i input, pc uint32, pos int) bool {
|
||||||
b.cap[inst.Arg] = pos
|
b.cap[inst.Arg] = pos
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
if 0 <= inst.Arg && inst.Arg < uint32(len(b.cap)) {
|
if inst.Arg < uint32(len(b.cap)) {
|
||||||
// Capture pos to register, but save old value.
|
// Capture pos to register, but save old value.
|
||||||
b.push(re, pc, b.cap[inst.Arg], true) // come back when we're done.
|
b.push(re, pc, b.cap[inst.Arg], true) // come back when we're done.
|
||||||
b.cap[inst.Arg] = pos
|
b.cap[inst.Arg] = pos
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue