windows10 toast Notification in golang
import (
"github.com/go-toast/toast"
"log"
)
func main() {
notification := toast.Notification{
AppID: "Example App",
Title: "My notification",
Message: "Some message about how important something is...",
Icon: "", // This file must exist (remove this line if no icon is desired)
Actions: []toast.Action{},
}
err := notification.Push()
if err != nil {
log.Fatalln(err)
}
}
or:
func main() {
//注意,这需要你的系统中安装了BurntToast模块
cmd := exec.Command("powershell.exe", "-Command", "New-BurntToastNotification -Text 'Hello, World!'")
err := cmd.Run()
if err != nil {
log.Fatal(err)
}
}