Comment

Comment by microtonal

    bytes, _ := ioutil.ReadAll(os.Stdin)
    lines := strings.Split(string(bytes), "\n")
Tip: use bufio.Scanner.

    scanner := bufio.NewScanner(reader)
    scanner.Split(bufio.ScanLines)
    for scanner.Scan() {
      // Do stuff
    }
And you can iterate over the lines 'lazily'. If you don't want to consume \r's, make your own ScanLines :).
parent microtonal 11 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton