golangUsing panic() in program
Usage example
package main
func main() {
age := 90
if age > 50 {
panic("Naah, too old")
}
}
output
panic: Naah, too old
goroutine 1 [running]:
main.main()
/tmp/test.go:6 +0x27
exit status 2More of Golang
- How to generate random float
- How to generate random int
- How to iterate over a slice in reverse order
- How to generate random string
- How to set custom headers for HTTP request
- How to check Go version
- How to use basic auth with HTTP client
- Unrmarshal example
- How to use range with string
- How to set user agent for HTTP request
See more codes...