This PR fixes a bug in how we use fallback variants in this SDK.
The fallback should be used when there is no flag, when the flag doesn't have any variants, and if the flag has variants, but is disabled. However, prior to this, it was only used if the flag didn't exist.
It addresses the issues in and closes #160.
Discussion points
Overriding FeatureEnabled
Comparing this to the Node SDK, I noticed one thing that we don't seem to do: setting the FeatureEnabled property based on the flag's enabled state.
Because the fallback you pass in also has FeatureEnabled as a property, you can in theory override this. However, that means you can get into situations where the flag is actually enabled, but the variant says FeatureEnabled is false because that's what the fallback says. That seems incorrect to me, so I've added in some handling for that, but I'd like to get a second opinion on it.
Code quality
This may be my first time writing Go, so it's very possible that I've missed some idioms or similar. Please feel free to correct as many things as you want.
This PR fixes a bug in how we use fallback variants in this SDK.
The fallback should be used when there is no flag, when the flag doesn't have any variants, and if the flag has variants, but is disabled. However, prior to this, it was only used if the flag didn't exist.
It addresses the issues in and closes #160.
Discussion points
Overriding
FeatureEnabled
Comparing this to the Node SDK, I noticed one thing that we don't seem to do: setting the
FeatureEnabled
property based on the flag's enabled state.Because the fallback you pass in also has
FeatureEnabled
as a property, you can in theory override this. However, that means you can get into situations where the flag is actually enabled, but the variant saysFeatureEnabled
isfalse
because that's what the fallback says. That seems incorrect to me, so I've added in some handling for that, but I'd like to get a second opinion on it.Code quality
This may be my first time writing Go, so it's very possible that I've missed some idioms or similar. Please feel free to correct as many things as you want.