import ( "github.com/docker/docker/engine" "fmt" ) func main() { job := engine.Job{} // set environment variable "DEBUG" to "true" job.Env = []string{"DEBUG=true"} // Get the value of "DEBUG" environment variable as a boolean debug := job.GetenvBool("DEBUG", false) // Output: true fmt.Println(debug) }
import ( "github.com/docker/docker/engine" "fmt" ) func main() { job := engine.Job{} // "LOG_LEVEL" environment variable has not been set // Get the value of "LOG_LEVEL" environment variable as a boolean with a default value of false logLevel := job.GetenvBool("LOG_LEVEL", false) // Output: false fmt.Println(logLevel) }In this example, we create an engine.Job object but we do not set an environment variable "LOG_LEVEL". We then use the GetenvBool function to retrieve the value of the "LOG_LEVEL" environment variable as a boolean with a default value of false. Since the variable does not exist, the function returns the default value of false and we print it to the console.