title: How to hide console window of a Go program on Windows
body: <p>I tried various ways of creating a Go program that only displays either a <code>MessageBox</code> or a standalone GUI window.
  If I were to write this in C / C++ I would just define a <a href="https://stackoverflow.com/questions/13871617/winmain-and-main-in-c-extended"><code>WinMain</code></a>, leave out the main and I would be good to go.
  It seems to me that as soon as I define a <code>main</code> function a console window is created automatically. And the main function is compulsory.</p>
  
  <pre><code>package main
  func main() {
  ...
  }
  </code></pre>
  
  <p>To avoid this I tried an <a href="https://github.com/ohisama/win/blob/master/win.go" rel="noreferrer">example</a> which creates a WinMain</p>
  
  <pre><code>func WinMain(wproc uintptr) {
      hInstance := GetModuleHandle(nil)
      ...
  }
  </code></pre>
  
  <p>But the effect is the same: an empty console window <em>and</em> a GUI window:
  <a href="https://i.stack.imgur.com/O8ZTf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/O8ZTf.png" alt="enter image description here"></a></p>