Golang log.Panic, Panicf and Panicln functions example
package log
Golang log.Panic, Panicf and Panicln functions usage example
package main
import (
"fmt"
"log"
)
func main() {
defer func() {
if err := recover(); err != nil {
fmt.Println(err) // nooo! and stop
handleException()
}
}()
log.Panic("nooo! and stop")
// log.Panicf is similar to fmt.Printf ( can replace %s,%v,%d with values)
// log.Panicln is similar to fmt.Println (end of with \n)
log.Println("this will not be called.")
}
func handleException() {
log.Println("recovering...")
}
References :
http://golang.org/pkg/log/#Panic
Advertisement
Something interesting
Tutorials
+15.9k Golang : Get current time from the Internet time server(ntp) example
+15.7k Golang : Intercept Ctrl-C interrupt or kill signal and determine the signal type
+6k Fontello : How to load and use fonts?
+6.3k WARNING: UNPROTECTED PRIVATE KEY FILE! error message
+16.8k Golang : read gzipped http response
+7.8k Golang : Load DSA public key from file example
+6.8k Swift : substringWithRange() function example
+11.6k Golang : Surveillance with web camera and OpenCV
+6.5k PHP : Shuffle to display different content or advertisement
+12.3k Golang : Display list of countries and ISO codes
+5.2k Responsive Google Adsense
+9.7k Golang : Detect number of active displays and the display's resolution