Go Tool: Difference between revisions
Line 2: | Line 2: | ||
* [[Go_Operations|Go Operations]] | * [[Go_Operations|Go Operations]] | ||
=Overview= | =Overview= | ||
<code>go</code> is a command line tool with multiple uses: manage packages in [[Go_Language_Modularization#Workspace|workspaces]], query metadata about packages, print documentation, build, format, download, test, etc. | <code>go</code> is a command line tool with multiple uses: package manager, build tool and test driver. <code>go</code> manage packages in [[Go_Language_Modularization#Workspace|workspaces]], query metadata about packages, print documentation, build, format, download, test, etc. | ||
=Commands= | =Commands= |
Revision as of 01:04, 8 September 2023
Internal
Overview
go
is a command line tool with multiple uses: package manager, build tool and test driver. go
manage packages in workspaces, query metadata about packages, print documentation, build, format, download, test, etc.
Commands
Help
go help <command>
go help build
build
The build
command compiles one, possible more packages and optionally builds an executable.
cd ${PROJECT_DIR}
go build ./src/main/main.go
The command will create an executable named after the first source file, in this case main
, and will place it by default in the ${PROJECT_DIR}
directory.
To build in GOPATH mode, see:
install
doc
The doc
command prints documentation for a package.
fmt
The fmt
("format") command formats source code files.
get
The get
command downloads packages and installs them.
list
The list
command lists all installed packages.
run
The run
command compiles .go
files and runs the executable.
cd $PROJECT_DIR
go run ./src/main/main.go
test
The test
command runs tests. For more details, see: