doujieju0397 2017-10-14 16:02 采纳率: 0%
浏览 77
已采纳

Github项目结构

I'm just writing some project that is separated into 3 parts: API written in Golang, mongoDB and android client. And as above I thought it would be good to create directives. But when it's not good practice for golang github projects: for structure like this:

MyProject
├── API
│   ├── scripts
│   └── src
│       └── some_go_file.go
├── DB
│   ├── db_scripts
│   └── data
└── AndroidDirectory

Any idea how this structure should look like? Should I use separate repos or maybe should I leave each component on separate branch ?

  • 写回答

1条回答 默认 最新

  • dqw70970 2017-10-14 16:08
    关注

    There is no particular layout imposed on Go projects on github, save that it would be nice to make it go gettable by having a main package with some go files at the top level. See the instructions here, but bear in mind it starts by talking about workspaces, not apps if you scroll up.

    https://golang.org/doc/code.html#Command

    To compile and run a simple program, first choose a package path (we'll use github.com/user/hello) and create a corresponding package directory inside your workspace:

    $ mkdir $GOPATH/src/github.com/user/hello Next, create a file named hello.go inside that directory, containing the following Go code.

    So that's the only bit I'd change - put at least one go file at the top level, you can then have your other packages below that in whatever structure you wish (it's fine to use a src dir if you wish for most packages).

    Use a separate repo for the Android project, because it's unlikely to use the same code (presumably it'll use the API over the network, and will not use mongodb for example directly).

    That leaves your api project and mongodb. As the db data and any scripts are likely related to the api server anyway and will evolve with it, I'd put them as a subdirectory of your project as you have shown.

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!