We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 354f013 commit b0a4de8Copy full SHA for b0a4de8
sample/main.go
@@ -23,6 +23,8 @@ func main() {
23
os.Exit(1)
24
}
25
26
+ out := bufio.NewWriterSize(os.Stdout, 1024*512)
27
+
28
rand.Seed(time.Now().UnixNano())
29
scanner := bufio.NewScanner(os.Stdin)
30
for scanner.Scan() {
@@ -31,12 +33,13 @@ func main() {
31
33
continue
32
34
35
emitted += 1
- fmt.Printf("%q", scanner.Text()) // Println will add back the final '\n'
36
+ out.WriteString(scanner.Text())
37
+ out.WriteString("\n")
38
39
if err := scanner.Err(); err != nil {
40
fmt.Fprintln(os.Stderr, "Error reading standard input:", err)
41
os.Exit(2)
42
-
43
+ out.Flush()
44
fmt.Fprintf(os.Stderr, "Total of %d lines. Sampled to %d\n", total, emitted)
45
0 commit comments