Details you might NOT know about go.mod & go.sum

It's Go's official tool for package/dependency management.

·

1 min read

Table of contents

No heading

No headings in the article.

image.png

Go Modules came out on version 1.12

It's Go's official tool for package/dependency management.

Go Modules mainly use two files to keep track of the dependencies. go.mod & go.sum

And here's what they do:

image.png

1. go.mod

  • Initializes the project module & records the module path

  • Records the version of Go in use

  • Records the direct dependencies

  • User-defined

image.png

2. go.sum

  • Lists the checksum of direct and indirect dependencies

  • Records the version of said dependencies

  • Auto-generated & un-editable

Small note: checksums are used to confirm that dependencies haven't been modified since last pulled.

Go Modules is one of the most fundamental tools for when programming in Go.

Make great use of it!