From 10c593006b0f712ad13550f2afce6dfec717e07d Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Thu, 13 Nov 2014 17:23:30 +0100 Subject: [PATCH] Issue #1: Fixed that Keys() returns an empty key. --- README.md | 4 ++++ properties.go | 2 +- properties_test.go | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d1afbe6..1270e64 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,10 @@ $ go get -u github.com/magiconair/properties History ------- +v1.4.1, 13 Nov 2014 +------------------- + * (Issue #1) Fixed bug in Keys() method which returned an empty string + v1.4.0, 23 Sep 2014 ------------------- * Added Keys() to get the keys diff --git a/properties.go b/properties.go index e9386fb..cde68fe 100644 --- a/properties.go +++ b/properties.go @@ -362,7 +362,7 @@ func (p *Properties) Len() int { // Keys returns all keys. func (p *Properties) Keys() []string { - keys := make([]string, len(p.m)) + keys := make([]string, 0, len(p.m)) for k, _ := range p.m { keys = append(keys, k) } diff --git a/properties_test.go b/properties_test.go index ba5d6be..4abe20b 100644 --- a/properties_test.go +++ b/properties_test.go @@ -560,6 +560,7 @@ func (l *TestSuite) TestKeys(c *C) { p, err := parse(test.input) c.Assert(err, IsNil) c.Assert(p.Len(), Equals, len(test.keys)) + c.Assert(len(p.Keys()), Equals, len(test.keys)) for _, key := range test.keys { _, ok := p.Get(key) c.Assert(ok, Equals, true)