This is a creation in Article, where the information may have evolved or changed.
What do we got?
Gitlib has released 6.0, claiming to be an enterprise-class version, as the first choice for private git libraries, more and more people use
Suppose there is such a Golang library, the URL is http://git.wendal.net/wendal/gofly
If you try to execute the following statement to get the library,
go get git.wendal.net/wendal/gofly#会输出package git.wendal.net/wendal/gofly: unrecognized import path "git.wendal.net/wendal/gofly"
However, if we enter
go get git.wendal.net/wendal/gofly.git#会输出fatal: repository 'git.wendal.net/wendal/gofly' does not existpackage git.wendal.net/wendal/gofly.git: exit status 128
Why? Seemingly go get does not support custom library addresses AH (git)
And look at the code inside $GOROOT/src/cmd/go/vcs.go.
// General syntax for any server. { re: `^(?P
(?P
([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?/[A-Za-z0-9_.\-/]*?)\.(?P
bzr|git|hg|svn))(/[A-Za-z0-9_.\-]+)*$`, ping: true, },
As you can see, for unknown library addresses (not Github/google code/bitbucket/launchpad), they are set in the configuration here
According to the regular expression above, the input git.wendal.net/wendal/gofly can be obtained
root = git.wendal.net/wendal/goflyrepo = git.wendal.net/wendal/goflyvcs = git
What? When you use Git for clone, you actually execute the
git clone $repo $GOPATH/src/$root#展开之后(假设GOPATH=/opt/gopath)git clone git.wendal.net/wendal/gofly /opt/gopath/src/git.wendal.net/wendal/gofly
The Git repository address is a local path, so it's not a mistake.
How to solve it? Add a custom library address similar to GitHub
First, copy a github configuration
// Github { prefix: "github.com/", re: `^(?P
github\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[A-Za-z0-9_.\-]+)*$`, vcs: "git", repo: "https://{root}", check: noVCSSuffix, },
Change into
// git.xwoods.org { prefix: "git.wendal.net/", re: `^(?P
git\.wendal\.net/(?P
.[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*))$`, ping: false, repo: "git@git.wendal.net:{p}.git", vcs : "git", },
Note that re and repo, do a special deal with Oh, more than a P variable, so that repo will be the standard SSH git address, automatically use the key (haha, private library)
Finally, we need to compile the Golang
# linux/mac 下$GOROOT/src/make.bash#windows下cd %GOROOT%\src\cmd\gogo install