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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 有偿求码,CNN+LSTM实现单通道脑电信号EEG的睡眠分期评估
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
    • ¥20 matlab yalmip kkt 双层优化问题
    • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
    • ¥88 实在没有想法,需要个思路