I am working on a basic project,
In my project inside the package, I have two more sub-packages.
And each sub-packages has it’s own init() function.
Here is my folder structure
the 2nd file is the main package.
Here is the full detail of both files
init should be written in a way that it doesn’t matter.
It is a known implementation detail of the official compiler, that imports will be loaded in lexical order per Package. Within each package each file is loaded in lexical order as well, so you can infer the order of init execution by manually resolving those import steps.
Any alternative implementation of the compiler could behave differently than what I’ve said in 2, therefore its better to adhere to 1.
What you can rely on though is, that potential inits of packages you import have been run, before you get into the init of the current file. Due to this, it is kind of guaranteed that init of the main package will always be the last init to be run.