Skip to content

Instantly share code, notes, and snippets.

@madagra
Created January 11, 2024 21:12
Show Gist options
  • Save madagra/1a7e3aee90f12ef3bdfd963cc43917d5 to your computer and use it in GitHub Desktop.
Save madagra/1a7e3aee90f12ef3bdfd963cc43917d5 to your computer and use it in GitHub Desktop.
Golang union type
type Message struct {
Sender string `json:"sender"`
Receiver string `json:"receiver"`
Body string `json:"body"`
Time string `json:"time"`
}
type User struct {
isOnline bool
msgCh chan Message
}
type Union interface {
User | Message | float32 | int32
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment