cheat sheet for go mod package management

tomoyk

Tomoyuki KOYAMA

Posted on October 25, 2024

cheat sheet for go mod package management

This article describes how to use package management commands of go mod.

Project setup

go mod init github.com/YOUR_USER/YOUR_PROJECT
Enter fullscreen mode Exit fullscreen mode

Fixing go.mod

This command provides deletion of unused packages and insertion of required packages from go.mod.

go mod tidy
Enter fullscreen mode Exit fullscreen mode

Install packages which have dependency

This command represents installing packages with dependency resolution.

go get .
Enter fullscreen mode Exit fullscreen mode

Install a package

This command represents labstack/echo installation.

go get github.com/labstack/echo/v4@latest
Enter fullscreen mode Exit fullscreen mode

Update packages

This command is for updating the specific package github.com/labstack/echo/v4.

Only update the package to the latest version:

go get github.com/labstack/echo/v4@latest
Enter fullscreen mode Exit fullscreen mode

Update the package with dependency packages to the latest version:

go get -u github.com/labstack/echo/v4@latest
Enter fullscreen mode Exit fullscreen mode

Reference

💖 💪 🙅 🚩
tomoyk
Tomoyuki KOYAMA

Posted on October 25, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related