英文:
How to link GOPATH to LiteIDE?
问题
我已经安装了LiteIde,并在我的.bashrc
中导出了GOROOT
和GOPATH
。当我使用LiteIDE时,自动补全功能正常工作,但无法构建/运行我的代码。当我查看“Manage GOPATH”时,系统GOPATH框为空,并且我也无法在其中输入。
在网上查找,解决方案似乎是“链接”GOPATH
和LiteIDE。如何“链接”这两者呢?
英文:
I've installed LiteIde and exported GOROOT
and GOPATH
in my .bashrc
. When I use LiteIDE, the auto-completion works just fine, but it can't build/run my code. When I look at 'Manage GOPATH', the System GOPATH box is empty, and I can't type into it either.
Looking up online, the solution seems to be - 'link' the GOPATH
and LiteIDE. How do I 'link' the two?
答案1
得分: 20
从下拉菜单中选择适合您系统的正确环境:
例如,如果您使用的是 Mac 并且使用了软件包安装程序,则在 64 位 Mac 上应该选择 "darwin64-local"。
然后点击下拉菜单左侧的 "Go" 文件夹图标。
点击 "Add Directory..." 并添加一个包含 src
、pkg
和 bin
文件夹的文件夹路径。基本上就是您设置的 GOPATH
。
确保您不要在 .bashrc
中设置 GOROOT。您真的不需要设置 GOROOT。
英文:
Select the correct environment for you system from the drop-down:
For example, if you're on a Mac and used the package installer it would be "darwin64-local" on a 64 bit Mac.
Then click on the "Go" folder icon on the left of the drop-down.
Click "Add Directory..." and add a folder path that contains src
, pkg
, and bin
folders. Essentially what you set GOPATH
to.
Make sure you do not set GOROOT in .bashrc
at all. You don't need to set GOROOT, really.
答案2
得分: 4
请按照上面的答案操作,但是关于构建路径不正确的问题:
如果你在Liteide中进行“构建”,那么可执行文件会放在与你的.go文件相同的文件夹中。
但是通过在Liteide中点击“安装”,可执行文件会被放置在go工作区根目录的bin文件夹中,这是正确的位置。
如果在与你的.go文件相同的文件夹中没有可执行文件,你仍然可以在Liteide中“运行”代码。
英文:
Follow the answer above, but then regarding the updated problems with the build path being incorrect:
If you "build" in Liteide then the executable gets put in the same file as your .go file.
But by clicking "install" in Liteide then the executable gets placed in the go workspace root bin folder as it should be.
You can still "run" the code from within Liteide if there is not the executable in the same folder as your .go file.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论