Skip to content

Latest commit

 

History

History
23 lines (13 loc) · 488 Bytes

File metadata and controls

23 lines (13 loc) · 488 Bytes

Init Function

Let's learn about Go's init() function



init() function

  • init() function looks similar to main function, but doesn't take arguments or return values
  • init() function is the first function called when a package is loaded
    • Use it when you need package initialization logic!


When is the init() function run?

It executes in the order: import --> const --> var --> init()