tobool(v) converts v to a boolean. The string "true" becomes true, and "false" becomes false. Boolean values pass through unchanged.
Signature
Example
Read a feature flag from the environment as a string and use it as a boolean condition:RUN_MIGRATIONS=false in the environment skips the migration task.
Notes
- Only the strings
"true"and"false"are valid inputs. Any other string causes an error. toboolis most useful when a value comes from an environment variable or CLI flag that is inherently a string.