mirror of
https://github.com/bootdotdev/fcc-learn-golang-assets.git
synced 2025-12-14 09:11:16 +00:00
first
This commit is contained in:
28
course/12-local_development/exercises/1-intro/readme.md
Normal file
28
course/12-local_development/exercises/1-intro/readme.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Packages
|
||||
|
||||
Every Go program is made up of packages.
|
||||
|
||||
You have probably noticed the `package main` at the top of all the programs you have been writing.
|
||||
|
||||
A package named "main" has an entrypoint at the `main()` function. A `main` package is compiled into an executable program.
|
||||
|
||||
A package by any other name is a "library package". Libraries have no entry point. Libraries simply export functionality that can be used by other packages. For example:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("My favorite number is", rand.Intn(10))
|
||||
}
|
||||
```
|
||||
|
||||
This program is an executable. It is a "main" package and *imports* from the `fmt` and `math/rand` library packages.
|
||||
|
||||
## Assignment
|
||||
|
||||
Fix the bug in the code.
|
||||
Reference in New Issue
Block a user