How can I specify ports using remote remote import paths?

I have a private (corporate self-service) git repository that listens on a different but default http port. (E.g. 6655)

The full url repository for my golang library would be:

http://internal-git.corporate-domain.com:6655/~myuser/golang-lib.git 

I tried to import it like this:

 package main import ( "encoding/json" "flag" "fmt" "internal-git.corporate-domain.com:6655/~myuser/golang-lib.git" "log" "net/http" "os" "os/signal" "time" ) 

The documentation here and here is not explicit about this.

When I try to compile the code above, I get:

 C:\Users\myuser\gopath\src\myuser\golang-project>go get can't load package: package myuser/golang-project: main.go:7:2: invalid import path: "internal-git.corporate-domain.com:6655/~myuser/golang-lib.git" 
+7
source share
2 answers

As in the previous comment, you probably want to clone the Git repository into the $GOPATH ( %GOPATH% for Windows).

In your example, the clone command would look like this:

 git clone internal-git.corporate-domain.com:6655/~myuser/golang-lib.git $GOPATH/corporate-domain.com/golang-lib 

And your import in Go source files will look like this:

 import "corporate-domain.com/golang-lib" 
+3
source

Another solution is to change your .gitconfig to work with ports.

 [url " git@internal-git.corporate-domain.com :6655"] insteadOf = git://internal-git.corporate-domain.com 
0
source

All Articles