Setting Up Your Go Environment Flashcards

1
Q

What command is used to access development tools in Go?

A

go

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the go build command do?

A

It compiles Go programs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the purpose of go fmt?

A

It formats Go code according to Go’s formatting rules.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which command manages Go module dependencies?

A

go mod

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the function of go test?

A

It runs tests in Go.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does go vet do?

A

It detects common mistakes and errors in Go code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you initialize a Go module?

A

By running go mod init, which creates a go.mod file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What information does the go.mod file contain?

A

It contains the module name, the minimum supported Go version, and dependencies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the purpose of a Go package declaration?

A

It organizes code into packages, with main being the starting point.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does go build do when executed?

A

It generates an executable. The default binary name is the module name, but it can be changed with the -o flag.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How are braces placed in Go?

A

The opening brace must be on the same line as the declaration or command.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the recommended practice before compiling Go code?

A

Always run go fmt to fix whitespace and enforce consistent formatting.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How does Go handle semicolons in code?

A

Semicolons are automatically inserted by the Go compiler, so developers should never manually add them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What should you do to check for missing arguments in a function call in Go?

A

Run go vet to detect errors like missing arguments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a Makefile used for in software development?

A

A Makefile automates the building of programs by specifying a sequence of operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does .DEFAULT_GOAL in a Makefile specify?

A

It specifies the default target to execute when no target is given.

17
Q

How is a target defined in a Makefile?

A

A target is defined by its name followed by a colon, with prerequisites listed after the colon.