Question : Go Error using Errorf() in Golang
Answered by : samer-saeid
package main
import "fmt"
func main() { age := -14 // creating an error using Efforf() error := fmt.Errorf("%d is negative\nAge can't be negative", age) if age < 0 { fmt.Println(error) } else { fmt.Println("Age: %d", age); }
}
Source : | Last Update : Thu, 23 Jun 22