Below you will find pages that utilize the taxonomy term “Productivity”
February 10, 2024
Experience with Go workspace
Introduction
Go 1.18 added the workspace mode to Go, allowing you to work on multiple modules simultaneously without having to edit the go.mod file.
Module is a folder having go.mod
file
Earlier if you are working with multiple modules the flow would look like below
- Make the change in module1.
- Update the go.mod file of module2 with
replace
directive for your local, unpublished changes. - Make the changes in module2.
- Before pushing to remote remember to remove the
replace
from thego.mod
.
What workspace allows you to do is allow you to access the changes from module1 in module2 without updating the go.mod
files.
Thus allowing developers to fully focus on writing code, only when you are going to complete your local development flow and are going to push to remote, we need to update the version tag of module1 in module2’s go.mod file.