Skip to content

Commit c740640

Browse files
committed
chore: update README
1 parent 3322e45 commit c740640

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
if [[ -n $(alias g 2>/dev/null) ]]; then
4040
unalias g
4141
fi
42-
EOF
42+
EOF
4343
$ source "$HOME/.g/env"
4444
```
4545
@@ -59,7 +59,8 @@
5959
#!/bin/sh
6060
# g shell setup
6161
export GOROOT="${HOME}/.g/go"
62-
export PATH="${HOME}/.g/bin:${GOROOT}/bin:$PATH"
62+
[ -z "$GOPATH" ] && export GOPATH="${HOME}/go"
63+
export PATH="${HOME}/.g/bin:${GOROOT}/bin:${GOPATH}/bin:$PATH"
6364
export G_MIRROR=https://golang.google.cn/dl/
6465
EOF
6566
```
@@ -68,10 +69,10 @@
6869
6970
```shell
7071
$ cat >>~/.bashrc <<'EOF'
71-
# g shell setup
72-
if [ -f "${HOME}/.g/env" ]; then
73-
. "${HOME}/.g/env"
72+
if [[ -n $(alias g 2>/dev/null) ]]; then
73+
unalias g
7474
fi
75+
[ -s "${HOME}/.g/env" ] && \. "${HOME}/.g/env" # g shell setup
7576
EOF
7677
```
7778
@@ -109,7 +110,7 @@ To install a specific version of Go (e.g., 1.20.5):
109110
110111
```shell
111112
$ g install 1.14.7
112-
Downloading 100% [===============] (92/92 MB, 12 MB/s)
113+
Downloading 100% [===============] (92/92 MB, 12 MB/s)
113114
Computing checksum with SHA256
114115
Checksums matched
115116
Now using go1.20.5
@@ -131,7 +132,7 @@ $ g ls-remote
131132
1.2.2
132133
1.3
133134
1.3.1
134-
...
135+
...
135136
1.19.10
136137
1.20rc1
137138
1.20rc2
@@ -161,7 +162,7 @@ Uninstalled go1.19.10
161162
To clear the package file cache for Go installations:
162163
163164
```shell
164-
$ g clean
165+
$ g clean
165166
Remove go1.18.10.darwin-arm64.tar.gz
166167
Remove go1.19.10.darwin-arm64.tar.gz
167168
Remove go1.20.5.darwin-arm64.tar.gz
@@ -232,7 +233,7 @@ Remove /Users/voidint/.g
232233
- After installing a go version using g, when running the `go version` command, the output shows a different version than the one installed. Is this a bug?
233234
234235
This is likely due to an incorrect setting of the `PATH` environment variable in the current shell environment (it is recommended to run `which go` to see the path of the go binary file). By default, the path to the go binary file should be `~/.g/go/bin/go`. If it is not this path, it means that the PATH environment variable is set incorrectly.
235-
236+
236237
- Does g support compiling and installing from source code?
237238
238239
No, it does not support compiling and installing from source code.

README_CN.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
if [[ -n $(alias g 2>/dev/null) ]]; then
4040
unalias g
4141
fi
42-
EOF
42+
EOF
4343
$ source "$HOME/.g/env"
4444
```
4545
@@ -59,7 +59,8 @@
5959
#!/bin/sh
6060
# g shell setup
6161
export GOROOT="${HOME}/.g/go"
62-
export PATH="${HOME}/.g/bin:${GOROOT}/bin:$PATH"
62+
[ -z "$GOPATH" ] && export GOPATH="${HOME}/go"
63+
export PATH="${HOME}/.g/bin:${GOROOT}/bin:${GOPATH}/bin:$PATH"
6364
export G_MIRROR=https://golang.google.cn/dl/
6465
EOF
6566
```
@@ -68,10 +69,10 @@
6869
6970
```shell
7071
$ cat >>~/.bashrc <<'EOF'
71-
# g shell setup
72-
if [ -f "${HOME}/.g/env" ]; then
73-
. "${HOME}/.g/env"
72+
if [[ -n $(alias g 2>/dev/null) ]]; then
73+
unalias g
7474
fi
75+
[ -s "${HOME}/.g/env" ] && \. "${HOME}/.g/env" # g shell setup
7576
EOF
7677
```
7778
@@ -109,7 +110,7 @@ $ g ls-remote stable
109110
110111
```shell
111112
$ g install 1.14.7
112-
Downloading 100% [===============] (92/92 MB, 12 MB/s)
113+
Downloading 100% [===============] (92/92 MB, 12 MB/s)
113114
Computing checksum with SHA256
114115
Checksums matched
115116
Now using go1.20.5
@@ -161,7 +162,7 @@ Uninstalled go1.19.10
161162
清空 go 安装包文件缓存
162163
163164
```shell
164-
$ g clean
165+
$ g clean
165166
Remove go1.18.10.darwin-arm64.tar.gz
166167
Remove go1.19.10.darwin-arm64.tar.gz
167168
Remove go1.20.5.darwin-arm64.tar.gz
@@ -232,7 +233,7 @@ Remove /Users/voidint/.g
232233
- 使用 g 安装了某个 go 版本后,执行`go version`命令,但输出的 go 版本号并非是所安装的那个版本,这是不是 bug ?
233234
234235
由于当前 shell 环境中`PATH`环境变量设置有误导致(建议执行`which go`查看二进制文件所在路径)。在未修改 g 家目录的情况下,二进制文件 go 的路径应该是`~/.g/go/bin/go`,如果不是这个路径,就说明`PATH`环境变量设置有误。
235-
236+
236237
- 支持源代码编译安装吗?
237238
238239
不支持

0 commit comments

Comments
 (0)