dougao9864 2018-01-28 11:53
浏览 44
已采纳

在Golang中安装库的快捷方式

I'm following the instructions in https://golang.org/doc/code.html#Library and trying to use Goland. I'm surprised though that I can't find a fast way to install the library I'm writing. According to the tutorial, you should use install to install your code in the pkg or bin folders, yet I can't find a way to do this in Goland other than writing it in the console. What am I missing?

  • 写回答

1条回答 默认 最新

  • 普通网友 2018-01-28 12:46
    关注

    There are two ways to import Go packages using GoLand:

    1. copy-paste the code that needs the package into the IDE and then on the import declaration use Show Intention to see the list of actions available and choose the first one, go get -t <package-name>/...
    2. copy the URL of the Github repository into your clipboard, switch to the IDE and use the pop-up to run go get on the package. The pop-up disappears after a few seconds.

    I've attached the image which shows these options. import packages in GoLand

    This will download libraries in the correct GOPATH directory and run go install as part of the go get action.

    As for installing the libraries that you are developing in GOPATH/pkg, there is no need for that, as soon as you run any configuration from the IDE, be it an application or a test that depend on those libraries, the IDE will install those libraries as well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 ue5运行的通道视频都会有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数