I recently joined a project where there's an external configuration style service - basically a KV store that's called with jsonrpc.
Don't ask why it's there..
I need to query this config service to obtain a whitelist used internally within the codebase.
However, I can't come to a solution without using a global var. For example I call a function to get the config from package A
but must export the var for it to be used within other packages. My original solution was to use gocache
setting the cache within a package and exporting the cache accessor to have some type restriction. However, this added complexity and seemed too much rather than just storing the val in an exported var.
I have seen global vars used within the standard library but am confused as this would go against the law of encapsulation?
Would appreciate any advice how to approach a problem like this.