Set in Go, map[]bool and map[]struct{} performance comparison
TL;DR
map[]struct{}
is 5% faster in time and 10% less memory consumption comparing tomap[]bool
when it comes to a big Set.
It is not a secret that there is no built-in Set in go, so go developers use map
to mimic the behavior of Set. Use map
to implement Set means that the value of the map is not important, we only need to focus on the existence of the key…