Go course

Packages and ModulesQuiz: Packages and Modules

Go

Display

Theme

Packages and Modules · Quiz

Quiz: Packages and Modules

Test your understanding of packages, name visibility, modules, the go command, and the standard library. Answer every question in the right-hand panel.

  1. Question 1 of 6The kasir package contains the following code. Which names can be used from the main package?
    package kasir
    
    func Total(h []int) int { ... }
    func pajak(n int) int { ... }
    type struk struct{ ... }
    const MaksItem = 50
  2. Question 2 of 6Which command creates the go.mod file for a new project?
  3. Question 3 of 6A project with the module github.com/rina/kedai has a menu/ folder holding the menu package. How does main.go import it?
  4. Question 4 of 6What happens if a file imports "strings" but doesn't use it?
  5. Question 5 of 6What does the following code print?
    n, err := strconv.Atoi("12a")
    fmt.Println(n, err != nil)
  6. Question 6 of 6What's the difference between go build and go install?