kennygrant / sanitize

Package sanitize provides functions for sanitizing text in golang strings.
BSD 3-Clause "New" or "Revised" License
334 stars 72 forks source link

override defaults #13

Closed porjo closed 7 years ago

porjo commented 8 years ago

A couple of defaults I'd like to be able to override:

kennygrant commented 8 years ago

Sound sensible. Would it be acceptable to have package globals to set things like separator or other default options?

We'd need to keep the current behaviour and make this optional of course.

porjo commented 8 years ago

This would be one way to achieve it which keeps the current behaviour by default and doesn't break the API

kennygrant commented 7 years ago

I had a think about this last year, and the reason I haven't done it is that it would make the interface not thread safe in a non-obvious way. You might be tempted to set the globals each time before calling the function, which would not be safe in a goroutine (i.e. in a server). The Separator might be safe as a global if it's clearly documented I guess, because you're likely only to set it once.

Re lowercase, I think better would be to add functions which preserve case, but I'm not sure on naming. I prefer to avoid mixed case in file names because of varying treatment on file systems like Mac OS or linux which can cause subtle bugs.

So on balance I'm going to close this one for the above reasons. Sorry it took so long and thanks for the suggestions.