-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from kumparan/feature/addlowermap
Feature: addlowermap
- Loading branch information
Showing
3 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package utils | ||
|
||
import "strings" | ||
|
||
func LowerMapStringKey(v map[string]interface{}) map[string]interface{} { | ||
lv := make(map[string]interface{}, len(v)) | ||
for mk, mv := range v { | ||
lv[strings.ToLower(mk)] = mv | ||
} | ||
return lv | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package utils | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_LowerMapStringKey(t *testing.T) { | ||
value := map[string]interface{}{ | ||
"storyID" : "testing", | ||
} | ||
res := LowerMapStringKey(value) | ||
assert.Equal(t, res["storyid"].(string), "testing") | ||
} |