title: Golang to redirect fmt.Scanf to read from file instead of os.Stdin
body: <p>Normally when we call <code>fmt.Scanf()</code> in Golang, the program will read from standard input stream i.e. <code>os.stdin</code></p>
  
  <p>I want, by Golang code, to make <code>fmt.Scanf()</code> to reading from a file stream - similarly to a <a href="https://stackoverflow.com/a/39482389/248616">technique in Python here</a>.</p>
  
  <p>Please note that we have the piping workaround at command line level; here I'm looking for in-Golang code solution.</p>
  
  <p>If you know how to get there, please share.</p>
  
  <p>p.s.</p>
  
  <p>I guess it requires us to</p>
  
  <ul>
  <li>read from file stream and store in a string variable <code>bytes</code></li>
  <li>assign <code>bytes</code> to <code>os.stdin</code> stream </li>
  </ul>
  
  <p>Though I'm a Golang newbie and my <a href="https://www.google.com.vn/search?newwindow=1&amp;biw=1855&amp;bih=965&amp;q=golang+redirect+fmt.Scanf+to+read+from+file+instead+of+os.stdin&amp;oq=golang+redirect+fmt.Scanf+to+read+from+file+instead+of+os.stdin&amp;gs_l=psy-ab.3...117763.129164.0.129422.35.33.0.0.0.0.370.3709.5j18j3j1.27.0....0...1.1.64.psy-ab..9.5.732...0i7i30k1j33i21k1j33i160k1.0.hd_2NcoGc08" rel="nofollow noreferrer">google search</a> is not very helpful so I asked here.</p>