duanbage2161 2017-09-06 22:32
浏览 87

在github仓库的子目录中获取包

If you have a go-only repo (let's say it's https://github.com/foo/bar), you can put your code right at the root level, and have others import using the following command:

go get -u github.com/foo/bar

Directories and subdirectories therein would be recognized as packages.

But suppose you are creating a multi-language repo on github (e.g. one that has java code, go code, javascript code, etc.). And you want to make your go code available for others to use. Usually putting the go code right at the root level would be a no-no from the code organization standpoint. What might be more common may be

(root)
  |-- src
       |-- main
            |-- go
            |-- java
            |-- javascript
            |-- proto

The root level of your go code is now at https://github.com/foo/bar/src/main/go. But you can no longer use the previous go get command as it would look at the top level. You don't really want to use go get -u github.com/foo/bar/src/main/go either as all those would now become part of the package names which is real yucky.

Question is, is there a way to specify an exact URL so that you can separate the package names and the URL? In other words, I'm looking for something like

go get -u github.com/foo/bar https://github.com/foo/bar/src/main/go

(of course the package names should match those that are actually in the source, otherwise it won't compile).

I looked at the go documentation, but it isn't clear to me whether this is doable.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大