When and in what order is the init() function executed in Go?
Hello everyone! I just started learning Go and came across the `init()` function. The documentation says it runs automatically, but I can't understand: when exactly? And what happens if I have multiple files in a package, each with its own init()? What if I import a third-party library that also has init()?
Here's my example. There's a `database` package with a file `db.go`:
```go
package database
import "fmt"
var Connection string
func init() {
fmt.Println("Initializing DB...")
Connection = "postgres://user:pass@localhost/mydb"
}
```
And a file `main.go`:
```go
package main
import (
"fmt"
"myproject/database"
)
func init() {
fmt.Println("My init in main")
}
func main() {
fmt.Println(database.Connection)
}
```
I expected that first the