Golang fileRun BuildInitiate go module as a package managerInstall package from GithubFormattingUse go help <command>Reference
Golang file
There must be a package
// main.go
package main
You can import outside lib
import (
"fmt"
)
Run
go run main.go
But if you are using other files and they are all under the same package. Main function is an entry point.
go run .
Build
Build programs into binaries.
go build file.go
./file
Initiate go module as a package manager
go mod init <project_name>
Install package from Github
go get
Formatting
Run
go fmt
.It briefly does the followings:
- Indentation: Go uses tab 😊
- Line length: no limit
go <command> [arguments]
Use go help <command>
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