Discover the essentials of Go (Golang) programming language, from its history and key features to setting up the development environment. Learn how to write and run your first Go program efficiently.
History and Features of Go
Who developed the Go programming language? a) James Gosling b) Bjarne Stroustrup c) Ken Thompson, Rob Pike, and Robert Griesemer d) Dennis Ritchie
When was Go first released to the public? a) 2005 b) 2007 c) 2009 d) 2010
Which of the following is NOT a feature of the Go programming language? a) Static typing b) Automatic memory management c) Object-oriented programming d) Built-in garbage collection
Which company was responsible for the development of Go? a) Apple b) Microsoft c) Google d) IBM
Go is often praised for its simplicity. Which of these features contributes to its simplicity? a) Complex inheritance structure b) Minimalistic syntax and structure c) Comprehensive built-in libraries d) Multi-threading model
What type of programming model does Go promote? a) Object-oriented programming b) Functional programming c) Concurrent programming d) Event-driven programming
Which of these is a key design goal for Go? a) Support for complex frameworks b) High performance and scalability c) Large codebases d) Compatibility with legacy systems
In Go, which feature helps achieve better concurrency? a) Threads b) Goroutines c) Processes d) Classes
What is one of the main advantages of Go’s garbage collection system? a) It runs in the background without user input b) It manages memory allocation across multiple cores c) It uses a reference counting system d) It automatically defragments memory
Which statement is true about Go’s error handling? a) Go uses exceptions for error handling b) Go uses multiple return values, one of which is an error c) Go ignores errors unless explicitly mentioned d) Go handles errors using a special error object
Setting up Go Environment (Installation, GOPATH, Modules)
Which of the following is the first step to setting up a Go environment? a) Install the Go runtime b) Set the GOPATH c) Download the Go source code d) Install Go modules
What is the default GOPATH directory in Go? a) /usr/local/go b) $HOME/go c) /opt/go d) $GOPATH/src
How can you install Go on a Windows machine? a) By using the Windows Store b) By downloading the Go installer from the official site c) By compiling Go from source d) By using Homebrew
Which command in Go is used to download dependencies as modules? a) go fetch b) go mod c) go get d) go install
What is the purpose of the GOPATH in Go? a) To manage the workspace for Go code b) To store Go executable binaries c) To compile Go programs d) To store Go modules
What does the go mod init command do? a) Initializes a new Go module in the current directory b) Downloads external dependencies for a project c) Compiles Go source files d) Sets up the GOPATH environment variable
Which of these is true about Go modules? a) They allow the use of versioned dependencies b) They are used only for Go 1.13+ versions c) They are similar to Python packages d) They are required for every Go project
How can you check if Go is properly installed on your machine? a) Use go -v b) Use go check c) Use go status d) Use go install
What does the go run command do? a) Compiles and runs a Go program b) Installs a Go package c) Executes a Go module d) Runs a Go test suite
What is the recommended directory for Go source code? a) $GOPATH/src b) $HOME/go/src c) /usr/src/go d) /opt/go/src
Writing and Running Your First Go Program
What is the first line of a Go program? a) package main b) import "fmt" c) func main() d) var main()
What function is used as the entry point of a Go program? a) main() b) start() c) run() d) init()
Which of these is the correct way to print “Hello, World!” in Go? a) fmt.Println("Hello, World!") b) println("Hello, World!") c) Print("Hello, World!") d) System.out.println("Hello, World!")
What does the go run command do? a) Compiles and runs a Go source file b) Installs dependencies for the program c) Sets up Go modules d) Starts a Go web server
What should be the first statement of every Go program? a) import b) func main() c) package main d) var main()
In Go, how do you declare a variable? a) var x int b) int x c) let x = 0 d) x = 0
How do you declare and initialize a constant in Go? a) const PI = 3.14 b) var PI = 3.14 c) let PI = 3.14 d) def PI = 3.14
What is the file extension for a Go source file? a) .go b) .gop c) .gof d) .gol
How do you execute a Go program after writing the code? a) go run <filename> b) go start <filename> c) go execute <filename> d) go compile <filename>
What is the command to compile a Go program without running it? a) go build b) go compile c) go create d) go make
Answer Key
QNo
Answer (Option with text)
1
c) Ken Thompson, Rob Pike, and Robert Griesemer
2
c) 2009
3
c) Object-oriented programming
4
c) Google
5
b) Minimalistic syntax and structure
6
c) Concurrent programming
7
b) High performance and scalability
8
b) Goroutines
9
a) It runs in the background without user input
10
b) Go uses multiple return values, one of which is an error
11
a) Install the Go runtime
12
b) $HOME/go
13
b) By downloading the Go installer from the official site
14
c) go get
15
a) To manage the workspace for Go code
16
a) Initializes a new Go module in the current directory