脚本描述
脚本依赖环境: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.orggrpc /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.orggenproto /s /e /Q /Y /I
)
if not exist %tempDir%
et (
call git clone https://github.com/golang/net %tempDir%
et
call xcopy %tempDir%
et %workPath%golang.orgx
et /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.orgxsys /s /e /Q /Y /I
)
if not exist %tempDir% ext (
call git clone https://github.com/golang/text.git %tempDir% ext
call xcopy %tempDir% ext %workPath%golang.orgx ext /s /e /Q /Y /I
)