Golang bytes.Buffer.String() function example
package bytes
String returns the contents of the unread portion of the buffer as a string. If the Buffer is a nil pointer, it returns "
<nil>
".
Golang bytes.Buffer.String() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
buff := bytes.NewBuffer([]byte("abcdefg"))
fmt.Println(buff.String())
var buf *bytes.Buffer // pointer
fmt.Println(buf.String())
}
Output :
abcdefg
<nil>
Reference :
Advertisement
Something interesting
Tutorials
+5.5k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+35.3k Golang : Integer is between a range
+10.9k Golang : Generate random elements without repetition or duplicate
+18.5k Golang : Iterating Elements Over A List
+10k Golang : Use regular expression to get all upper case or lower case characters example
+15.1k Golang : Find location by IP address and display with Google Map
+9.3k Golang : Get all countries currencies code in JSON format
+15.4k Golang : Validate hostname
+18.4k Golang : Send email with attachment
+8.9k Golang : Intercept and compare HTTP response code example
+7.8k Golang : Grayscale Image
+11.2k Golang : How to flush a channel before the end of program?