Find go version?
Find go version :Type
go version
Print environment variables in linux
printenv
GOROOT is a variable that defines where your Go SDK is located.In my computer /usr/local/go. You do not need to change this variable, unless you plan to use different Go versions.
GOPATH is the root of your workspace and contains the following folders:
src/: location of Go source code (for example, .go, .c, .g, .s ).
pkg/: location of compiled package code (for example, .a ).
bin/: location of compiled executable programs built by Go.
How to find GOPATH and GOROOT in your system?
go env GOROOT
go env GOPATH
GOPATH is used to resolve import statements
If the environment variable is unset, GOPATH defaults to a subdirectory named “go” in the user’s home directory. To check this, enter the following command:
On Linux:
$go env GOPATH
$HOME/go
When using modules in Go, the GOPATH is no longer used to determine imports. However, it is still used to store downloaded source code in pkg and compiled commands bin.
Go modules
A module is a collection of packages that are released, versioned, and distributed together. Modules may be downloaded directly from version control repositories or from module proxy servers.
A module is identified by a module path, which is declared in a
go.mod
file, together with information about the module's dependencies. The module root directory is the directory that contains thego.mod
file.Go environment variables
go <command> [arguments]
The commands are
bug start a bug report build compile packages and dependencies clean remove object files and cached files doc show documentation for package or symbol env print Go environment information fix update packages to use new APIs fmt gofmt (reformat) package sources generate generate Go files by processing source get add dependencies to current module and install them install compile and install packages and dependencies list list packages or modules mod module maintenance run compile and run Go program test test packages tool run specified go tool version print Go version vet report likely mistakes in packages
Comments
Post a Comment