Created
August 21, 2018 13:40
-
-
Save andriykohut/9ceb1080806e5445964ab7dcd15146c8 to your computer and use it in GitHub Desktop.
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
package main | |
import "fmt" | |
func blah(data []map[string]interface{}) map[string]string { | |
result := make(map[string]string) | |
for _, item := range data { | |
tagTypeName := item["tag_type_name"].(string) | |
tagName := item["tag_name"].(string) | |
if tagTypeName == "profanity_status" { | |
result["profanity_status"] = tagName | |
} else if tagTypeName == "brand_unsafe" { | |
result[tagName] = item["accuracy"].(string) | |
} | |
} | |
return result | |
} | |
func main() { | |
data := []map[string]interface{}{ | |
map[string]interface{}{"tag_type_name": "profanity_status", "tag_name": "profane"}, | |
map[string]interface{}{"tag_type_name": "brand_unsafe", "tag_name": "profane", "accuracy": "42"}, | |
} | |
for k, v := range blah(data) { | |
fmt.Printf("%s: %s\n", k, v) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment