What is the empty struct (struct{}), and why is it commonly used in channels and sets?

Last updated 20 June 2026

  • 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 via close(ch).

  • map[string]struct{} models a set where only keys matter, using less space than map[string]bool.

  • https://sagarsonwane230797.medium.com/save-memory-in-go-with-the-empty-struct-e2fe1e0f0ba6
All Golang interview questions