Golang bytes.Buffer.Next() function example
package bytes
Next returns a slice containing the next n (1st parameter) bytes from the buffer, advancing the buffer as if the bytes had been returned by Read. If there are fewer than n bytes in the buffer, Next returns the entire buffer. The slice is only valid until the next call to a read or write method.
Golang bytes.Buffer.Next() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
buff := bytes.NewBufferString("abcdefghi")
var threebytes [3]byte
buff.Read(threebytes[0:3])
fmt.Printf("%s\n", string(threebytes[:]))
// read the next 5 bytes
fmt.Printf("%s\n", string(buff.Next(5)))
}
Output :
abc
defgh
Reference :
Advertisement
Something interesting
Tutorials
+13.2k Golang : Skip blank/empty lines in CSV file and trim whitespaces example
+14.2k Golang : Convert IP version 6 address to integer or decimal number
+7.5k Golang : Detect sample rate, channels or latency with PortAudio
+5.2k Responsive Google Adsense
+51.9k Golang : How to get time in milliseconds?
+5.6k PHP : Fix Call to undefined function curl_init() error
+10k Golang : Get escape characters \u form from unicode characters
+9.3k Golang : Temperatures conversion example
+10.1k Golang : Edge detection with Sobel method
+5.9k Golang : Use NLP to get sentences for each paragraph example
+21.4k Curl usage examples with Golang
+14.6k Golang : Missing Bazaar command