-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GetString function #54
base: master
Are you sure you want to change the base?
Conversation
Resolves valyala#53 Convenience function so users don't have to do: ```go s := string(v.GetStringBytes("key", "a", "b")) ```
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #54 +/- ##
==========================================
+ Coverage 97.00% 97.01% +0.01%
==========================================
Files 9 9
Lines 1067 1072 +5
==========================================
+ Hits 1035 1040 +5
Misses 19 19
Partials 13 13 ☔ View full report in Codecov by Sentry. |
// Array indexes may be represented as decimal numbers in keys. | ||
// | ||
// "" is returned for non-existing keys path or for invalid value type. | ||
func (v *Value) GetString(keys ...string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add an equivalent String
function because that would collide with the existing one that returns a string representation of the value.
Unfortunately this won't work as expected, since the returned string will contain garbage after the next call to |
What do you suggest? |
Either stick to |
What if GetString returned string(v.GetStringBytes())? |
|
Resolves #53
Convenience function so users don't have to do: