github.com/safing/portbase@v0.19.5/notifications/doc.go (about) 1 /* 2 Package notifications provides a notification system. 3 4 # Notification Lifecycle 5 6 1. Create Notification with an ID and Message. 7 2. Set possible actions and save it. 8 3. When the user responds, the action is executed. 9 10 Example 11 12 // create notification 13 n := notifications.New("update-available", "A new update is available. Restart to upgrade.") 14 // set actions and save 15 n.AddAction("later", "Later").AddAction("restart", "Restart now!").Save() 16 17 // wait for user action 18 selectedAction := <-n.Response() 19 switch selectedAction { 20 case "later": 21 log.Infof("user wants to upgrade later.") 22 case "restart": 23 log.Infof("user wants to restart now.") 24 } 25 */ 26 package notifications