<p dir="auto">fmt doc says: <code class="notranslate">Scanf, Fscanf and Sscanf require newlines in the input to match newlines in the format; the other routines treat newlines as spaces.</code></p>
<p dir="auto">The following program spits out error (should not according to doc):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="package main

import (
    &quot;fmt&quot;
    &quot;log&quot;
)

func main() {
    var a, b int
    _, err := fmt.Sscanf(&quot;1\n2&quot;, &quot;%d %d&quot;, &amp;a, &amp;b)
    if err == nil {
        log.Fatalf(&quot;got - %q, expected - %q&quot;, err, &quot;unexpected newline&quot;)
    }
}
"><pre class="notranslate"><code class="notranslate">package main

import (
    "fmt"
    "log"
)

func main() {
    var a, b int
    _, err := fmt.Sscanf("1\n2", "%d %d", &amp;a, &amp;b)
    if err == nil {
        log.Fatalf("got - %q, expected - %q", err, "unexpected newline")
    }
}

</code></pre></div>
<p dir="auto">on commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/golang/go/commit/335e44d265e7b7741b00237f4fcd97a1b80bfd9a/hovercard" href="https://github.com/golang/go/commit/335e44d265e7b7741b00237f4fcd97a1b80bfd9a"><tt>335e44d</tt></a></p>
<p dir="auto">I got different <code class="notranslate">fmt.Scanf</code> behavior depending on the line endings style.</p>
<p dir="auto">My go version is go1.3.3 darwin/amd64 on a Mac with OSX 10.10</p>
<p dir="auto">To reproduce the problem, here is a short go program:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="package main

import &quot;fmt&quot;

func main() {
    var steps, i int
    fmt.Scanf(&quot;%d&quot;, &amp;steps)

    var a, b int
    for i = 0; i &lt; steps; i++ {
        fmt.Scanf(&quot;%d&quot;, &amp;a)
        fmt.Scanf(&quot;%d&quot;, &amp;b)
        fmt.Println(a + b)
    }
}"><pre class="notranslate"><code class="notranslate">package main

import "fmt"

func main() {
    var steps, i int
    fmt.Scanf("%d", &amp;steps)

    var a, b int
    for i = 0; i &lt; steps; i++ {
        fmt.Scanf("%d", &amp;a)
        fmt.Scanf("%d", &amp;b)
        fmt.Println(a + b)
    }
}
</code></pre></div>
<p dir="auto">And an input file</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2
2 5
4           8"><pre class="notranslate"><code class="notranslate">2
2 5
4           8
</code></pre></div>
<p dir="auto"><code class="notranslate">go run test.go &lt; input</code></p>
<p dir="auto">I expect to see regardless of the line endings been <code class="notranslate">\r\n</code> or <code class="notranslate">\n</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="7
12"><pre class="notranslate"><code class="notranslate">7
12
</code></pre></div>
<p dir="auto">But I see</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2
7"><pre class="notranslate"><code class="notranslate">2
7
</code></pre></div>
<p dir="auto">when in the input file the line endings are <code class="notranslate">\r\n</code> .</p>
<p dir="auto">If the line endings are <code class="notranslate">\n</code> it works fine.</p>