blob: 2b3f513a155aeed541a35bafc6d9604688f24e25 [file] [log] [blame] [view]
# Introduction
Programmers from languages like Java or C++ may miss an `enum` type, providing type-safe constants.
# Code
type LogLevel struct { name string }
var (
LL_FATAL = LogLevel{"fatal"}
LL_ERROR = LogLevel{"error"}
LL_WARN = LogLevel{"warn"}
LL_INFO = LogLevel{"info"}
LL_DEBUG = LogLevel{"debug"}
)
This code allows functions to take a parameter of type `LogLevel` and prevents callers from accidentally passing values of other types for this parameter.