通过脚本下载GO被墙或常用的相关包

脚本描述

脚本依赖环境:Windows,GO,GIT
脚本将创建 temp 目录,并拷贝相关包到第一个 GOPATH 中
可将脚本保存到本地自行添加被墙或者常用的包

完整脚本代码

@echo off

setlocal enabledelayedexpansion
set currentPath=%~dp0
set tempDir=%currentPath%temp
set str="%gopath%"
for /f "delims=;, tokens=1,*" %%a in (%str%) do (
    set godir= %%a
)
REM gopath第一个目录
set workPath=!godir!\src
echo GOPATH:%workPath%

if not exist %tempDir% md %tempDir%

if not exist %tempDir%\grpc\  (
    call git clone https://github.com/grpc/grpc-go %tempDir%\grpc
    call xcopy %tempDir%\grpc %workPath%\google.golang.org\grpc /s /e /Q /Y /I
)

if not exist %tempDir%\genproto\  (
    call git clone https://github.com/google/go-genproto.git %tempDir%\genproto
    call xcopy %tempDir%\genproto %workPath%\google.golang.org\genproto /s /e /Q /Y /I
)

if not exist %tempDir%\net  (
    call git clone https://github.com/golang/net %tempDir%\net
    call xcopy %tempDir%\net %workPath%\golang.org\x\net /s /e /Q /Y /I
)
if not exist %tempDir%\sys  (
    call git clone https://github.com/golang/sys %tempDir%\sys
    call xcopy %tempDir%\sys %workPath%\golang.org\x\sys /s /e /Q /Y /I
)

if not exist %tempDir%\text  (
    call git clone https://github.com/golang/text.git %tempDir%\text
    call xcopy %tempDir%\text %workPath%\golang.org\x\text /s /e /Q /Y /I
)

转载于:https://www.cnblogs.com/morang/p/8878771.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值