title: multiline input in a terminal Go application
body: <p>I need to let a user input multiline text to the console.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>package main
  
  import (
      "bufio"
      "fmt"
      "os"
  )
  
  func main() {
      for {
          fmt.Println("How to read all lines here?")
          in := bufio.NewReader(os.Stdin)
          result, err := in.ReadString('\n')
          if err != nil {
              fmt.Println(err)
          }
          fmt.Println("\nresult")
          fmt.Println(result)     
  
      }
  }
  </code></pre>
  
  <p>I pasted in the console:</p>
  
  <pre><code>    Hello
      World
  </code></pre>
  
  <p>It outputs:</p>
  
  <pre><code>How to read all lines here?
  
          Hello
          World
  
  
  result
  
  
  How to read all lines here?
  
  result
          Hello
  
  How to read all lines here?
  
  result
          World
  
  How to read all lines here?
  
  result
  
  
  How to read all lines here?
  </code></pre>
  
  <p>But I expect it to be:</p>
  
  <pre><code>         How to read all lines here?
  
                  Hello
                  World
  
  
          result
  
  
          How to read all lines here?
  
          result
                  Hello
                  World
  
          How to read all lines here?
  </code></pre>
  
  <p>I guess I need to use something like <code>EOF</code> instead of <code>'\n'</code>
   But how to do it exactly?</p>
  
  <h1>Update</h1>
  
  <p>peterSo's answer works except in case when I am trying to paste from clipboard a text with one or more empty lines in-between, like:</p>
  
  <pre><code>Hello
  
  World
  </code></pre>
  
  <p>It prints</p>
  
  <pre><code>Enter Lines:
  Hello
  
  WorldResult:
  Hello
  
  Enter Lines:
  </code></pre>
  
  <h1>Update 2</h1>
  
  <p>The great updated peterSO's answer now works even for text with empty lines.</p>