Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
linuxlibs
Golang_multi_version_manager_g
提交
92c44464
G
Golang_multi_version_manager_g
项目概览
linuxlibs
/
Golang_multi_version_manager_g
8 个月 前同步成功
通知
17
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Golang_multi_version_manager_g
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
92c44464
编写于
6月 11, 2023
作者:
A
akayj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enhance: Windows application support not just terminal like powershell or CMD
上级
b8f19564
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
38 addition
and
17 deletion
+38
-17
install.ps1
install.ps1
+38
-17
未找到文件。
install.ps1
浏览文件 @
92c44464
$release
=
"1.5.0"
$os
=
"windows"
$arch
=
"amd64"
$base_dir
=
"
$HOME
/
.g"
$dest_file
=
"
${base_dir}
/downloads/
g
${release}
.
${os}
-
${arch}
.zip"
$url
=
"https://github.com/voidint/g/releases/download/v
${release}
/g
${release}
.
${os}
-
${arch}
.zip"
$release
=
"1.5.0"
$os
=
"windows"
$arch
=
"amd64"
$base_dir
=
"
$HOME
\
.g"
$dest_file
=
"
${base_dir}
\downloads\
g
${release}
.
${os}
-
${arch}
.zip"
$url
=
"https://github.com/voidint/g/releases/download/v
${release}
/g
${release}
.
${os}
-
${arch}
.zip"
function
NewDirs
()
{
New-Item
-
Path
"
$base_dir
/downloads"
,
"
$base_dir
/bin"
-ItemType
"directory"
New-Item
-
Force
-Path
"
$base_dir
/downloads"
,
"
$base_dir
/bin"
-ItemType
"directory"
}
function
CleanDirs
()
{
...
...
@@ -21,24 +21,45 @@ function InstallG () {
Expand-Archive
"
$dest_file
"
"
$base_dir
/bin/"
}
function
SetEnv
()
{
$e1
=
'$env:GOROOT="$HOME\.g\go"'
$e2
=
'$env:Path=-join("$HOME\.g\bin;", "$env:GOROOT\bin;", "$env:Path")'
Out-File
-InputObject
""
-Append
-NoClobber
-FilePath
$PROFILE
Out-File
-InputObject
$e1
-Append
-NoClobber
-FilePath
$PROFILE
Out-File
-InputObject
$e2
-Append
-NoClobber
-FilePath
$PROFILE
function
setHOME
()
{
[
System.Environment
]::
SetEnvironmentVariable
(
"G_HOME"
,
$base_dir
,
[
System.EnvironmentVariableTarget
]::
User
)
[
System.Environment
]::
SetEnvironmentVariable
(
"GOROOT"
,
"
$base_dir
\go"
,
[
System.EnvironmentVariableTarget
]::
User
)
}
function
setPath
()
{
$paths
=
[
System.Environment
]::
GetEnvironmentVariable
(
"PATH"
,
[
System.EnvironmentVariableTarget
]::
User
)
-split
';'
$newPaths
=
@(
"%G_HOME%\bin"
,
"%GOROOT%\bin"
,
"%GOPATH%\bin"
)
foreach
(
$p
in
$newPaths
)
{
if
(
$p
-in
$paths
)
{
Write-Output
"
$p
already exists"
continue
}
[
System.Environment
]::
SetEnvironmentVariable
(
"PATH"
,
[
System.Environment
]::
GetEnvironmentVariable
(
"PATH"
,
[
System.EnvironmentVariableTarget
]::
User
)
+
";
$p
"
,
[
System.EnvironmentVariableTarget
]::
User
)
Write-Host
-ForegroundColor
Green
"
$p
appended"
}
}
function
SetEnv
()
{
setHOME
setPath
}
Write-
Output
"[1/3] Downloading
${url}
"
Write-
Host
-ForegroundColor
Blue
"[1/3] Downloading
${url}
"
NewDirs
DownloadRelease
Write-
Output
"[2/3] Install g to the
${HOME}
/.g/bin"
Write-
Host
-ForegroundColor
Blue
"[2/3] Install g to the
${HOME}
/.g/bin"
InstallG
Write-
Output
"[3/3] Set environment variables"
Write-
Host
-ForegroundColor
Blue
"[3/3] Set environment variables"
SetEnv
Write-Output
"Done!"
\ No newline at end of file
Write-Host
-ForegroundColor
Green
"Done!"
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录