Our great sponsors
-
package main import ( "fmt" ) func main() { s := []string{"Samuel", "Marc", "Samuel"} names := Uniq(s) fmt.Println(names) names = UniqGenerics(s) fmt.Println(names) i := []int{1, 20, 20, 10, 1} ids := UniqGenerics(i) fmt.Println(ids) } //from https://github.com/samber/lo/blob/master/slice.go func UniqGenerics[T comparable](collection []T) []T { result := make([]T, 0, len(collection)) seen := make(map[T]struct{}, len(collection)) for _, item := range collection { if _, ok := seen[item]; ok { continue } seen[item] = struct{}{} result = append(result, item) } return result } func Uniq(collection []string) []string { result := make([]string, 0, len(collection)) seen := make(map[string]struct{}, len(collection)) for _, item := range collection { if _, ok := seen[item]; ok { continue } seen[item] = struct{}{} result = append(result, item) } return result }
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.