Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

go get error - can't load package

I am new to golang and I am trying to get a package but I get a strange error and can't seem to figure out what the problem is?

padlar@padlar:~/workspace-go$ echo $GOPATH
/home/padlar/workspace-go

padlar@padlar:~/workspace-go$ go get golang.org/x/oauth2
padlar@padlar:~/workspace-go$ ls ~/workspace-go/src/golang.org/x/oauth2/
    AUTHORS            google/            jwt_test.go        README.md          
    CONTRIBUTORS       internal/          LICENSE            transport.go       
    example_test.go    jws/               oauth2.go          transport_test.go  
    .git/              jwt.go             oauth2_test.go     .travis.yml        

padlar@padlar:~/workspace-go$ ls ~/workspace-go/pkg/linux_amd64/golang.org/x/oauth2
oauth2/   oauth2.a  
padlar@padlar:~/workspace-go$ ls ~/workspace-go/pkg/linux_amd64/golang.org/x/oauth2/
internal.a  jws.a
padlar@padlar:~/workspace-go$ go get github.com/golang/oauth2
can't load package: package github.com/golang/oauth2: code in directory /home/padlar/workspace-go/src/github.com/golang/oauth2 expects import "golang.org/x/oauth2"
like image 398
padlar Avatar asked Dec 07 '14 15:12

padlar


1 Answers

You are using go get on two different import paths. The new path,

go get golang.org/x/oauth2

and the old path

go get github.com/golang/oauth2

This confuses the Go tool chain. Consistently use the new import path

go get golang.org/x/oauth2
like image 128
peterSO Avatar answered Sep 22 '22 08:09

peterSO