Golang log.Fatalf() function example

package log

Golang log.Fatalf() function usage example

 package main

 import (
 "fmt"
 "log"
 )

 func main() {

 fmt.Println("Before")

 value := 0.5

 // Fatalf will cause the program to
 // terminate
 // Fatalf is kinda similar to fmt.Printf
 log.Fatalf("value %f die here!", value)

 fmt.Println("After")
 }

Output :

Before

2015/03/26 14:32:32 value 0.500000 die here!

exit status 1

Reference :

http://golang.org/pkg/log/#Fatalf

Advertisement