Detect if Code is Running On Windows (at Runtime)
·
136 words
·
1 minute read
On of the advantages of using Go is it’s cross-platform support, the ability to write the code once and have it work across many operating systems. However, there are times when you’ll need to change the route through your code based which OS is running it. If you’re needing to do this on a large scale there are better, more manageable ways, but for tiny changes this works fine.
This snippet uses the GOOS flag within the runtime package, which is also used at compile time.
|
|