https://www.growthbook.io/ logo
#give-feedback
Title
# give-feedback
b

busy-horse-73824

05/24/2022, 7:41 PM
One thing I'd lightly flag - the Go lib feels very "non-Go-like" - there's no safe way to detect that feature/featuremap parsing has failed, as it always returns non-nil values from functions like
BuildFeatureMap
,
ParseFeature
, and
BuildFeatureRule
- even if the input is totally invalid. Offering more of a typical Go interface would require breaking changes though. Would you be open to a PR around this?
It's also a little surprising that you don't just put json tags onto the feature structs, rather than having to manually iterate over maps to build the features - maybe there's a reason for that?
f

future-teacher-7046

05/24/2022, 7:53 PM
We're definitely open to PRs. I prefer maintaining backwards compatibility when possible, so maybe there's a way to just make new functions for parsing features that throw errors properly and deprecate the old ones.
b

busy-horse-73824

05/24/2022, 7:54 PM
It's kind of a difficult one because these APIs work in a super, super unusual way - there would be no common code between them on the parsing side (in order to maintain exactly the same behaviour anyway) So might be more sensible to release as a v2 module, then both remain independently available
f

future-teacher-7046

05/24/2022, 7:56 PM
Ok, I'm fine with a new major version instead then.
b

busy-horse-73824

05/24/2022, 7:56 PM
I'll have a peek at it when I get a chance 👌
Actually I guess one alternative is to just add the json tags and basically deprecate all the parsing/build methods - I don't think they should be necessary, as you could just do:
Copy code
var featureMap map[string]growthbook.Feature
json.Unmarshal(data, &featureMap)
Maybe would benefit from some minor extra thing to validate the final objects though
7 Views