Break up go project into subfolders

前端 未结 6 913
傲寒
傲寒 2020-12-30 01:18

I want to break my project up to subfolders.

I want this code structure:

├── main.go
└── models
    └── user.go

Where main.go is:

6条回答
  •  臣服心动
    2020-12-30 01:59

    Breaking up a single project into subfolders is not the recommended way of structuring a go project, which is why there is basically no good way to do what you want.

    If the project is really large, and too unwieldy to make a single package, consider splitting it into several totally distinct packages, rather than special sub-directory packages. This has the advantage of forcing you to think cleanly about your internal APIs.

提交回复
热议问题