17

Golang在Windows上弹出通知

 2 years ago
source link: https://studygolang.com/articles/35224?fr=sidebar
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Golang在Windows上弹出通知

jiqing112 · 大约13小时之前 · 163 次点击 · 预计阅读时间 1 分钟 · 大约8小时之前 开始浏览    
package main

import (
	"github.com/go-toast/toast"
	"log"
)

func main() {
	notification := toast.Notification{
		AppID:   "Microsoft.Windows.Shell.RunDialog",
		Title:   "大佬",
		Message: "只是一个通知",
		Icon:    "C:\\path\\to\\your\\logo.png", // 文件必须存在
		Actions: []toast.Action{
			{"protocol", "按钮1", "https://www.google.com/"},
			{"protocol", "按钮2", "https://github.com/"},
		},
	}
	err := notification.Push()
	if err != nil {
		log.Fatalln(err)
	}
}



有疑问加站长微信联系(非本文作者)

280

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:701969077


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK