Home > Software engineering >  Why Golang hchan struct closed field use uint32 type?
Why Golang hchan struct closed field use uint32 type?

Time:09-17

type hchan struct {
    qcount   uint           // total data in the queue
    dataqsiz uint           // size of the circular queue
    buf      unsafe.Pointer // points to an array of dataqsiz elements
    elemsize uint16
    closed   uint32
....

I searched the references of all closed fields, the values are only 0 and 1. What is more confusing is why not use int8 or other types?

  •  Tags:  
  • go
  • Related