Golang fmt.Fprintln() function examples
package fmt
Fprintln formats using the default formats for its operands and writes to w. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
Golang fmt.Fprintln() function usage examples
Example 1 :
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
<-c
fmt.Fprintln(os.Stderr, "\nReceived second interrupt. Shutting down.")
os.Exit(1)
Example 2 :
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello World! ")
})
Reference :
Advertisement
Something interesting
Tutorials
+9.2k Golang : Write multiple lines or divide string into multiple lines
+18k Golang : How to log each HTTP request to your web server?
+7.9k Golang : Get today's weekday name and calculate target day distance example
+31.1k Golang : Calculate percentage change of two values
+7.8k Swift : Convert (cast) String to Double
+11.5k Golang : Generate DSA private, public key and PEM files example
+9.4k Golang : Scramble and unscramble text message by randomly replacing words
+19.6k Golang : Set or Add HTTP Request Headers
+6.1k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+10.6k Golang : ISO8601 Duration Parser example
+30.9k error: trying to remove "yum", which is protected
+5.7k List of Golang XML tutorials