title: How to control file access in Windows?
body: <p>Go provides <a href="https://golang.org/pkg/os/#Chmod" rel="noreferrer"><code>os.Chmod()</code></a> for setting file and directory permissions. For example, if I want to ensure a file is accessible only to the current user, I can do the following:</p>
  
  <pre><code>os.Chmod("somefile.txt", 0600)
  </code></pre>
  
  <p>This works great on Linux but does absolutely nothing on Windows. After digging into the Go source code, I came across <a href="https://golang.org/src/syscall/syscall_windows.go#L520" rel="noreferrer">its implementation</a>. It seems like <code>S_IWRITE</code> is the only attribute supported.</p>
  
  <p>How do I control access to a file or directory on Windows using Go?</p>