top | item 27963773

(no title)

BenTheElder | 4 years ago

A zero-sized type + hashmap for sets is also done in Go with a `struct{}`. [1][2]

But without generics it must be implemented again for each entry type ...

Kubernetes uses a code generator to automate this, but it's a bit kludge. [3]

[1]: https://pkg.go.dev/k8s.io/apimachinery/pkg/util/sets#Empty

[2]: https://dave.cheney.net/2014/03/25/the-empty-struct

[3]: https://github.com/kubernetes/code-generator/blob/master/cmd...

discuss

order

No comments yet.