Essential Go Structs  Edit on GitHub      File Issue

Empty struct

A struct is a sequence of named elements, called fields, each of which has a name and a type. Empty struct has no fields, like this anonymous empty struct:

var s struct{}

Or like this named empty struct type:

type T struct{}

The interesting thing about the empty struct is that, its size is zero:


This prints 0, so the empty struct itself takes no memory. so it is good option for quit channel, like:

package main

import (

func main() {
    done := make(chan struct{})
    go func() {
        time.Sleep(1 * time.Second)

  ↑ ↓ to navigate     ↵ to select     Esc to close