Closed powerman closed 6 years ago
This is the way it should be used.
A policy is not safe to be used whilst it is being defined (there is no protection around some of the maps for example), but once it has been constructed it is safe to be used by multiple goroutines that apply the same policy.
In my programs I set up a couple of policies during program init and then use them for the life of the program across many goroutines.
I've updated the example usage code to include clarifying comments.
At a glance it looks like there is no reason to create new policy per each sanitized value (well, it's per goroutine, but in practice this often means - per each value), after initial policy setup it should be safe to use by multiple goroutines, but doc doesn't mention this (which apply default meaning: not safe). So, if it's safe, please document this.