RidgeA
RidgeA

Reputation: 1546

Import path with colons in Golang

I have local private repository (gitlab) with hostname https://git.local.com:1234/

Also I have several packages in my golang project

Project structure looks like:

// my_project/main.go
package main

import (
    "git.local.com:1234/my_project/notMainPackage"
)

func main() {
    //....
}

// my_project/notMainPackage/notMainPackage.go
package notMainPackage

func SomeFunc() {

}

The problem is that I should use colons in my import path to be able run go get and go build comands, but, when import path contains colon, I get error

invalid import path: "git.local.com:1234/my_project/notMainPackage"

I can't change host of gitlab sever.

How can i solve this problem?

Upvotes: 1

Views: 573

Answers (1)

Arun G
Arun G

Reputation: 1688

As the suggestion in comment,

do

git clone git.local.com:1234/my_project/notMainPackage

so the git project loads on to your gopath and

just use it like below,

// my_project/main.go
package main

import (
    "my_project/notMainPackage"
)

func main() {
    //....
}

Hope this helps!!

Upvotes: 2

Related Questions