Empty struct

suggest change

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)


Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents