0
0
Goprogramming~10 mins

Go toolchain overview - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print the Go version using the runtime package.

Go
package main

import (
	"fmt"
	"runtime"
)

func main() {
	fmt.Println(runtime.[1]())
}
Drag options to blanks, or click blank then click option'
AVersionInfo
BGoVersion
CGetVersion
DVersion
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using a non-existent function like GoVersion()
Accessing Version as a variable instead of calling the function
2fill in blank
medium

Complete the command to build a Go program into an executable.

Go
go [1] main.go
Drag options to blanks, or click blank then click option'
Abuild
Brun
Cinstall
Dtest
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using go run which compiles and runs immediately
Using go test which runs tests instead of building
3fill in blank
hard

Fix the error in the command to run tests with verbose output.

Go
go test [1] ./...
Drag options to blanks, or click blank then click option'
A-v
B-verbose
C-verbose=true
D--verbose
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using long flags like --verbose which are not supported
Using -verbose=true which is invalid syntax
4fill in blank
hard

Fill both blanks to create a map of word lengths for words longer than 3 characters.

Go
words := []string{"go", "tool", "chain", "test"}
lengths := make(map[string]int)
for _, word := range words {
	if len(word) [2] 3 {
		lengths[word] = [1]
	}
}
Drag options to blanks, or click blank then click option'
Alen(word)
B>
C<
Dword
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using word instead of len(word) for the map value
Using < instead of > for filtering
5fill in blank
hard

Fill all three blanks to create a map of uppercase words to their lengths for words longer than 3 characters.

Go
words := []string{"go", "tool", "chain", "test"}
lengths := make(map[string]int)
for _, [2] := range words {
	if len([2]) [3] 3 {
		lengths[[1]([2])] = len([2])
	}
}
Drag options to blanks, or click blank then click option'
A""
Bword
C>
Dstrings.ToUpper
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using empty string "" as map key
Using wrong comparison operator like < instead of >