device source analysis

This commit is contained in:
arnaucode
2017-04-15 20:47:33 +02:00
parent ee7caca895
commit 8456427b32
6 changed files with 39 additions and 3 deletions

20
analyzeSource.go Normal file
View File

@@ -0,0 +1,20 @@
package main
import (
"strings"
"github.com/dghubble/go-twitter/twitter"
)
func analyzeSource(tweets []twitter.Tweet) map[string]int {
var sources = make(map[string]int)
for _, v := range tweets {
source := strings.Split(strings.Split(v.Source, ">")[1], "<")[0]
if _, ok := sources[source]; ok {
sources[source] = sources[source] + 1
} else {
sources[source] = 1
}
}
return (sources)
}