package main import ( "log" ) func main() { log.Print("This is a log message.") }
package main import ( "log" ) func main() { value := 0 if value == 0 { log.Fatalf("Value cannot be zero.") } }This example uses the Fatalf function of the log package to log an error message "Value cannot be zero." and exit the program with a non-zero status because the value is equal to zero. Both examples utilize the go log package.