go build不去vendor下查找包

go build 报错:
main.go:5:2: cannot find package “gopkg.in/go-playground/validator.v9” in any of:
/usr/local/go/src/gopkg.in/go-playground/validator.v9 (from $GOROOT)
/root/work/testjdcloud/src/gopkg.in/go-playground/validator.v9 (from $GOPATH)

但是为什么没有去vendor下找呢?

确认了下,是目录结构的问题,可以查找vendor的目录结构是
test|
|src|
| |test|
| | |main.go
| | |vendor
也就是说,需要在src下面再有一层目录

你可能感兴趣的:(go build不去vendor下查找包)