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