title: Minimum code to create a GUI with button using nuklear package
body: <p>I am trying to trim demo file from <a href="https://github.com/golang-ui/nuklear/blob/master/cmd/nk-example/main.go" rel="nofollow noreferrer">nuklear package</a> to get minimum code for just creating a GUI window with one button. Following is my attempt:</p>
  
  <pre><code>package main
  
  import (
      "log"
      "runtime"
      "time"
  
      "github.com/go-gl/gl/v3.2-core/gl"
      "github.com/go-gl/glfw/v3.2/glfw"
      "github.com/golang-ui/nuklear/nk"
      "github.com/xlab/closer"
  )
  
  const (
      winWidth         = 400
      winHeight        = 500
      maxVertexBuffer  = 512 * 1024
      maxElementBuffer = 128 * 1024
  )
  
  func init() {
      runtime.LockOSThread()
  }
  func main() {
      if err := glfw.Init(); err != nil {
          closer.Fatalln(err)
      }
      glfw.WindowHint(glfw.ContextVersionMajor, 3)
      glfw.WindowHint(glfw.ContextVersionMinor, 2)
      glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
      glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)
      win, err := glfw.CreateWindow(winWidth, winHeight, "Nuklear Demo", nil, nil)
      if err != nil {
          closer.Fatalln(err)
      }
      win.MakeContextCurrent()
  
      width, height := win.GetSize()
      log.Printf("glfw: created window %dx%d", width, height)
  
      if err := gl.Init(); err != nil {
          closer.Fatalln("opengl: init failed:", err)
      }
      gl.Viewport(0, 0, int32(width), int32(height))
  
      ctx := nk.NkPlatformInit(win, nk.PlatformInstallCallbacks)
  
      atlas := nk.NewFontAtlas()
      nk.NkFontStashBegin(&amp;atlas)
      //sansFont := nk.NkFontAtlasAddFromBytes(atlas, MustAsset("assets/FreeSans.ttf"), 16, nil)
      sansFont := nk.NkFontAtlasAddDefault(atlas, 16, nil)
      nk.NkFontStashEnd()
      if sansFont != nil {
          nk.NkStyleSetFont(ctx, sansFont.Handle())
      }
  
      exitC := make(chan struct{}, 1)
      doneC := make(chan struct{}, 1)
      closer.Bind(func() {
          close(exitC)
          &lt;-doneC
      })
  
      state := &amp;State{
          bgColor: nk.NkRgba(28, 48, 62, 255),
      }
      fpsTicker := time.NewTicker(time.Second / 30)
      for {
          select {
          case &lt;-exitC:
              nk.NkPlatformShutdown()
              glfw.Terminate()
              fpsTicker.Stop()
              close(doneC)
              return
          case &lt;-fpsTicker.C:
              if win.ShouldClose() {
                  close(exitC)
                  continue
              }
              glfw.PollEvents()
              gfxMain(win, ctx, state)
          }
      }
  }
  
  func gfxMain(win *glfw.Window, ctx *nk.Context, state *State) {
      nk.NkPlatformNewFrame()
      // Layout
      bounds := nk.NkRect(50, 50, 230, 250)
      update := nk.NkBegin(ctx, "Demo", bounds,
          nk.WindowBorder|nk.WindowMovable|nk.WindowScalable|nk.WindowMinimizable|nk.WindowTitle)
      if update &gt; 0 {
          nk.NkLayoutRowStatic(ctx, 30, 80, 1)
          {
              if nk.NkButtonLabel(ctx, "A_Button") &gt; 0 {
                  log.Println("[INFO] button pressed!")
              }
          }
      }
      nk.NkEnd(ctx)
      // Render
      bg := make([]float32, 4)
      nk.NkColorFv(bg, state.bgColor)
      width, height := win.GetSize()
      gl.Viewport(0, 0, int32(width), int32(height))
      gl.Clear(gl.COLOR_BUFFER_BIT)
      gl.ClearColor(bg[0], bg[1], bg[2], bg[3])
      nk.NkPlatformRender(nk.AntiAliasingOn, maxVertexBuffer, maxElementBuffer)
      win.SwapBuffers()
  }
  
  type Option uint8
  type State struct {
      bgColor nk.Color
      prop    int32
      opt     Option
  }
  </code></pre>
  
  <p>It seems a lot of code to just create a window with a button. I am sure more code can be removed but I can't seem to find it. What further unneeded code can I remove from above to trim it further?</p>