-1

In the strings module, there is a function func NewReader(s string) *Reader to create a Reader from a string.

How can you get/read the string from the strings.Reader?

deft_code
  • 57,255
  • 29
  • 141
  • 224
Salah Eddine Taouririt
  • 24,925
  • 20
  • 60
  • 96

1 Answers1

2

You can use ioutil.ReadAll :

bytes, err := ioutil.ReadAll(r)
// err management here
s := string(bytes)
Denys Séguret
  • 372,613
  • 87
  • 782
  • 758