Skip to content

Instantly share code, notes, and snippets.

@gigenthomas
Last active March 23, 2025 06:12
Show Gist options
  • Save gigenthomas/2e1459e6f30b36c72b9e5eed25ad10e9 to your computer and use it in GitHub Desktop.
Save gigenthomas/2e1459e6f30b36c72b9e5eed25ad10e9 to your computer and use it in GitHub Desktop.
go-constants.go
const (
Unknown nodeType = iota
Sync
Async
Fanout
)
func getNodeType(node Node) nodeType {
if _, isSync := node.(SyncNode); isSync {
return Sync
}
if _, isAsync := node.(AsyncNode); isAsync {
return Async
}
if _, isFanout := node.(FanoutNode); isFanout {
return Fanout
}
return Unknown
}
/*
const – Declares a group of constants.
iota – Automatically increments values starting from 0 within the const block.
Unknown nodeType = iota – Assigns 0 to Unknown, and nodeType is the type for these constants.
Sync – Becomes 1, as iota increments.
Async – Becomes 2.
Fanout – Becomes 3.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment