douzhao9608 2015-02-13 22:57
浏览 18
已采纳

有没有一种方法可以在Go项目中使用可重用的导入路径?

I am very new at Go, and need a bit of help with a way to make import pathing more distributable between my team.

Currently at the top of one of my Go files, I have an import, say "github.teamName.com/teamMemberA/HeartThrob/c"

I forked his project to my own name and downloaded it and got some pretty obvious import errors.

MY path to the file it is trying to import is the following: "github.teamName.com/myName/HeartThrob/c"

This pathing change is because I am pulling the project from my own forked repo.

What is a way I can go about fixing this? Is relative pathing possible? I can't put all the Go files into the same directory due to the size of the project and some obvious places for separation.

Disclaimer: New to Go AND Git (My forked approach is team-mandated though)

  • 写回答

1条回答 默认 最新

  • dpnv33177 2015-02-14 00:37
    关注

    Assuming that GOPATH contains a single element, do this:

    $ mkdir -p $GOPATH/github.teamName.com/teamMemberA
    $ cd $GOPATH/github.teamName.com/teamMemberA
    $ git clone github.teamName.com/myName/HeartThrob
    $ cd HeartThrob/c
    $ go install
    

    An alternative approach is:

    $ go get github.teamName.com/teamMemberA/HeartThrob/c
    $ cd $GOPATH/github.teamName.com/teamMemberA/HeartThrob
    $ git remote add fork git@github.myName/HeartThrob.git
    

    Hack a way and push to fork.

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

报告相同问题?

悬赏问题

  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决