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
+10.4k Golang : Find age or leap age from date of birth example
+12k Golang : Skip blank/empty lines in CSV file and trim whitespaces example
+7.3k Prevent Write failed: Broken pipe problem during ssh session with screen command
+9k Golang : Test a slice of integers for odd and even numbers
+5.2k Java : Human readable password generator
+18.2k Golang : Get current URL example
+23.2k Golang : Daemonizing a simple web server process example
+61.6k Golang : Convert HTTP Response body to string
+19.7k Golang : Clean up null characters from input data
+82.5k Golang : How to convert character to ASCII and back
+4.3k Golang : Display packages names during compilation
+4.7k Golang : Display advertisement images or strings on random order