Recall & Review
beginner
What is a package in Go?
A package in Go is a way to organize and reuse code. It groups related functions, types, and variables together in one place.
Click to reveal answer
beginner
How do you create a custom package in Go?
To create a custom package, make a folder with your package name, write Go files starting with 'package packagename', and then use 'import' to use it in other files.
Click to reveal answer
beginner
Why should package names be short and lowercase?
Short and lowercase package names are easier to type and remember. They also follow Go's style guidelines for readability and consistency.
Click to reveal answer
beginner
How do you make a function accessible outside its package?
Start the function name with a capital letter. This makes it exported and usable by other packages.
Click to reveal answer
beginner
What is the purpose of the 'import' statement in Go?
The 'import' statement lets you use code from other packages, including your custom packages, by bringing their names and functions into your file.
Click to reveal answer
What keyword starts a Go source file to define its package?
✗ Incorrect
Every Go file begins with the 'package' keyword followed by the package name.
How do you use a custom package in another Go file?
✗ Incorrect
You import the package using the 'import' statement with the package path or name.
Which function name is exported and accessible outside its package?
✗ Incorrect
In Go, functions starting with a capital letter are exported and accessible outside their package.
Where should you place your custom package files?
✗ Incorrect
Custom package files should be inside a folder named after the package for Go to recognize them properly.
What is the recommended style for package names?
✗ Incorrect
Go style recommends short, lowercase package names for simplicity and clarity.
Explain how to create and use a custom package in Go.
Think about folder structure, naming, exporting, and importing.
You got /4 concepts.
Why is it important to export functions in a package, and how do you do it?
Focus on function naming and visibility.
You got /2 concepts.