These steps cover writing and running your application:
- From your terminal/console application, create a new directory called chapter1/bytestrings.
- Navigate to this directory.
- Copy tests from https://github.com/agtorre/go-cookbook/tree/master/chapter1/bytesstrings, or use this as an exercise to write some of your own code!
- Create a file called buffer.go with the following contents:
package bytestrings import ( "bytes" "io" "io/ioutil" ) // Buffer demonstrates some tricks for initializing bytes //Buffers // These buffers implement an io.Reader interface func Buffer(rawString string) *bytes.Buffer { // we'll start with a string encoded into raw bytes rawBytes := []byte(rawString) // there are a number of ways to ...