Skip to content

golang超实用技巧

拉取私有库

比如我私有库为 github.com/gofulljs/private

1.配置ssh密钥用以拉取代码

ssh -T git@github.com
Hi gofulljs! You've successfully authenticated, but GitHub does not provide shell access.

2.配置https替换为ssh

git config --global url."git@github.com:gofulljs".insteadOf "https://github.com/gofulljs"

这样针对自己写的库都会走ssh,不会弹出

 fatal: could not read Username for 'https://github.com': terminal prompts disabled
  1. 配置自己库路径为私有,这样避免校验
go env -w GOPRIVATE=github.com/gofulljs
  1. 享受成果
go get github.com/gofulljs/private@latest

可自行打 tag 来实用自己项目了,非常happy

Comments