-
Notifications
You must be signed in to change notification settings - Fork 220
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
安装脚本优化 #49
Conversation
There was a problem hiding this 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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- echo输出内容用双引号包裹
- GOROOT内容用双引号包裹
运行脚本前设置 G_HOME 可以自定义安装位置
运行脚本前设置 G_MIRROR 可以自定义镜像地址
脚本相关环境变量独立到了 g/g_profile
.g 目录无法被 mac goland 找到,故将~/g 设置为默认目录,同其它相关项 全部移到这个目录
#18 #47