doumu5023
2018-05-28 10:02
浏览 144
已采纳

将整个golang包推送到github

I have built a small application locally in golang. My directory structure is as follows.

gocode/
      src/
          github.com/
                    travel/
                          config/
                          server/
                          routes/
                          main.go

      pkg/
          linux/
               github.com/
                    // projects with .a extension 
               golang.org/
                         x/net/
                         x/oauth2
      bin/

I went through a lot of documentations, which states to push only /src folder to github as best practice.

I am confused with what happens with packages like golang.org/x/net which are not inside /src directory.

So we need to run go import "net/http" in production server as well and create executable binaries.

I've come from a nodejs background so is it something like we do "npm install" in nodejs.But the thing is we have a package.json file in case of node. Anyways please help me with this confusion.

图片转代码服务由CSDN问答提供 功能建议

我已经在golang中本地构建了一个小型应用程序。 我的目录结构如下。

  gocode / 
 src / 
 github.com/
 travel / 
 config / 
服务器/ 
路由/ 
 main.go 
 
 pkg / 
 linux  / 
 github.com/
 //具有.a扩展名的项目
 golang.org/
x/net/
x/oauth2
 bin / 
   
 
 <  p>我浏览了许多文档,其中指出最佳做法是仅将/ src文件夹推送到github。 
 
 

我对golang.org/x/之类的软件包的处理方式感到困惑 .net不在/ src目录中。

因此,我们还需要在生产服务器中运行go import“ net / http”并创建可执行二进制文件。

我来自nodejs背景,所以som 就像我们在nodejs中执行“ npm install”一样。但是事情是在node的情况下,我们有一个package.json文件。 无论如何,请帮助我解决这个混乱。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douzhan1031 2018-05-28 10:55
    已采纳

    You would only push the contents of the src/github.com/travel directory. go get handles dependency resolution for you when someone wants to download your package. Take a look at something like logrus. Running go get github.com/sirupsen/logrus will download all dependencies needed to build the package. This includes any of your golang.org/x/ packages.

    打赏 评论

相关推荐 更多相似问题