1 // Regression: a library package's init() never ran.
2 //
3 // registerFunc rejected every top-level init() after printing a message, so a
4 // dependency's setup was silently skipped. Legacy allows one init() per
5 // package (main packages excepted), runs it after the package's variable
6 // initializers, and lets it write package globals - which is the only place
7 // user code may do so. This checks both the call and the ordering.
8 package main
9 10 import (
11 "tests/regressions/should_compile/library_init/lib"
12 )
13 14 func main() {
15 if got := lib.ReadyValue(); got != 42 {
16 panic("library init did not run: Ready is zero")
17 }
18 println("ok")
19 }
20