title: ioutils.WriteFile() not respecting permissions
body: <p>I'm trying to use ioutils.WriteFile() but for some reason it's ignoring the 0777 permissions I'm giving it.</p>
  
  <pre><code>package main
  
  import (
      "io/ioutil"
      "os"
  )
  
  func main() {
  
      // normal permissions
      if err := ioutil.WriteFile("cant-touch-this-0644", []byte{}, 0644); err != nil {
              panic(err)
      }
  
  
      // full permissions
      if err := ioutil.WriteFile("cant-touch-this-0777", []byte{}, 0777); err != nil {
              panic(err)
      }
  
  
      // normal permissions + chmod to full
      if err := ioutil.WriteFile("cant-touch-this-mixed", []byte{}, 0755); err != nil {
              panic(err)
      }
  
      if err := os.Chmod("cant-touch-this-mixed", 0777); err != nil {
              panic(err)
      }
  }
  </code></pre>
  
  <p>The output I get from this is:</p>
  
  <pre><code>$ ls -l
  -rw-r--r--  1 edson edson    0 May  9 17:19  cant-touch-this-0644
  -rwxr-xr-x  1 edson edson    0 May  9 17:19  cant-touch-this-0777
  -rwxrwxrwx  1 edson edson    0 May  9 17:19  cant-touch-this-mixed
  </code></pre>
  
  <p>Which means:</p>
  
  <ul>
  <li>The first scenario (0644) worked</li>
  <li>The second (0777) was ignored</li>
  <li>The only way I can get full 0777 permissions is by using a <code>os.Chmod</code> (like in the third scenario)</li>
  </ul>
  
  <p>What am I doing wrong?</p>