Idea golang "can’t find import" 解決方法

如題,在使用leveldb go wrapper levigo 的時候,本地安裝好levigo後,經過命令行編譯代碼正常並能work,但在Idea中使用時出現:html

can't find import "github.com/jmhodges/levigo"

參考 https://github.com/mtoader/google-go-lang-idea-plugin/issues/159linux

我是這麼解決的:分別建立源碼和.a文件所在目錄的軟鏈接:git

其中 /home/fun/software/go/go/github

fun@fun:~$ echo $GOROOT
/home/fun/software/go/goapp

 

軟連接:ide

  /home/fun/software/go/go/pkg/linux_amd64/github.com -> /home/fun/software/go/go/bin/pkg/linux_amd64/github.com/ google

/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.aidea

 

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命令行

..........code

相關文章
相關標籤/搜索