Golang io/ioutil.ReadAll() function example

package io/ioutil

Golang io/ioutil.ReadAll() function usage example

 package main

 import (
 "bytes"
 "fmt"
 "io/ioutil"
 )

 func main() {
 str := bytes.NewReader([]byte("abcdefghijklmnopqrstuvwxyz"))

 reader, err := ioutil.ReadAll(str)

 if err != nil {
 fmt.Println(err)
 }

 fmt.Printf("%s \n", reader)
 }

Reference :

http://golang.org/pkg/io/ioutil/#ReadAll

Advertisement