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)
        }
}

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Captcha Code