GoLand不会自动导入本地项目包

时间:2019-02-28 19:48:27

标签: go

我不确定是否会出现这种行为,但是在引用时GoLand似乎不会自动导入本地项目包

GoLand对程序包和程序包方法具有智能感知。但是,在为本地软件包添加方法之后,GoLand只是抱怨说它是“未解决的参考”。直到我自己手动导入软件包为止。

我已启用所有导入优化设置。 GoLand自动导入所有github和系统软件包,而不是我的本地项目软件包

有什么方法可以为本地软件包启用自动导入吗?还是我必须自己手动导入它们?

谢谢

enter image description here

Not auto-importing

Manually imported

1 个答案:

答案 0 :(得分:1)

以这种方式使用本地导入不是一个好习惯。而是通过您的GOPATH(即github.com/your_github_username/your_project_dir/utilities)链接到软件包。

假设项目目录:

$GOPATH/
  |
  src/
   |
   github.com/
     |
     your_github_username/
          |
          your_project_dir/
              |utilities
          main.go

项目:github.com/your_github_username/your_project_dir

软件包:github.com/your_github_username/your_project_dir/utilities

按照this标准,您的本地软件包应无问题地导入。

相关问题