0
0
Goprogramming~5 mins

Creating custom packages in Go - Quick Revision & Summary

Choose your learning style9 modes available
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?
Afunc
Bimport
Cpackage
Dvar
How do you use a custom package in another Go file?
ABy using 'include' keyword
BBy writing 'import "packagename"' at the top
CBy copying the code manually
DBy running 'go use packagename'
Which function name is exported and accessible outside its package?
ACalculateSum
BcalculateSum
Ccalculate_sum
D_CalculateSum
Where should you place your custom package files?
AIn a folder named after the package
BAnywhere on your computer
CIn the main Go installation folder
DInside the 'bin' folder
What is the recommended style for package names?
ALong and descriptive with uppercase letters
BWith underscores
CCamelCase
DShort and lowercase
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.