It reads Stdin into a buffer and appeds it to a result buffer until an error occurs. If the error is io.EOF, it returns the collected buffer. Otherwise, the error is returned. It works a bit like the following snippet.
package main
import (
"io"
"os"
)
func main() {
buf := make([]byte, 1024)
var res []byte
for {
n, err := os.Stdin.Read(buf)
res = append(res, buf[:n]...)
if err == io.EOF {
break
}
if err != nil {
panic(err)
}
}
println(len(res))
}
But for this test case, I need to read 100000 characters from StdIn, first.
So if possible, I’d like you to help me for fixing of this test case.
Thank you.[quote=“devphoenix092, post:1, topic:34591, full:true”]
I want to input and read a string of more than 10000 characters using Golang’s stdin module.
However, with my current knowledge of Golang, I can only read first 4096 characters.
So I would like to anyone to help me for fixing of this problem.