dongxing2030 2017-05-24 08:27
浏览 275
已采纳

在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?

  • 写回答

1条回答 默认 最新

  • duanhuo0577 2017-05-24 09:17
    关注

    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!!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?