Including OS-Specific Data
Each one of the tools you’re using to send the system notification has a different requirement for the notification severity. For example, on Linux notify-send expects severities as low, normal, or critical, while on Windows your script defines the type of icons such as Info, Warning, or Error. Finally, terminal-notifier on macOS doesn’t use severities so you’ll display the notification as text with the notification title.
The users of your package define the severity using a constant value of the Severity type. Let’s write a method String that converts the value to a string representation according to each tool’s specific requirements based on the running operating system.
In Go, you can use the runtime package to ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access