Go Modules: Difference between revisions
Jump to navigation
Jump to search
(→go.mod) |
|||
Line 20: | Line 20: | ||
=<tt>go.mod</tt>= | =<tt>go.mod</tt>= | ||
<code>go.mod</code> declares the module path, which is the [[Go_Packages#Import_Path|import path]] prefix for all [[Go_Packages#Overview|packages]] within the module. | <code>go.mod</code> declares the module path, which is the [[Go_Packages#Import_Path|import path]] prefix for all [[Go_Packages#Overview|packages]] within the module. | ||
=Module Path= | |||
A module path serves as import path prefix for its packages. It also indicates where the [[#Go_Tool#Overview|<code>go</code> tool]] command should look to download it. For example, to download the module <code>golang.org/x/tools</code>, the <code>go</code> tool should go to the repository indicated by https://golang.org/x/tools. |
Revision as of 19:41, 7 September 2023
Internal
TO PROCESS
To process:
Overview
A module is a collection of related packages with built-in dependencies and versioning, that are released together. The module contains the packages in the directory containing its go.mod
file as well as subdirectories of that directory, up to the next subdirectory containing another go.mod
file (if any).
Declaring Modules
Building Modules
Publishing Modules
Consuming Modules
go.mod
go.mod
declares the module path, which is the import path prefix for all packages within the module.
Module Path
A module path serves as import path prefix for its packages. It also indicates where the go
tool command should look to download it. For example, to download the module golang.org/x/tools
, the go
tool should go to the repository indicated by https://golang.org/x/tools.