Skip to content

Instantly share code, notes, and snippets.

@cvvs
Created May 31, 2016 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cvvs/ddf4b81dc92f71c54f495d85532634cd to your computer and use it in GitHub Desktop.
Save cvvs/ddf4b81dc92f71c54f495d85532634cd to your computer and use it in GitHub Desktop.
package main
import "fmt"
func main() {
var stringSet map[string]interface{} = make(map[string]interface{})
stringSet["apple"] = nil
stringSet["orange"] = nil
stringSet["cherry"] = nil
// O(1) vs O(n). Only matters for large lists
if _, ok := stringSet["apple"]; !ok {
fmt.Println("apple not in stringset")
}
if _, ok := stringSet["banana"]; !ok {
fmt.Println("banana not in stringset")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment