Home > Article > Backend Development > Best practices for working with two github go projects
php editor Baicao brings you an introduction to the best practices for handling two GitHub Go projects. During the development process, we often need to deal with dependencies and code collaboration between multiple projects. This article will share some effective methods and suggestions to help you optimize the project structure, manage dependencies, resolve conflicts, and improve the maintainability and scalability of the code. Both beginners and experienced developers can benefit from it and improve development efficiency and project quality. Let’s explore these best practices together!
I am developing two golang projects based on github, one of which depends on the other.
Suppose I have project A (github.com/A), which depends on project B (github.com/B). So now I'm making modifications to project B, pushing the code, and executing go get github.com/B
in project A to get the latest code for project B.
This process is very time consuming and doesn't sound right to me. I thought the GO_PATH location of project B's changed files, but it seems the GO_PATH downloaded project is read-only.
Is there a better way to do this?
If your golang version is 1.18, you can take advantage of the workspace feature to improve your development experience.
Let's use your example so we have github.com/A
, which depends on github.com/B
.
workspace
cd
In workspace
, then go mod init ./A && go work use ./B
workspace
go run github.com/A
The result is that in your local development environment you will always use the local version of github.com/B
, so there is no need to synchronize remotely.
If you are using a previous version of go, I think your best option is to write some scripts to automate this process
The above is the detailed content of Best practices for working with two github go projects. For more information, please follow other related articles on the PHP Chinese website!