Files
  • main.go
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package main

import "fmt"

func main() {
	// :show start
	greetings := map[string]struct{}{
		"hi":    {},
		"hello": {},
	}

	// delete a value from set
	delete(greetings, "hi")

	// add a value to set
	greetings["hey"] = struct{}{}

	// check if a value is in the set:
	if _, ok := greetings["hey"]; ok {
		fmt.Printf("'hey' is in greetings\n")
	}
	// :show end
}
go version go1.9.4 linux/amd64