package main import ( "fmt" "time" "github.com/gocql/gocql" ) type Metric struct { ID_client string `json:"id_client"` Mtime time.Time `json:"mtime"` Name string `json:"name"` Value string `json:"value"` } func PrintMetrics(metrics []Metric) { for _, metric := range metrics { fmt.Printf("%s\n", metric.Name) } } func LoadMetrics(session *gocql.Session) []Metric { var metrics []Metric m := map[string]interface{}{} iter := session.Query("SELECT id_client, mtime, name, value FROM metric").Iter() for iter.MapScan(m) { metrics = append(metrics, Metric{ ID_client: m["id_client"].(string), Mtime: m["mtime"].(time.Time), Name: m["name"].(string), Value: m["value"].(string), }) m = map[string]interface{}{} } return metrics }