Go Package bytes: Difference between revisions
Jump to navigation
Jump to search
(→Buffer) |
(→Buffer) |
||
Line 11: | Line 11: | ||
* https://golang.org/pkg/bytes/#Buffer | * https://golang.org/pkg/bytes/#Buffer | ||
A <tt>Buffer</tt> does not have to be initialized and supports both <tt>[[Go_Package_io#Reader|Reader]]</tt> and <tt>[[Go_Package_io#Writer|Writer]]</tt> interface. | A <tt>Buffer</tt> is a variable-sized buffer of bytes with <tt>Read</tt> and <tt>Write</tt> methods. The zero value for <tt>Buffer</tt> is an empty buffer ready to use. A <tt>Buffer</tt> does not have to be initialized and supports both <tt>[[Go_Package_io#Reader|Reader]]</tt> and <tt>[[Go_Package_io#Writer|Writer]]</tt> interface. | ||
Conversion of a <tt>Buffer</tt> into a <tt>[]byte</tt>: | Conversion of a <tt>Buffer</tt> into a <tt>[]byte</tt>: |
Revision as of 22:35, 30 March 2016
External
Internal
Buffer
A Buffer is a variable-sized buffer of bytes with Read and Write methods. The zero value for Buffer is an empty buffer ready to use. A Buffer does not have to be initialized and supports both Reader and Writer interface.
Conversion of a Buffer into a []byte:
var buffer bytes.Buffer bytes := buffer.Bytes()