Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Dependency Management with | Go Programming Bootcamp lesson | BraveProgrammer
  1. Courses
  2. /
  3. Go Programming Bootcamp

Lesson 22 of 60

·Go

Dependency Management with Go Modules

15 minutes

Course progress37%

Go Modules Refresher

This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.

A module is a collection of related Go packages versioned together.

Initialising a module

$ mkdir cli && cd cli
$ go mod init github.com/yourname/cli

Adding a dependency

$ go get github.com/spf13/cobra@v1.7.0

The go.mod file now contains:

module github.com/yourname/cli

 

require github.com/spf13/cobra v1
go
1.22
.7
.0

Tidy up

$ go mod tidy   // removes unused deps, adds missing ones

Vendor directory (optional)

$ go mod vendor

Versioning

  • Tag releases with semantic versioning (git tag v1.0.0).
  • go install github.com/yourname/cli@latest fetches the latest version.

Info

Never commit the vendor directory unless you need reproducible builds without internet.
Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from Go Programming BootcampBrowse activities
Previous lessonBuilding a RESTful API – CRUD OperationsContinue to lesson 23Building a CLI with CobraBack to Go Programming Bootcamp curriculum