我想将 go lang 包安装在单独的文件夹中,而不是使用apt-get install
来安装它。由于很多原因,我不太愿意使用apt-get
,这里就不一一解释了。
我做了以下事情
apt-get download golang-go
然后我像这样解开它
dpkg -x golang-go_2%3a1.6-1ubuntu4_amd64.deb .
我有文件夹usr
,其中包含 3 个文件夹bin
,lib
以及share
其中的逻辑链接。
我下一步该怎么做?
答案1
不好的方法
这是个坏主意。我按照你写的做了提取,但链接断开了,无法启动go
:
$ cd /tmp/
$ apt-get download golang-go
$ dpkg -x golang-go_2%3a1.6-1ubuntu4_amd64.deb go
$ tree go -f | grep bin
├── go/usr/bin
│ ├── go/usr/bin/go -> ../lib/go-1.6/bin/go
│ └── go/usr/bin/gofmt -> ../lib/go-1.6/bin/gofmt
$ ./go/usr/bin/go
bash: ./go/usr/bin/go: No such file or directory
您可以尝试其他更大的套餐 -
$ apt-get download golang-1.6-go
$ dpkg -x golang-1.6-go_1.6.2-0ubuntu5~16.04.4_amd64.deb go
$ tree go -f | grep bin ├── go/usr/bin
│ ├── go/usr/bin/go -> ../lib/go-1.6/bin/go
│ └── go/usr/bin/gofmt -> ../lib/go-1.6/bin/gofmt
│ ├── go/usr/lib/go-1.6/bin
│ │ ├── go/usr/lib/go-1.6/bin/go
│ │ └── go/usr/lib/go-1.6/bin/gofmt
│ │ │ │ ├── go/usr/lib/go-1.6/pkg/linux_amd64/encoding/binary.a
$ go/usr/bin/go version
go version go1.6.2 linux/amd64
这样比较好,但是如果 go 找不到某些库怎么办?
实际上,对于工作golang
安装,您需要更多包 - 请参阅下面的模拟:
$ apt-get install golang --simulate
NOTE: This is only a simulation!
apt-get needs root privileges for real execution.
Keep also in mind that locking is deactivated,
so don't depend on the relevance to the real current situation!
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
golang-1.6 golang-1.6-doc golang-1.6-go golang-1.6-race-detector-runtime golang-1.6-src golang-doc golang-go golang-race-detector-runtime
golang-src
Suggested packages:
bzr git mercurial subversion
The following NEW packages will be installed:
golang golang-1.6 golang-1.6-doc golang-1.6-go golang-1.6-race-detector-runtime golang-1.6-src golang-doc golang-go golang-race-detector-runtime
golang-src
0 upgraded, 10 newly installed, 0 to remove and 12 not upgraded.
好方法
实际上您有以下选择:
创建 debootstrap 或 schroot 或 Docker 容器/目录或类似的东西来隔离 Go 环境。
安装
go
使用 Snap:snap install go16-lbo
并测试一下
snap run go16-lbo help
安装
go1.10
ubuntu-make:sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make sudo apt-get update sudo apt-get install ubuntu-make umake go