GetBool
Overview
GetBool parses a bool environment variable.
Part of the env package — Node.js analog: dotenv / process.env.
Signature
go
func GetBool(key string, def bool) (bool, error)Compare: Node.js · Standard Go · gox
js
// Typical dotenv / process.env pattern in Node.jsgo
v := os.Getenv("KEY")
if v == "" {
v = "default"
}go
import "github.com/sahilkhaire/gox/env"
debug, err := env.GetBool("DEBUG", false)Example
go
import "github.com/sahilkhaire/gox/env"
debug, err := env.GetBool("DEBUG", false)Tips
Call Load() once at startup, then use typed getters instead of parsing strings manually.
Standard library alternative
Use the standard library directly:
go
v := os.Getenv("KEY")
if v == "" {
v = "default"
}