// 已知list中元素"amber","jack"

arr := [...]string{"amber","jack"}

 

var set map[string]struct{}

set = make(map[string]struct{})

 

for _, value := range arr{

    set[value] = struct{}{}

}

 

if _, ok := set["amber"];ok {

    fmt.Println("amber is in the list")

} else {

    fmt.Println("amber is not in the list")

}