Go.mod

From NovaOrdis Knowledge Base
Revision as of 01:39, 16 September 2023 by Ovidiu (talk | contribs) (Created page with "=Internal= =Overview= <code>go.mod</code> declares the module path, which is the import path prefix for all Go_Package...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Overview

go.mod declares the module path, which is the import path prefix for all packages within the module. It also tracks the modules that provide dependencies to this module.

One way to create it is with go mod init:

go mod init <module-path>

go.mod stays with the code, including in the source repository.

Example

module example.com/hello

go 1.21.0

require rsc.io/quote v1.5.2

require (
	golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect
	rsc.io/sampler v1.3.0 // indirect
)