Consider this Go program saved as main.go. What will be printed when you run go run main.go?
package main import "fmt" func main() { fmt.Println("Hello, Go toolchain!") }
Think about what go run does with a simple program that prints text.
The go run command compiles and runs the Go program. Since the program prints "Hello, Go toolchain!", that is the output.
Which go tool command compiles the packages and their dependencies but does not run the program?
Think about the command that creates an executable without running it.
go build compiles the packages and dependencies and produces an executable file but does not run it.
What error message will this Go program produce when executed with go run?
package main func main() { var x int = "string" }
Look at the variable type and the assigned value types.
The program tries to assign a string value to an int variable, which causes a type mismatch error.
Choose the correct statement about the difference between go install and go build.
Think about where the executable ends up after each command.
go install compiles the package and places the executable in the Go workspace bin directory, making it available globally. go build compiles locally without installing.
This Go program uses a module and imports fmt. What will be the output when running go run main.go inside a module-enabled directory?
package main import "fmt" func main() { fmt.Println("Module enabled run") }
Modules do not affect standard library imports like fmt.
The program prints the string because fmt is part of the standard library and modules do not block this import.