Go - Package import and initialization


Package Import
  1. Import path: packages are identified by an unique string, called import path
  2. Go lang spec doesn't define what "import path" mean, it's up to the tools to interpret them
  3. Declare import without using it will get panic
Package Initialization
  1. init function can't be called, but can be used to init package.
    1. In this case, only main function is initialized
    2. Declare same function name in the same package, even in different file. Will get panic
    3. When main function call package function, package will be initialized before main function.
    4. The order of package initialization follows files order
    5. This picture proves main is the last package to be initialized



沒有留言:

張貼留言

Lessons Learned While Benchmarking vLLM with GPU

Recently, I benchmarked vLLM on a GPU to better understand how much throughput can realistically be expected in an LLM serving setup. One ...