I have a project that is hosted on source.cloud.google.com. I am hoping to use go get and go modules to manage it. When I do go get, I get the following:
$ go get source.cloud.google.com/<PROJECT-ID>/<REPO>
go get source.cloud.google.com/<PROJECT-ID>/<REPO>: unrecognized import path "source.cloud.google.com/<PROJECT-ID>/<REPO>" (parse https://source.cloud.google.com/<PROJECT-ID>/<REPO>?go-get=1: no go-import meta tags ())
Has anyone got this to work?
Don't forget about the .git in the end
go get source.developers.google.com/p/<PROJECT-ID>/r/<REPO>.git
I got it working with a vanity URL.
vanity.yaml
cat vanity.yaml
paths:
/<REPO>:
repo: https://source.developers.google.com/p/<PROJECT-ID>/r/<REPO>
vcs: git
Related
The steps I took:
1- Configure .gitconfig
[url "ssh://git#bitbucket.org/"]
insteadOf = https://bitbucket.org/
2- export GOPRIVATE=bitbucket.org/myproject/helpers-go
3- go get
my go.mod file ->
module bitbucket.org/myproject/x/test-service
go 1.16
require (
bitbucket.org/myproject/helpers-go v0.0.2
)
replace bitbucket.org/myproject/helpers-go => bitbucket.org/myproject/helpers-go.git v0.0.2
My ssh key works. I can push/pull each services.
I also have the v0.0.2 tag on my last helpers-go commit.
I am trying to import private repo(helpers-go) into (test-service) and the error I get is :
go: bitbucket.org/myproject/helpers-go#v0.0.2: invalid version control suffix in bitbucket.org/ path
Even if I change the v0.0.2 to something random like v0.0.9 which I don`t have a tag like this, I still get the same error.
Appreciate the help...
it is solved:
1- I was using go 1.16 and there was an issue with bitbucket private repos not being supported for this version. I don`t think it has the same issue with gitlab. Upgrading it to go 1.19
2- Small change here .org/ -> .org:
[url "git#bitbucket.org:"]
insteadOf = https://bitbucket.org/
3- Also making sure the private repo I am importing has a file that ends with .go. My .go files were all in other folders leaving main folder without a .go file.
I have a project to do at my job and we're using Bitbucket. So we have all our repos like this :
bitbucket.org/company/project Nothing new here.
I have created a repository called go-tools, his module name is bitbucket.org/company/go-tools and his path his bitbucket.org/company/go-tools
Following this medium post I could achieve a go mod tidy
package whatever
import (
"bitbucket.org/company/go-tools"
"bitbucket.org/company/go-tools/env"
// and so on ...
)
The problem occurs when I try to replace "bitbucket.org/company" by "company.com" because we would like to have our company name instead bitbucket.
So my module name become company.com/go-tools instead of bitbucket.org/company/go-tools
And my imports become :
package whatever
import (
"company.com/go-tools"
"company.com/go-tools/env"
// and so on ...
)
I have set my GOPRIVATE to use bitbucket and configured git to use bitbucket instead of company.com
git config --global url."https://{username}:{app password}#bitbucket.com/company".insteadOf "https://company.com"
go env -w GOPRIVATE=bitbucket.org/company
And from there I only get a 404 error telling me that my package can't be found.
Did anyone have an idea why ? Am I misunderstanding something ?
NOTE : I also read this
Thanks #adrian for your reply this answer my question for at least a part.
I was more looking for a way of just go get 'company.com/whatever' but this is ok.
So if I understand correctly I need to go get bitbucket.org/company/whatever first and then go mod edit -replace bitbucket.org/company/whatever=company.com/whatever
Thanks
My module is gitlab.com/getsote/utilities/slogger
My repository is gitlab.com/getsote/utilities/slogger.git
When I run go get gitlab.com/getsote/utilities/slogger, I get the message below.
Scotts-Mac-mini:seeding syacko$ go get gitlab.com/getsote/utilities/slogger
go get gitlab.com/getsote/utilities/slogger: module gitlab.com/getsote/utilities/slogger: git ls-remote -q origin in /Users/syacko/workspace/sotesoft/golang/pkg/mod/cache/vcs/80b3644beae1b986f1c659355360479e2463820660aa328d2edb1e571aba259b: exit status 128:
remote: The project you were looking for could not be found.
fatal: repository 'https://gitlab.com/getsote/utilities.git/' not found
Scotts-Mac-mini:seeding syacko$
The gitlab.com/getsote/utilities.git is a sub-directory and not a repository. I don't understand why go get is going to the utilities as a repository?
==========================
PREVIOUS Updates
Directory Structure:
GOPATH/src/slogger
|----go.mod
|----slogger.go
|----slogger_test.go
go.mod file
module slogger or gitlab.com/getsote/utilities/slogger -> still gets the error below
go 1.14
gitlab.com/getsote/utilities contains repository slogger.git
I have run a test to see if the issue is the number of nodes in the path. So, I create a new repository with no sub-directory and pushed the slogger code. Then ran go get gitlab.com/getsote/slogger which generate a different error message.
GOPATH/gitlab.com/getsote/test-go-mod -> create new directory and added slogger files listed above
gitblab.com/getsote/test-go-mod -> new repository with one less level
Scotts-Mac-mini:test-go-mod syacko$ go get gitlab.com/getsote/test-go-mod
go: downloading gitlab.com/getsote/test-go-mod v0.0.0-20200409023538-794310bf7cf9
go get gitlab.com/getsote/test-go-mod: gitlab.com/getsote/test-go-mod#v0.0.0-20200409023538-794310bf7cf9: verifying module: gitlab.com/getsote/test-go-mod#v0.0.0-20200409023538-794310bf7cf9: reading https://sum.golang.org/lookup/gitlab.com/getsote/test-go-mod#v0.0.0-20200409023538-794310bf7cf9: 410 Gone
server response:
not found: gitlab.com/getsote/test-go-mod#v0.0.0-20200409023538-794310bf7cf9: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/gopath/pkg/mod/cache/vcs/7753c92c9bd1419156d8120684b7f3707fd207e01a2947ba89e2acfd2ecfb4d0: exit status 128:
fatal: could not read Username for 'https://gitlab.com': terminal prompts disabled
Scotts-Mac-mini:test-go-mod syacko$
This is still getting the status error of 128 for the missing version. Additionally, it is looking in the right location for the code. If this is true, then I just need help with the version missing. Moving to a shorted directory structure is doable.
========================
Newest Update
#praveent > The solution at https://medium.com/cloud-native-the-gathering/go-modules-with-private-git-repositories-dfe795068db4 didn't work for me. So I started from scratch to see how to resolve the issue.
The reason is because for a git repository it assumes that utilities is the repo and not utilities/slogger
There is a way to override this behavior by implementing go get API. But, gitlab is yet to implement the same due to security concerns. You can read more here. Gitlab issue
Update: Add reference to gitlab issue tracking this problem.
So, here is how I got this to work using gitlab.com. I'm not saying other ways will not work, they just didn't for me and my setup. First, since I don't care if the code is available to the public, I created a new group at gitlab.com. This new group is public from the start, so no need to adjust permissions. Then I create a repository called packages and cloned the repository to my local machine with the same directory structure that is in gitlab.com, gitlab.com/soteapps/packages with ~/workspace/soteapps/packages on my machine. Both of these are out side the GOPATH. I'm not sure this matters, but it is working this way, so I'm putting it here.
Under packages, I copied the slogger directory and code.
cp -R slogger ~/workspace/soteapps/packages/.
Edited the go.mod file to match the repository structure, which is in the packages directory. There is no go.mod file in the slogger directory.
module gitlab.com/soteapps/packages
go 1.14
Edited the hello.go import to match the package.
package main
import (
"fmt"
"rsc.io/quote"
"gitlab.com/soteapps/packages/slogger"
)
func main() {
fmt.Println(quote.Hello())
slogger.Info("Test message")
}
Built the program using go build -o hello and then ran it hello with the following results:
Scotts-Mac-mini:hello syacko$ hello
Hello, world.
INFO:2020/04/10 21:11:33 Test message
Scotts-Mac-mini:hello syacko$
Worked! Thank you all that helped. This wouldn't of gotten solved without your help.
Note: This only works for public repositories.
When I run the following:
go get github.com/docker/go-plugins-helpers/volume
It prints:
github.com/docker/go-connections/sockets
../github.com/docker/go-connections/sockets/sockets.go:35:26: dialer.DialContext undefined (type proxy.Dialer has no field or method DialContext)
../github.com/docker/go-connections/sockets/sockets_unix.go:24:28: undefined: context
You are using proxy.Dialer whereas it seems you want net.Dialer, as that one has a DialContext.
For those not familiar with go (like me), a very temporary workaround (until there is a fix for https://github.com/docker/go-connections/issues/60) would be:
cd ~/go/src/github.com/docker/go-connections
git checkout 9885905e989f4d8cc9f42d3549c5be9c27e4460d
go get github.com/docker/go-connections/sockets
cd -
Cheers
Detail:
C:\>go get -u github.com/hidu/proxy-manager
package code.google.com/p/go.net/proxy: Get http://www.google.com/hangouts/: stopped after 10 redirects
package golang.org/x/crypto/blowfish: unrecognized import path "golang.org/x/crypto/blowfish"
package golang.org/x/crypto/cast5: unrecognized import path "golang.org/x/crypto/cast5"
package golang.org/x/crypto/salsa20/salsa: unrecognized import path "golang.org/x/crypto/salsa20/salsa"
I think maybe it because google is forbidden in china?
How to solve this error?
I opened a issue here, solved by the help of repo owner.
The package I try to install is using godep and go vendor.
go vendor need go 1.5 +, and the most important thing is :
export GO15VENDOREXPERIMENT=1
This command make install successful.
Maybe it is also because code.google.com/p/go.net has been archived.
Make sure the project you are using includes a recent fork of that go.net project, like github.com/hashicorp/go.net.
If you cannot change directly github.com/hidu/proxy-manager, you would need to fork it first.
Then change the import in hidu/proxy-manager/manager/client.go#L4
For the "unrecognized import path", see this thread:
One common explanation is that something is blocking access to the golang.org domain.
go get -v golang.org/x/crypto/blowfish should tell you more.
That last part works for me:
C:\Users\vonc\prog>go get -v golang.org/x/crypto/blowfish
Fetching https://golang.org/x/crypto/blowfish?go-get=1
Parsing meta tags from https://golang.org/x/crypto/blowfish?go-get=1 (status code 200)
get "golang.org/x/crypto/blowfish": found meta tag
main.metaImport{Prefix:"golang.org/x/crypto",
VCS:"git",
RepoRoot:"https://go.googlesource.com/crypto"}
at https://golang.org/x/crypto/blowfish?go-get=1
get "golang.org/x/crypto/blowfish": verifying non-authoritative meta tag
Fetching https://golang.org/x/crypto?go-get=1
Parsing meta tags from https://golang.org/x/crypto?go-get=1 (status code 200)
golang.org/x/crypto (download)
golang.org/x/crypto/blowfish
Trying proxy
export GO111MODULE=on
export GOPROXY=https://goproxy.cn