golang:在本地目录中安装软件包 [英] golang: installing packages in a local directory

查看:201
本文介绍了golang:在本地目录中安装软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在本地目录中安装软件包(包含 go get ... )的最佳实践是什么?

What is the best practice to install packages (those with go get...) in a local directory?

例如:我想尝试 Revel 网页框架,但我不想混淆视线安装在 / usr / local / go

Example: I'd like to try out the Revel web framework, but I don't want to clutter my go installation at /usr/local/go.

通常我会说 sudo go获取github.com/robfig/revel 写在主页上,但是它会将它安装在 / usr / local / go / src / pkg /...

Normally I'd say sudo go get github.com/robfig/revel as written on the home page, but that would install it beneath /usr/local/go/src/pkg/....

有没有简单的方法可以说(例如) go get --local ... 并在当前(子)目录中包?

Is there an easy way to say (for example) go get --local ... and have the package in the current (sub) directory?

推荐答案

您可以导出env变量 GOPATH 。对我来说,它是〜/ local / lib / go 。此文件夹包含子文件夹 bin pkg src ,所以它就像 / usr / local / go 。然后 go -tool会自动下载,编译并安装包到这个目录中。

You can export the env variable GOPATH. For me it is ~/local/lib/go. This folder has the subfolders bin, pkg and src, so it's just like /usr/local/go. The go-tool will then automatically download , build and install packages into this directory.

这篇关于golang:在本地目录中安装软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