//go:build windows package main import ( "syscall" "unsafe" ) // fatalBox shows a message box and returns. // // A GUI-subsystem program has no console: println goes nowhere, and a launch // that ends before the window exists ends in complete silence. Every silent exit // in main now says something here first — an operator who is told "another // OpsLog is already running" can act on it; one who sees nothing files "it does // not start", which is the report nobody can answer. func fatalBox(title, text string) { user32 := syscall.NewLazyDLL("user32.dll") proc := user32.NewProc("MessageBoxW") t, err1 := syscall.UTF16PtrFromString(text) ti, err2 := syscall.UTF16PtrFromString(title) if err1 != nil || err2 != nil { return } const mbIconError = 0x00000010 proc.Call(0, uintptr(unsafe.Pointer(t)), uintptr(unsafe.Pointer(ti)), mbIconError) }