Difference between revisions of "Go mod"

From wikieduonline
Jump to navigation Jump to search
Line 12: Line 12:
 
</pre>
 
</pre>
  
 +
 +
<pre>
 +
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>
 
   
 
   
  

Revision as of 11:30, 10 August 2022

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


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.



See also

Advertising: