shad-go/lectures/09-io/bytesbuffer/main.go

15 lines
211 B
Go
Raw Normal View History

2020-04-23 01:40:13 +00:00
package main
import (
"bytes"
"fmt"
"os"
)
func main() {
var b bytes.Buffer // A Buffer needs no initialization.
b.Write([]byte("Hello "))
_, _ = fmt.Fprintf(&b, "world!")
_, _ = b.WriteTo(os.Stdout)
}