Resolving 'cannot find package' error with vendor in go 1.7

2,131 views
Skip to first unread message

DM

unread,
Jan 11, 2017, 6:16:59 AM1/11/17
to golang-nuts
I have a project structure which looks like below:-

session-service
    _libs  
//Contains all the external dependencies
   
...     // Other packages

Content of _libs looks like below:-


My Makefile looks like below:-

.PHONY: deploy

LOGLEVEL ?= 1
CONFIGFILE ?= 2
GOFLAGS ?= $(GOFLAGS:)

PWD = $(shell pwd)
export GOPATH = $(shell echo $$GOPATH):$(PWD)/_libs:$(PWD)
export GOBIN = $(PWD)/bin
export GOROOT = $(shell echo $$GOROOT)

deploy: clean build install 

build:
    @rm -rf pkg/ 2>/dev/null
    @rm -rf _libs/pkg/ 2>/dev/null
    @go build $(GOFLAGS) ./...

install:
    @go install ./...

clean:
    @go clean $(GOFLAGS) -i ./...


## EOF

Everything is working fine. Now I am thinking of moving to vendor. So I renamed my _libs to vendor and modified my Makefile like below:-

export GOPATH = $(shell echo $$GOPATH):$(PWD)

But after this I started getting the following error:-

vendor/golang.org/x/net/html/charset/charset.go:20:2: cannot find package "golang.org/x/text/encoding" in any of:
    /Users/debraj/golang/src/bitbucket.org/myntra/session-service/vendor/golang.org/x/text/encoding (vendor tree)
    /usr/local/go/src/golang.org/x/text/encoding (from $GOROOT)
    /Users/debraj/golang/src/golang.org/x/text/encoding (from $GOPATH)
    /Users/debraj/golang/src/bitbucket.org/myntra/session-service/src/golang.org/x/text/encoding
vendor/golang.org/x/net/html/charset/charset.go:21:2: cannot find package "golang.org/x/text/encoding/charmap" in any of:
    /Users/debraj/golang/src/bitbucket.org/myntra/session-service/vendor/golang.org/x/text/encoding/charmap (vendor tree)
    /usr/local/go/src/golang.org/x/text/encoding/charmap (from $GOROOT)
    /Users/debraj/golang/src/golang.org/x/text/encoding/charmap (from $GOPATH)
    /Users/debraj/golang/src/bitbucket.org/myntra/session-service/src/golang.org/x/text/encoding/charmap
vendor/golang.org/x/net/html/charset/charset.go:22:2: cannot find package "golang.org/x/text/encoding/htmlindex" in any of:
    /Users/debraj/golang/src/bitbucket.org/myntra/session-service/vendor/golang.org/x/text/encoding/htmlindex (vendor tree)
    /usr/local/go/src/golang.org/x/text/encoding/htmlindex (from $GOROOT)
    /Users/debraj/golang/src/golang.org/x/text/encoding/htmlindex (from $GOPATH)
    /Users/debraj/golang/src/bitbucket.org/myntra/session-service/src/golang.org/x/text/encoding/htmlindex
vendor/golang.org/x/net/html/charset/charset.go:23:2: cannot find package "golang.org/x/text/transform" in any of:
    /Users/debraj/golang/src/bitbucket.org/myntra/session-service/vendor/golang.org/x/text/transform (vendor tree)
    /usr/local/go/src/golang.org/x/text/transform (from $GOROOT)
    /Users/debraj/golang/src/golang.org/x/text/transform (from $GOPATH)
    /Users/debraj/golang/src/bitbucket.org/myntra/session-service/src/golang.org/x/text/transform
vendor/golang.org/x/net/http2/h2i/h2i.go:38:2: cannot find package "golang.org/x/crypto/ssh/terminal" in any of:
    /Users/debraj/golang/src/bitbucket.org/myntra/session-service/vendor/golang.org/x/crypto/ssh/terminal (vendor tree)
    /usr/local/go/src/golang.org/x/crypto/ssh/terminal (from $GOROOT)
    /Users/debraj/golang/src/golang.org/x/crypto/ssh/terminal (from $GOPATH)
    /Users/debraj/golang/src/bitbucket.org/myntra/session-service/src/golang.org/x/crypto/ssh/terminal


Environment:-

  • go version go1.7.3 darwin/amd64
  • Mac OS X 10.11.6
Can someone let me know why I am getting the above errors with vendor but everything works fine with _libs?


Debraj Manna

unread,
Jan 12, 2017, 5:54:20 AM1/12/17
to golang-nuts
This has been discussed further in stackoverflow.

--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/cipdqeorCKc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages