Go mod

From NovaOrdis Knowledge Base
Revision as of 21:56, 2 October 2023 by Ovidiu (talk | contribs) (→‎Overview)
Jump to navigation Jump to search

Internal

Overview

go.mod

init

Initialize a v0 or v1 module:

go mod init example.com/m

Initialize a v2 module:

go mod init example.com/m/v2

tidy

Inspect the code, look for module imports, download them and update go.mod.

go mod tidy

If we know our dependency, it is sufficient to add it to the import list, then execute go mod tidy:

import (
	consul "github.com/hashicorp/consul/api"
)

...