這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。
如題,在使用leveldb go wrapper levigo 的時候,本地安裝好levigo後,通過命令列編譯代碼正常並能work,但在Idea中使用時出現:
can't find import "github.com/jmhodges/levigo"
參考 https://github.com/mtoader/google-go-lang-idea-plugin/issues/159
我是這麼解決的:分別建立源碼和.a檔案所在目錄的軟串連:
其中 /home/fun/software/go/go/
fun@fun:~$ echo $GOROOT
/home/fun/software/go/go
軟連結:
/home/fun/software/go/go/pkg/linux_amd64/github.com -> /home/fun/software/go/go/bin/pkg/linux_amd64/github.com/
/home/fun/software/go/go/src/pkg/github.com -> /home/fun/software/go/go/bin/src/github.com/
檔案結構:
tree /home/fun/software/go/go/pkg/linux_amd64/github.com
/home/fun/software/go/go/pkg/linux_amd64/github.com
└── jmhodges
└── levigo.a
tree /home/fun/software/go/go/src/pkg/github.com
/home/fun/software/go/go/src/pkg/github.com
├── jmhodges
│ └── levigo
│ ├── batch.go
│ ├── cache.go
│ ├── comparator.go
│ ├── conv.go
│ ├── db.go
│ ├── doc.go
│ ├── env.go
│ ├── examples
│ │ └── comparator_example.go
│ ├── filterpolicy.go
│ ├── iterator.go
│ ├── leveldb_test.go
│ ├── LICENSE
│ ├── options.go
│ └── README.md
└── nsf
└── gocode
├── autocompletecontext.go
├── autocompletefile.go
..........