Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【赛风三(Psiphon3) 】Installation of go language on 🚩🇨🇳🏹红旗中科 RedFlag Linux (🍥Debian 11) #4

Closed
englianhu opened this issue Sep 2, 2022 · 4 comments

Comments

@englianhu
Copy link
Contributor

englianhu commented Sep 2, 2022

Remove any previous Go installation by deleting the /usr/local/go folder (if it exists), then extract the archive you just downloaded into /usr/local, creating a fresh Go tree in /usr/local/go:
$ rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.linux-amd64.tar.gz
(You may need to run the command as root or through sudo).

Do not untar the archive into an existing /usr/local/go tree. This is known to produce broken Go installations.

Add /usr/local/go/bin to the PATH environment variable.
You can do this by adding the following line to your $HOME/.profile or /etc/profile (for a system-wide installation):

export PATH=$PATH:/usr/local/go/bin
Note: Changes made to a profile file may not apply until the next time you log into your computer. To apply the changes immediately, just run the shell commands directly or execute them from the profile using a command such as source $HOME/.profile.

Verify that you've installed Go by opening a command prompt and typing the following command:
$ go version
Confirm that the command prints the installed version of Go.

引用:GO: Download and install

## GO语言官网https://go.dev/dl
wget https://go.dev/dl/go1.19.linux-amd64.tar.gz
sudo tar -C /usr/lib -xzf go1.19.linux-amd64.tar.gz
sudo rm -rf go1.19.linux-amd64.tar.gz
sudo chmod 777 -R /usr/lib/go
cd /usr/lib/go/
:~$ export GO=$PATH:/usr/lib/go/bin/
:~$ go version
bash: go:未找到命令
:~$ sudo micro $HOME/.profile

GO

export GO=$PATH:/usr/lib/go/bin/
:~$ go version
bash: go:未找到命令

...
...
...
tar 解压缩命令
tar
-c: 建立压缩档案
-x:解压
-t:查看内容
-r:向压缩归档文件末尾追加文件
-u:更新原压缩包中的文件
这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个。下面的参数是根据需要在压缩或解压档案时可选的。
-z:有gzip属性的
-j:有bz2属性的
-Z:有compress属性的
-v:显示所有过程
-O:将文件解开到标准输出
下面的参数-f是必须的
-f: 使用档案名字,切记,这个参数是最后一个参数,后面只能接档案名。

...
...
...

总结

1、.tar 用 tar –xvf 解压
2、
.gz 用 gzip -d或者gunzip 解压
3、.tar.gz和.tgz 用 tar –xzf 解压
4、.bz2 用 bzip2 -d或者用bunzip2 解压
5、
.tar.bz2用tar –xjf 解压
6、.Z 用 uncompress 解压
7、
.tar.Z 用tar –xZf 解压
8、.rar 用 unrar e解压
9、
.zip 用 unzip 解压

引用:Linux下tar命令解压到指定的目录

https://go.dev/doc/install

@englianhu
Copy link
Contributor Author

englianhu commented Sep 3, 2022

go

## 方案 01
echo "export PATH=/usr/lib/go/bin:${PATH}" | sudo tee /etc/profile.d/go.sh
source /etc/profile.d/go.sh
go version

## 方案 02
echo "export PATH=/usr/lib/go/bin:${PATH}" | sudo tee -a $HOME/.profile source
source $HOME/.profile
go version

参考文献:How to Install Go (Golang) Compiler on Debian 11

@englianhu
Copy link
Contributor Author

:~$ cd /home/englianhu/文档/GitHub/update-golang/
:~/文档/GitHub/update-golang$ sudo ./update-golang.sh
update-golang.sh: version 0.26
update-golang.sh: find_latest: found last release: 1.19
update-golang.sh: user: uid=0(root) gid=0(root) 组=0(root)
update-golang.sh: 
update-golang.sh: RELEASE_LIST=https://go.dev/dl/
update-golang.sh: SOURCE=https://storage.googleapis.com/golang
update-golang.sh: DESTINATION=/usr/local
update-golang.sh: RELEASE=1.19
update-golang.sh: OS=linux
update-golang.sh: ARCH_PROBE=uname -m
update-golang.sh: ARCH=amd64
update-golang.sh: PROFILED=/etc/profile.d/golang_path.sh
update-golang.sh: CACHE=/usr/local
update-golang.sh: GOPATH=
update-golang.sh: DEBUG=
update-golang.sh: FORCE_IPV4=           ;# set FORCE_IPV4=-4 to force IPv4
update-golang.sh: CONNECT_TIMEOUT=5
update-golang.sh: SKIP_WGET=             ;# set SKIP_WGET=1 to skip wget
update-golang.sh: 
update-golang.sh: 
update-golang.sh: WARNING
update-golang.sh: WARNING: golang-go is installed, you should remove it: sudo apt remove golang-go
update-golang.sh: WARNING
update-golang.sh: 
update-golang.sh: will install golang go1.19.linux-amd64 as: /usr/local/go
update-golang.sh: https://storage.googleapis.com/golang/go1.19.linux-amd64.tar.gz is remote
update-golang.sh: download: wget --connect-timeout 5  -O /usr/local/go1.19.linux-amd64.tar.gz https://storage.googleapis.com/golang/go1.19.linux-amd64.tar.gz
--2022-09-04 00:30:08--  https://storage.googleapis.com/golang/go1.19.linux-amd64.tar.gz
正在解析主机 storage.googleapis.com (storage.googleapis.com)... 2a00:1450:400c:c08::80, 2a00:1450:400c:c1b::80, 2a00:1450:400c:c06::80, ...
正在连接 storage.googleapis.com (storage.googleapis.com)|2a00:1450:400c:c08::80|:443... 失败:连接超时。
正在连接 storage.googleapis.com (storage.googleapis.com)|2a00:1450:400c:c1b::80|:443... 失败:连接超时。
正在连接 storage.googleapis.com (storage.googleapis.com)|2a00:1450:400c:c06::80|:443... 失败:连接超时。
正在连接 storage.googleapis.com (storage.googleapis.com)|2a00:1450:400c:c07::80|:443... 失败:连接超时。
正在连接 storage.googleapis.com (storage.googleapis.com)|66.102.1.128|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:148796421 (142M) [application/x-gzip]
正在保存至:/usr/local/go1.19.linux-amd64.tar.gz/usr/local/go1.19. 100%[==============>] 141.90M  8.14MB/s  用时 20s     

