9
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Macだと標準入力の最大文字数は1024文字(?)

Posted at

Goの標準入力のサンプル(下記)をMacで動かしていたら1024文字以上入力できなくて、returnも押せなかった。(1文字消したらreturnできたから、return込みで1024文字)
http://golang.org/pkg/bufio/#example_Scanner_lines

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		fmt.Println(scanner.Text()) // Println will add back the final '\n'
	}
	if err := scanner.Err(); err != nil {
		fmt.Fprintln(os.Stderr, "reading standard input:", err)
	}
}

最初、Goの最大文字数制限に引っかかっているのかと思って調べていたが、実はMacの制限らしい。
MacOSX 10.6.7 cuts off stdin at 1024 chars
pexpect can't pass input over 1024 chars?
公式なドキュメントは見つからなかったので確信は持てない。
この制限を変えられる設定とかも見つけられませんでした。

まぁ、標準入力なら1024文字あれば大丈夫でしょうけど。

9
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?