Including OS-Specific Files in the Build
Explore the process of implementing a notification sending method for various operating systems.
Overview
Using runtime.GOOS
to verify the current operating system is a practical way to
include OS-specific parameters and data in our application. But it’s not a good approach to include larger pieces of code because doing so might lead to convoluted code and it might not be possible in some cases to redefine the code within the condition block.
In these cases, we can use build constraints, also known as build tags, which are a mechanism that lets us include and exclude files from our build and our tests according to different criteria.
Get hands-on with 1200+ tech skills courses.