What is the empty struct (struct{}), and why is it commonly used in channels and sets?
Last updated
struct{}is a field-less type that occupies zero bytes, used when a value carries no information.chan struct{}signals events rather than data, e.g. a done signal broadcast viaclose(ch).map[string]struct{}models a set where only keys matter, using less space thanmap[string]bool.