2022-09-04 00:30:50 (7.26 MB/s) - 已保存 “/usr/local/go1.19.linux-amd64.tar.gz” [148796421/148796421])

update-golang.sh: remove_old_link: found symlink for old install: /usr/local/go1.19.linux-amd64
update-golang.sh: untar: rm_dir /usr/local/go1.19.linux-amd64
update-golang.sh: untar: tar -x -f /usr/local/go1.19.linux-amd64.tar.gz
update-golang.sh: profile_path_add: issuing new /usr/local/go/bin to /etc/profile.d/golang_path.sh
update-golang.sh: profile_path_add: issuing $HOME/go/bin to /etc/profile.d/golang_path.sh
update-golang.sh: golang go1.19.linux-amd64 installed at: /usr/local/go
update-golang.sh: testing: /usr/local/go/bin/go version
update-golang.sh: unsudo: running_as_root:englianhu: /usr/local/go/bin/go version
update-golang.sh: go version go1.19 linux/amd64
update-golang.sh: /usr/local/go/bin/go version: SUCCESS
update-golang.sh: unsudo: running_as_root:englianhu: mktemp -t hello-tmpXXXXXXXX
update-golang.sh: unsudo: running_as_root:englianhu: tee /tmp/hello-tmpTk0OuoZl.go
update-golang.sh: testing: /usr/local/go/bin/go run /tmp/hello-tmpTk0OuoZl.go
update-golang.sh: unsudo: running_as_root:englianhu: /usr/local/go/bin/go run /tmp/hello-tmpTk0OuoZl.go
update-golang.sh: hello, world - go1.19
update-golang.sh: /usr/local/go/bin/go run /tmp/hello-tmpTk0OuoZl.go: SUCCESS
update-golang.sh: running_as_root: yes
update-golang.sh: recursively forcing build cache [/home/englianhu/.cache/go-build] ownership to 1000:1001
update-golang.sh: 
update-golang.sh: HINT: If this is the first time you run this script, the env vars
update-golang.sh:       updated in the profile will only take effect for new shells.
update-golang.sh:       If you want them to affect the current shell, use this:
update-golang.sh: 
update-golang.sh:       source /etc/profile.d/golang_path.sh
update-golang.sh:

englianhu added a commit to englianhu/update-golang that referenced this issue Sep 4, 2022
更新赛风3,go编程语言
scibrokes/setup-centOS7-DO#4
@englianhu englianhu changed the title 赛风三(Psiphon3) 【赛风三(Psiphon3) 】Installation of go language on 🚩🇨🇳🏹红旗中科 RedFlag Linux (🍥Debian 11) Sep 4, 2022
@englianhu
Copy link
Contributor Author

englianhu commented Sep 4, 2022

...
...
update-golang.sh: HINT: If this is the first time you run this script, the env vars
update-golang.sh:       updated in the profile will only take effect for new shells.
update-golang.sh:       If you want them to affect the current shell, use this:
update-golang.sh: 
update-golang.sh:       source /etc/profile.d/golang_path.sh
update-golang.sh:

Originally posted by @englianhu in #4 (comment)

$ source /etc/profile.d/golang_path.sh

复制并更新至 https://github.com/englianhu/update-golang 猫城仓库~

@englianhu
Copy link
Contributor Author

englianhu commented Sep 22, 2022

## 移除红旗礼逆袭自带go语言版本
sudo rm -rf /usr/lib/go-1.11/

## GO语言官网https://go.dev/dl
wget https://dl.google.com/go/go1.20.linux-amd64.tar.gz
sudo tar -C /usr/lib -xzf go1.20.linux-amd64.tar.gz
sudo rm -rf go1.20.linux-amd64.tar.gz
sudo chmod 777 -R /usr/lib/go
cd /usr/lib/go/

## 方案 01
echo "export PATH=/usr/lib/go/bin:${PATH}" | sudo tee /etc/profile.d/go.sh
source /etc/profile.d/go.sh
go version

## 方案 02
echo "export PATH=/usr/lib/go/bin:${PATH}" | sudo tee -a $HOME/.profile source
source $HOME/.profile
go version
$ go version
go version go1.20 linux/amd64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant