Skip to content
New issue

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

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

Already on GitHub? # to your account

安装脚本优化 #49

Closed
wants to merge 1 commit into from
Closed

安装脚本优化 #49

wants to merge 1 commit into from

Conversation

ercJuL
Copy link

@ercJuL ercJuL commented Jun 10, 2021

运行脚本前设置 G_HOME 可以自定义安装位置
运行脚本前设置 G_MIRROR 可以自定义镜像地址
脚本相关环境变量独立到了 g/g_profile

.g 目录无法被 mac goland 找到,故将~/g 设置为默认目录,同其它相关项 全部移到这个目录
#18 #47

Copy link
Owner

@voidint voidint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

提交前请一定测试下

@@ -25,10 +25,14 @@ function get_os() {

main() {
local release="1.2.0"
local install_dir="${HOME}/g"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g默认的根目录是${HOME}/.g

@@ -25,10 +25,14 @@ function get_os() {

main() {
local release="1.2.0"
local install_dir="${HOME}/g"
if [ -n "$G_HOME" ]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要同时判断G_EXPERIMENTAL和G_HOME这两个环境变量,仅设置G_HOME不会起作用。

local os=$(get_os)
local arch=$(get_arch)
local dest_file="${HOME}/g${release}.${os}-${arch}.tar.gz"
local url="https://github.com/voidint/g/releases/download/v${release}/g${release}.${os}-${arch}.tar.gz"
local url="${GIT_MIRROR}https://github.com/voidint/g/releases/download/v${release}/g${release}.${os}-${arch}.tar.gz"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GIT_MIRROR环境变量?


echo "[3/3] Set environment variables"
echo export G_HOME="${install_dir}" >> ${install_dir}/g_profile
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo输出的内容使用单引号包裹


echo "[3/3] Set environment variables"
echo export G_HOME="${install_dir}" >> ${install_dir}/g_profile
echo export G_EXPERIMENTAL=true >> ${install_dir}/g_profile
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

G_EXPERIMENTAL环境变量不能默认启用。只有当前已经开启的情况下,才能开启。

echo export GOROOT='$G_HOME/go' >> ${install_dir}/g_profile
echo export PATH='$G_HOME:$GOROOT/bin:$PATH' >> ${install_dir}/g_profile
if [ -n "$G_MIRROR" ]; then
export G_MIRROR=${GO_MIRROR} >> ${install_dir}/g_profile
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

未实际写入内容


echo "[3/3] Set environment variables"
echo export G_HOME="${install_dir}" >> ${install_dir}/g_profile
echo export G_EXPERIMENTAL=true >> ${install_dir}/g_profile
echo export GOROOT='$G_HOME/go' >> ${install_dir}/g_profile
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • echo输出内容用双引号包裹
  • GOROOT内容用双引号包裹

@ercJuL ercJuL closed this Jun 30, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants