given I have a private (corporate self-hosted) git repository which listens on on another but the default http-port. (For example 6655)
The full repository-url to my golang-library would be:
http://internal-git.corporate-domain.com:6655/~myuser/golang-lib.git
I tried importing this like so:
package main
import (
"encoding/json"
"flag"
"fmt"
"internal-git.corporate-domain.com:6655/~myuser/golang-lib.git"
"log"
"net/http"
"os"
"os/signal"
"time"
)
Documentation here and here is not explicit about that.
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"
Another solution is to change your .gitconfig to work with ports.
[url "[email protected]:6655"]
insteadOf = git://internal-git.corporate-domain.com
Like a previous comment said you probably want to clone the Git repository into your $GOPATH
(%GOPATH%
for Windows) directory.
Per your example the clone
command would look like:
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 would look like:
import "corporate-domain.com/golang-lib"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With