有沒有人知道爲什麼我在導入github.com/juju/errors
時例如在$ GOPATH和$ GOROOT前面獲得_
Golang無法找到/使用供應商文件夾
回購結構
-$GOPATH/src/github.com/codelingo/lexicon/vendor
-$GOPATH/src/github.com/codelingo/lexicon/codelingo/ast/go/src/main.go
-$GOPATH/src/github.com/codelingo/lexicon/codelingo/ast/go/src/node/node.go
main.go行號
1 package main
2
3 import (
4 "encoding/json"
5 "fmt"
6 "os"
7 "strings"
8
9 "github.com/juju/errors"
10
11 "./key"
12 "./node"
13 "./parser"
14 "./property"
15 "./util"
16)
// rest of main.go
node.go行號
1 package node
2
3 import (
4 "encoding/json"
5 "github.com/juju/errors"
6 "reflect"
7)
//rest of node.go
$ go run main.go
node/node.go:5:2: cannot find package "_/home/jzhu/go/src/github.com/codelingo/lexicon/codelingo/ast/go/src/vendor/github.com/juju/errors" in any of:
/usr/local/go/src/_/home/jzhu/go/src/github.com/codelingo/lexicon/codelingo/ast/go/src/vendor/github.com/juju/errors (from $GOROOT)
/home/jzhu/go/src/_/home/jzhu/go/src/github.com/codelingo/lexicon/codelingo/ast/go/src/vendor/github.com/juju/errors (from $GOPATH)
供應商文件夾包含上述包和main.go
可以使用它(例如import ("github.com/juju/errors")
)。
供應商的文件夾下的是我的$ GOPATH(/家/ jzhu/GO)
注:有一個奇怪的 「_」 在包路徑的前面。
我期待着看看供應商樹中的以下內容。
vendor/github.com/codelingo/lingo/service/server/service.go:10:2: cannot find package "github.com/codelingo/platform/controller/graphdb/query/result" in any of:
/home/jzhu/go/src/github.com/codelingo/platform/vendor/github.com/codelingo/platform/controller/graphdb/query/result (vendor tree)
/home/jzhu/go/src/github.com/vendor/github.com/codelingo/platform/controller/graphdb/query/result
/usr/local/go/src/github.com/codelingo/platform/controller/graphdb/query/result (from $GOROOT)
/home/jzhu/go/src/github.com/codelingo/platform/controller/graphdb/query/result (from $GOPATH)
環境:
$go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/jzhu/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build894537960=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
$ go version
go version go1.8.3 linux/amd64
$ glide --version
glide version 0.13.0-dev
請貼節點/ node.go' – ymonad
@ymonad的'5日線是' 「github.com/juju/errors」' – Junyu