有没有在Go中实现静态变量的模式?

I am having a brain freeze

I am trying to write a logging package to work with our enterprise logging system.

I want to create the logger and it associated data at the beginning and reuse it throughout the service lifetime.

something like this (pseudo code) at the entry point of the service

log := LogManager.CreateLogger("mylog", "DEBUG")

use the following code in the rest of the service and imported packages

log := LogManager.GetLogger() 

log would be the same instance - the one instantiated at the beginning.

Thanks

G

A package-level variable that is initialized via init() should work for your use case.