Skip to content

Instantly share code, notes, and snippets.

@xcoulon
Last active November 17, 2017 09:12
Show Gist options
  • Save xcoulon/c8c37d876ff62896102ff1981d1b469e to your computer and use it in GitHub Desktop.
Save xcoulon/c8c37d876ff62896102ff1981d1b469e to your computer and use it in GitHub Desktop.
The benefit of using named return values in Golang
// IsEnabled queries whether or not the specified feature is enabled or not.
func (uc Client) IsEnabled(feature string, options ...FeatureOption) (enabled bool) {
defer func() {
uc.metrics.count(feature, enabled)
}()
if f == nil {
...
return false
}
if !f.Enabled {
return false
}
for _, s := range f.Strategies {
...
return true
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment