Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: accepts std/go/token as valid package? #31769

Open
bradfitz opened this issue Apr 30, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@bradfitz
Copy link
Member

commented Apr 30, 2019

goimports inserted a "std/go/token" package for me, which kinda works in some places (go test) but fails in others (trybots of

diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go
index 857f0d5928..e5c9f7e37b 100644
--- a/src/net/http/transport_test.go
+++ b/src/net/http/transport_test.go
@@ -35,6 +35,7 @@ import (
        "os"
        "reflect"
        "runtime"
+       "std/go/token"
        "strconv"
        "strings"
        "sync"
@@ -5220,3 +5221,45 @@ func TestTransportRequestWriteRoundTrip(t *testing.T) {
                })
        }
 }
+
+func TestTransportClone(t *testing.T) {
+       tr := &Transport{
+               Proxy:                  func(*Request) (*url.URL, error) { panic("") },
+               DialContext:            func(ctx context.Context, network, addr string) (net.Conn, error) { panic("") },
+               Dial:                   func(network, addr string) (net.Conn, error) { panic("") },
+               DialTLS:                func(network, addr string) (net.Conn, error) { panic("") },
+               TLSClientConfig:        ne)w(tls.Config),
+               TLSHandshakeTimeout:    time.Second,
+               DisableKeepAlives:      true,
+               DisableCompression:     true,
+               MaxIdleConns:           1,
+               MaxIdleConnsPerHost:    1,
+               MaxConnsPerHost:        1,
+               IdleConnTimeout:        time.Second,
+               ResponseHeaderTimeout:  time.Second,
+               ExpectContinueTimeout:  time.Second,
+               ProxyConnectHeader:     Header{},
+               MaxResponseHeaderBytes: 1,
+               ForceAttemptHTTP2:      true,
+               TLSNextProto:           map[string]func(authority string, c *tls.Conn) RoundTripper{},
+       }
+       tr2 := tr.Clone()
+       rv := reflect.ValueOf(tr2).Elem()
+       rt := rv.Type()
+       for i := 0; i < rt.NumField(); i++ {
+               sf := rt.Field(i)
+               if !token.IsExported(sf.Name) {
+                       continue
+               }
+               if rv.Field(i).IsZero() {
+                       t.Errorf("cloned field t2.%s is zero", sf.Name)
+               }
+       }
+
+       // But test that a nil TLSNextProto is kept nil:
+       tr = new(Transport)
+       tr2 = tr.Clone()
+       if tr2.TLSNextProto != nil {
+               t.Errorf("Transport.TLSNextProto unexpected non-nil")
+       }
+}
bradfitz@go:~/go/src$ cd net/http/
bradfitz@go:~/go/src/net/http$ go test -short
PASS
ok      net/http        4.134s
@dmitshur

This comment was marked as resolved.

Copy link
Member

commented May 5, 2019

a "std/go/token" package [...] kinda works in some places (go test)

Isn't that a bug? I would think the import path std/go/token should not resolve to the go/token package in standard library.

Edit: Never mind, sorry, I see that's exactly what this bug is about. I read only the issue body and missed the title. Issue #31814 primed me to think this was still describing a goimports bug.

@bradfitz

This comment has been minimized.

Copy link
Member Author

commented May 6, 2019

Note that it only works under $GOROOT/src, so it's not a release blocker. It only affects the standard library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.