Git&Golang开发环境快速初始化

55 阅读1分钟

SSH

免密拉取Git/GitLab

创建公钥

ssh-keygen -t rsa

image.png

添加公钥

cat /root/.ssh/id_rsa.pub

image.png

Git

git配置

git config --global url."git@x.com:infra/webapp.git".insteadOf "https://x.com/infra/webapp.git"

git config --global url."git@x.com:infra/exporter.git".insteadOf "https://x.com/infra/exporter.git"
git config --global url."git@x.com:infra/inspection.git".insteadOf "https://x.com/infra/inspection.git"
git config --global url."git@x.com:infra/common.git".insteadOf "https://x.com/infra/common.git"
git config --global url."git@x.com:infra/hermes.git".insteadOf "https://x.com/infra/hermes.git" 

image.png

git clone

image.png

git push

git config --global user.name kk
git config --global user.email x@qq.com

Golang

安装golang 1.20以上版本

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B

sudo add-apt-repository ppa:longsleep/golang-backports

sudo apt-get update

sudo apt-get install golang-go

golang私有仓库配置

go env -w GOPRIVATE="x.com/infra/common,x.com/infra/webapp,x.com/infra/inspection,x.com/infra/exporter,x.com/infra/hermes"

image.png

更新私有源依赖

go mod tidy

go get -u x.com/infra/common x.com/infra/exporter x.com/infra/inspection x.com/infra/webapp x.com/infra/hermes