Difference between revisions of "Go mod"

From wikieduonline
Jump to navigation Jump to search
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{lowercase}}
 
{{lowercase}}
 
+
* https://go.dev/ref/mod
 
  [[go mod init]]
 
  [[go mod init]]
 +
[[go mod download]]
 
  [[go mod vendor]]
 
  [[go mod vendor]]
 
  [[go mod verify]]
 
  [[go mod verify]]
 
  [[go mod why]]
 
  [[go mod why]]
 +
[[go mod tidy]]
 +
[[go help mod]]
 +
  
  
 
Execute:
 
Execute:
 
  [[go mod init]] YOUR_NAME
 
  [[go mod init]] YOUR_NAME
  go: creating new go.mod: module YOUR_NAME
+
  go: creating new [[go.mod]]: module YOUR_NAME
  
It will create a <code>go.mod</code> file containing:
+
It will create a <code>[[go.mod]]</code> file containing
 
<pre>
 
<pre>
 
  module YOUR_NAME
 
  module YOUR_NAME
Line 18: Line 22:
 
</pre>
 
</pre>
  
 
+
== Related ==
<pre>
+
* [[GOPATH]]
Go mod provides access to operations on modules.
 
 
 
Note that support for modules is built into all the go commands,
 
not just 'go mod'. For example, day-to-day adding, removing, upgrading,
 
and downgrading of dependencies should be done using 'go get'.
 
See 'go help modules' for an overview of module functionality.
 
 
 
Usage:
 
 
 
go mod <command> [arguments]
 
 
 
The commands are:
 
 
 
download    download modules to local cache
 
edit        edit go.mod from tools or scripts
 
graph      print module requirement graph
 
init        initialize new module in current directory
 
tidy        add missing and remove unused modules
 
vendor      make vendored copy of dependencies
 
verify      verify dependencies have expected content
 
why        explain why packages or modules are needed
 
 
 
Use "go help mod <command>" for more information about a command.
 
</pre>
 
 
 
 
  
  

Latest revision as of 18:52, 26 July 2023

go mod init
go mod download
go mod vendor
go mod verify
go mod why
go mod tidy
go help mod


Execute:

go mod init YOUR_NAME
go: creating new go.mod: module YOUR_NAME

It will create a go.mod file containing

 module YOUR_NAME

 go 1.14

Related[edit]


See also[edit]

Advertising: