Closed emicklei closed 9 years ago
Another solution might be to provide a Load method on Properties itself as this struct has a Prefix,Postfix pair that can be changed to prevent expansion. (properties.go:596)
Properties expands on Get()
and checks for circular references on both Get()
and Set()
. I've added a DisableExpansion
flag which you can set to true
after Load
which will disable both the expansion and the circular reference check. Please note that you can shoot yourself in the foot now by creating a Properties object with circular references which explodes when being used by your service. Also, you can construct a Properties object with circular references and then enable the circular reference check again. The next Get()
of such a reference will then fail.
Let me know what you think. The change is in https://github.com/magiconair/properties/tree/issue5
Thank you for the quick response and implementation. I had the wrong assumption that expansion is part of the Load process. The DisableExpansion will work for our case.
Then I'll merge it
As part of our configuration service, we need to store configurations as is in key-value records without substituing the ${..} expressions. Application that retrieve properties from this service will do the expansions.
My suggestion is to provide another Load function that takes the extra boolean parameter
expandExpressions