DEV Community

Tomoyuki KOYAMA
Tomoyuki KOYAMA

Posted on

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

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

đź‘‹ Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay