I have private bitbucket
repo on http://localhost:7990
ππ» clone link http://localhost:7990/scm/gom/bar.git
go.mod
looks like:
module mod.org/bar
go 1.13
References available in a remote repository:
git ls-remote http://localhost:7990/scm/gom/bar.git
From http://localhost:7990/scm/gom/bar.git
d456de4f12785b26ac27ba08cffb76687d1287c8 HEAD
d456de4f12785b26ac27ba08cffb76687d1287c8 refs/heads/master
f948bd47a22c5fb9abed5bff468a10fc24f67483 refs/tags/v1.0.0
I changed .gitconfig
to
[url "http://localhost:7990/scm/gom"]
insteadOf = https://mod.org
and tried to get module by name
, get no such host
error:
go get -v mod.org/bar
go get lmod.org/bar: unrecognized import path "lmod.org/bar" (https fetch: Get https://lmod.org/bar?go-get=1: dial tcp: lookup lmod.org: no such host)
When I add extension .git
go get -v mod.org/bar.git
go: finding lmod.org/bar.git v1.0.0
go: downloading lmod.org/bar.git v1.0.0
verifying lmod.org/bar.git@v1.0.0: lmod.org/bar.git@v1.0.0: reading https://sum.golang.org/lookup/lmod.org/bar.git@v1.0.0: 410 Gone
go
download version with tag v1.0.0
to GOPATH = /Users/user/go"
:
$GOPATH
βββ go
βββ pkg
βββ mod
βββ cache
βββ download
βββ mod.org
βββ bar.git
βββ @v
βββ v1.0.0.info
βββ v1.0.0.lock
βββ v1.0.0.zip.tmp882433775
, but I still can't use one as dependency in other go-project.
Steps to solve the problem:
1οΈβ£ changed module declaration in go.mod
to
module mod.org/gomod/bar
go 1.16
the same as bitbucket
repositories structure
repo's references to cloning:
http://localhost:7990/scm/gomod/bar.git
ssh://git@mod.org/gomod/bar.git
2οΈβ£ change .gitconfig
: add insteadOf
(ssh
or https
)
# [url "http://localhost:7990/scm"]
[url "ssh://git@mod.org"]
insteadOf = https://mod.org
3οΈβ£ add https://mod.org
to private repository
go env -w GOPRIVATE="mod.org"
βAfter all preparations the module will be accessible to go mod download
from other module by version tags
module mod.org/gomod/foo
go 1.16
require (
mod.org/gomod/bar v1.0.0-beta.1
)
replace (
mod.org/gomod/bar => mod.org/gomod/bar.git v1.0.0-beta.1
)
or manually
go get -u mod.org/gomod/bar.git
go get mod.org/gomod/bar.git@v1.0.0-beta.1