go to create modular project

For example, I want to create a xxx-system, which may have multiple sub-module, follow these steps:

1.mkdir xxx-system

2.cd xxx-system

3. Create a series of service at xxx-system directories, such as aa-service, bb-service (if a module is a project directly xxx-system as the root directory service can)

, And then into each directory service execution go mod init gitee.com/silentdoer/xxx-system/xx-service(xx-replaceable)

4. The next xx-service go.mod directory will generate a file, the contents of which are :( or bb-service, and so on, each service that ultimately will generate a exe program or become a dependent libraries)

module gitee.com/silentdoer/xxx-system/aa-service

go 1.13

5. In this case can be created within the directory and the xx-service src bin directory (if no dependencies, then there may be no executable files bin directory), and then create the src main.go directory entry for the file, and then in the src create a common directory, create some unique code that belongs to xx-service collection (such as similar in Java utils directories, etc.) under common directory, you can also create directories, etc. as support in the src;

6. After go run main.go go.mod automatically generates dependency records, go 1.13 will increase as the following:require github.com/astaxie/beego v1.11.1

Guess you like

Origin www.cnblogs.com/silentdoer/p/11777418.html