boilerplate
boilerplate copied to clipboard
Add a way to clearly mark a variable as having no value
There is some awkwardness in boilerplate
, and Go in general, with how to identify when you want to set a variable to "no value". In other languages, this would be done using null
or None
, but in Go, while some types can be set to nil
, most primitives can only be set to their "zero values" (e.g. "" for a string, 0 for an int, etc). This makes it hard to set "no value", both in the default
parameter in a boilerplate.yml
file and as a user when enter the value via interactive prompt or the --var
and --var-file
options.
Perhaps a simply, albeit not terribly elegant option is to simply define a placeholder that globally means "use the zero value for this type". A simple one would be something like __NO_VALUE__
. This is unlikely to collide with any real value a user is likely to enter and pretty clearly communicates the intent. Example:
variables:
name: Title
default: __NO_VALUE__