Increase the buffer of the scanner

This commit is contained in:
M. Mert Yildiran 2021-09-16 22:58:44 +03:00
parent 66046999cc
commit 362da8d70a
No known key found for this signature in database
GPG Key ID: D42ADB236521BF7A

View File

@ -65,6 +65,8 @@ func readConnection(wg *sync.WaitGroup, conn net.Conn, ws *websocket.Conn) {
defer wg.Done()
for {
scanner := bufio.NewScanner(conn)
buf := make([]byte, 0, 64*1024)
scanner.Buffer(buf, 209715200)
for {
ok := scanner.Scan()
@ -72,9 +74,11 @@ func readConnection(wg *sync.WaitGroup, conn net.Conn, ws *websocket.Conn) {
command := handleCommands(text)
if !command {
// fmt.Printf("\b\b** %s\n> ", text)
fmt.Printf("\b\b** %s\n> ", text)
if text == "" {
err := scanner.Err()
fmt.Printf("err: %v\n", err)
return
}