The Mattermost server uses go modules to manage dependencies. To manage dependencies you must have modules enabled.
While golang migrates to support go modules, you need to set the environment variable
on if you are developing in the GOPATH. For example:
Once this is done, all go commands issued will use the modules system.
Be sure you have enabled go modules support. Adding a dependency is easy. All you have to do is import the dependency in the code and recompile. The dependency will be automatically added for you. Updating uses the same procedure.
Before committing the code with your new dependency added, be sure to run
go mod tidy to maintain a consistent format and
go mod vendor to synchronize the vendor directory.
If you want to add or update to a specific version of a dependency you can use a command of the form:
go get -u email@example.com go mod tidy go mod vendor
If you just want whatever the latest version is, you can leave off the
To update all dependencies use the make target:
this will run
go get -u and
go mod tidy and
go mod vendor for you. It may also hold back specific dependencies as needed.
Be sure you have enabled go modules support. After removing all references to the dependency in the code, you run:
go mod tidy go mod vendor
to remove it from the
go.mod file and the