Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You should actually be using a `struct{}` as the value, as it takes no space (opposed to a bool).

http://play.golang.org/p/KK1ymLzd_e



Cool, I didn't know that. will change my Set implementation :)

BTW You should remember that if you really want a python-like set, map[interface{}]struct{} is not enough - you still have to implement intersection, union, diff yourself. Not that it's rocket science, but I do think this warrants at least a package in the std library, if not a first class type.


Agreed. There is an awesome project that provides this: https://github.com/deckarep/golang-set




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: