Created
January 11, 2024 21:12
-
-
Save madagra/1a7e3aee90f12ef3bdfd963cc43917d5 to your computer and use it in GitHub Desktop.
Golang union type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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