import ( "fmt" "k8s.io/kubernetes/pkg/util/sets" ) func main() { list1 := sets.NewStringList("apple", "banana", "orange") list2 := sets.NewStringList("orange", "grape", "kiwi") unionList := list1.Union(list2) fmt.Println("Union:", unionList.List()) intersectList := list1.Intersection(list2) fmt.Println("Intersection:", intersectList.List()) diffList := list1.Difference(list2) fmt.Println("Difference:", diffList.List()) symDiffList := list1.SymmetricDifference(list2) fmt.Println("Symmetric Difference:", symDiffList.List()) }
import ( "fmt" "k8s.io/kubernetes/pkg/util/sets" ) func main() { list := sets.NewStringList("apple", "banana", "orange") fmt.Println(list.Len()) // Output: 3 list.Insert("melon") fmt.Println(list.List()) // Output: [apple banana orange melon] list.Delete("banana") fmt.Println(list.List()) // Output: [apple orange melon] fmt.Println(list.Has("orange")) // Output: true }This example shows the usage of basic operations like Insert, Delete, Len, and Has on StringList. Overall, the "k8s.io/kubernetes/pkg/util/sets" package provides efficient Set implementations for various data types and is commonly used in Kubernetes codebase for list operations.