there are several Go packages that wrap the Windows GDI functions in a more idiomatic and less verbose interface. Here are some of the better options for creating a chess GUI:
- Fyne: A cross-platform GUI toolkit that works on Windows and abstracts away the low-level details:
fyne-io/fyne: Cross platform GUI toolkit in Go inspired by Material Design @GitHub
- Walk: A Windows-specific GUI toolkit for Go that provides native Windows GUI capabilities:
lxn/walk: A Windows GUI toolkit for the Go Programming Language @GitHub
- Gio: A cross-platform GUI library with immediate mode rendering:
Gio UI
- Ebiten: More game-focused but excellent for something like chess:
even without packages, Go can access Windows (and other OS) GUI features
Here is a super-simple but functional Go GUI "Hello World" program.
package main
import (
"syscall"
"unsafe"
)
var (
user32 = syscall.NewLazyDLL("user32.dll") // Loads the user32.dll library dynamically
messageBoxA = user32.NewProc("MessageBoxA") // Gets a reference to the MessageBoxA function
)
func main() {
messageBoxA.Call(
0, // NULL for the parent window handle
uintptr(unsafe.Pointer(syscall.StringBytePtr("world!"))), // message text
uintptr(unsafe.Pointer(syscall.StringBytePtr("Hello"))), // title
0, // type of message box, default
)
}