I couldn't find the answer to this from Googling.

According to the documentation that I've found:
- For any given package, its imports' init() functions are run before the 
package's init() function.
- Within a package, init() functions are more-or-less run in lexical 
filename order.

My question:
Can init() functions in different packages ever run concurrently, e.g. in 
separate go routines, or could they be in the future?

This seems to be within the spec, and could lead to faster startup on 
multicore machines, for example when packages A and B independently depend 
on C: both A and B's init() functions could run in separate goroutines 
after C's init() function, without violating the above. However, this could 
cause problems if (for example) A and B's init() functions update a map in 
C without synchronization.

Thanks for any answer,
Tom

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to