]> Cypherpunks repositories - gostls13.git/commitdiff
std: remove unused bits of code all over the place
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 2 Sep 2019 12:17:23 +0000 (14:17 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 2 Sep 2019 12:57:37 +0000 (12:57 +0000)
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>
src/database/sql/ctxutil.go
src/encoding/json/decode_test.go
src/encoding/xml/marshal_test.go
src/internal/reflectlite/value.go
src/net/http/response_test.go
src/net/http/transport.go
src/os/user/cgo_lookup_unix.go
src/reflect/type.go
src/regexp/backtrack.go

index af2afd5aa5704326d4799f53c33deb9faf003ebb..4dbe6af6d2bee38112ebbf1061903d15998b6d1c 100644 (file)
@@ -94,8 +94,6 @@ func ctxDriverStmtQuery(ctx context.Context, si driver.Stmt, nvdargs []driver.Na
        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) {
        if ciCtx, is := ci.(driver.ConnBeginTx); is {
                dopts := driver.TxOptions{}
index 31ab61c7335e1e7cf4336a33fe0f2955891669a4..72d384a80f9dda12442a234b5b98aefc058892c3 100644 (file)
@@ -1744,41 +1744,6 @@ type NullTest 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.
 // Issue 2540
 func TestUnmarshalNulls(t *testing.T) {
index a0ccf44028b19bda077599fef69ec310fa6659d0..8473158bcd031e06a55ea79ccdf3eedb5b258de4 100644 (file)
@@ -392,7 +392,6 @@ func stringptr(x string) *string {
 
 type T1 struct{}
 type T2 struct{}
-type T3 struct{}
 
 type IndirComment struct {
        T1      T1
index 985087254f0fd4bb3aaf463b8420d8cbc71b390d..308cf98fc80faa420db4361c7fd55e1746c5c419 100644 (file)
@@ -179,19 +179,6 @@ type emptyInterface struct {
        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
 // an unexported field.
 func (f flag) mustBeExported() {
index ee7f0d0b708ffc6233a740b289f15fe4fbeb7a9d..0c78df6f3fdc8eb40127033fc2c8c9c39e8cae0a 100644 (file)
@@ -636,6 +636,11 @@ var readResponseCloseInMiddleTests = []struct {
        {true, true},
 }
 
+type readerAndCloser struct {
+       io.Reader
+       io.Closer
+}
+
 // TestReadResponseCloseInMiddle tests that closing a body after
 // reading only part of its contents advances the read to the end of
 // the request, right up until the next request.
index f5e482d3f7b3d14acfb9d5b98689bbb408e698f8..b23e68f7b3146b199f19a8f72073e0f0e0fd8d35 100644 (file)
@@ -743,7 +743,6 @@ var (
        errCloseIdleConns     = errors.New("http: CloseIdleConnections called")
        errReadLoopExiting    = errors.New("http: persistConn.readLoop exiting")
        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
        // 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
 // tunnel, this function establishes a nested TLS session inside the encrypted channel.
 // The remote endpoint's name may be overridden by TLSClientConfig.ServerName.
@@ -2625,11 +2611,6 @@ func (gz *gzipReader) Close() error {
        return gz.body.Close()
 }
 
-type readerAndCloser struct {
-       io.Reader
-       io.Closer
-}
-
 type tlsHandshakeTimeoutError struct{}
 
 func (tlsHandshakeTimeoutError) Timeout() bool   { return true }
index 856ed28de86041e1e957c5bda1ea99e4763569bd..3307f790eacbbb02e1995da97ae4d33a0eb265f7 100644 (file)
@@ -129,10 +129,6 @@ func buildUser(pwd *C.struct_passwd) *User {
        return u
 }
 
-func currentGroup() (*Group, error) {
-       return lookupUnixGid(syscall.Getgid())
-}
-
 func lookupGroup(groupname string) (*Group, error) {
        var grp C.struct_group
        var result *C.struct_group
index 4afe634bbf9be44c92cadbb6c74a664117a886d5..b3df452ee85e35878bbfd1fb8e7aa62d781a6e16 100644 (file)
@@ -527,11 +527,6 @@ func (n name) pkgPath() string {
        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 {
        if len(n) > 1<<16-1 {
                panic("reflect.nameFrom: name too long: " + n)
@@ -867,10 +862,6 @@ func (t *rtype) PkgPath() string {
        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 {
        return t.tflag&tflagNamed != 0
 }
index 9fb7d1e4937a52f5e617f7c89231132170f9baae..41ae59bcaa2d1f6dd06f1ec033441add260b3352 100644 (file)
@@ -247,7 +247,7 @@ func (re *Regexp) tryBacktrack(b *bitState, i input, pc uint32, pos int) bool {
                                b.cap[inst.Arg] = pos
                                continue
                        } 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.
                                        b.push(re, pc, b.cap[inst.Arg], true) // come back when we're done.
                                        b.cap[inst.Arg] = pos