Starting the Notify Package
Explore how to build a Go library that sends system notifications by leveraging OS-specific tools and severity levels. Understand using runtime package to detect the OS and adapt notification formats accordingly for Linux, Windows, and macOS.
We'll cover the following...
Unlike other applications we developed, notify won’t be an executable application. It will be a library that allows us to include system notifications in other applications. We’ll develop a naive but functional implementation that
uses the os/exec package to call external programs that send a system notification. Because notifications vary according to the operating system, this is
a practical example of how to use operating system–specific data and files in
our applications.
Updating the notify.go file
Let’s update the file notify.go. We add the package definition and the import section.
For this file, we’ll use:
- The package
runtimeto check the running operating system. - The