title: golang scan a line of numbers from sdin
body: <p>I'm trying to read input from stdin like</p>
  
  <pre><code>3 2 1&lt;ENTER&gt;
  </code></pre>
  
  <p>and save it in a list of ints. At the moment my code looks like this:</p>
  
  <pre><code>nums = make([]int, 0)
  var i int
  for {
      _, err := fmt.Scan(&amp;i)
      if err != nil {
          if err==io.EOF { break }
          log.Fatal(err)
      }
      nums = append(nums, i)
  }
  </code></pre>
  
  <p>at the moment the program never leaves the for-loop. I can't find an easy way to check for a newline character in the documentation. how would i do this?</p>
  
  <p>Edit:</p>
  
  <p>Since I know that there will almost certainly be four numbers, I tried the following:</p>
  
  <pre><code>var i0,i1,i2,i3 int
  fmt.Scanf("%d %d %d %d\n", &amp;i0, &amp;i1, &amp;i2, &amp;i3)
  </code></pre>
  
  <p>but this only scanned the first number and then exited the program. I'm not sure if that's because of the z-shell I'm using.</p>
  
  <p>Edit:</p>
  
  <p>To clarify, the program will pause and ask for the user to input a list of n numbers separated by spaces and terminated with a newline. these numbers should be stored in an array.</p>