Setting Up Your Go Environment Flashcards
What command is used to access development tools in Go?
go
What does the go build command do?
It compiles Go programs.
What is the purpose of go fmt?
It formats Go code according to Go’s formatting rules.
Which command manages Go module dependencies?
go mod
What is the function of go test?
It runs tests in Go.
What does go vet do?
It detects common mistakes and errors in Go code.
How do you initialize a Go module?
By running go mod init, which creates a go.mod file.
What information does the go.mod file contain?
It contains the module name, the minimum supported Go version, and dependencies.
What is the purpose of a Go package declaration?
It organizes code into packages, with main being the starting point.
What does go build do when executed?
It generates an executable. The default binary name is the module name, but it can be changed with the -o flag.
How are braces placed in Go?
The opening brace must be on the same line as the declaration or command.
What is the recommended practice before compiling Go code?
Always run go fmt to fix whitespace and enforce consistent formatting.
How does Go handle semicolons in code?
Semicolons are automatically inserted by the Go compiler, so developers should never manually add them.
What should you do to check for missing arguments in a function call in Go?
Run go vet to detect errors like missing arguments.
What is a Makefile used for in software development?
A Makefile automates the building of programs by specifying a sequence of operations.
What does .DEFAULT_GOAL in a Makefile specify?
It specifies the default target to execute when no target is given.
How is a target defined in a Makefile?
A target is defined by its name followed by a colon, with prerequisites listed after the colon.