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
+8.8k Golang : Gorilla web tool kit schema example
+13k Swift : Convert (cast) Int to String ?
+8.6k Golang : Convert(cast) []byte to io.Reader type
+7.9k Golang : Trim everything onward after a word
+27.2k Golang : Find files by name - cross platform example
+6.3k Golang : How to get capacity of a slice or array?
+5.2k Golang : Customize scanner.Scanner to treat dash as part of identifier
+11.6k Golang : Concurrency and goroutine example
+43.5k Golang : Get hardware information such as disk, memory and CPU usage
+15.6k Golang : ROT47 (Caesar cipher by 47 characters) example
+5.7k Golang : Struct field tags and what is their purpose?
+5.8k CodeIgniter/PHP : Remove empty lines above RSS or ATOM xml tag