You can see how the different runtime.GOOS values are defined in the OS-specific runtime files like https://github.com/golang/go/blob/master/src/runtime/internal/sys/zgoos_windows.go. They happen to be lowercase, but I don't know anything that guarantees that in any future.
Curious though, why does it matter if you import the strings package for a single check? That's surprising to me. On Mon, Aug 7, 2017 at 2:00 PM, Eric Brown <edb1...@gmail.com> wrote: > This may be a completely stupid or trivial question; however... > > I currently use this on some old code I'm working on and trying to clean > things up: > > switch os := strings.ToLower(runtime.GOOS); os { > case "windows": > // do windows stuff here > case "linux": > // do linux stuff here > > default: > // do default stuff here > > } > > > I hate to import the entire strings package just to ensure that switch > will work. Does anybody know if runtime.GOOS will always return a > lowercase value so I don't have to import the strings package just for this > single check? All I can find is that GOOS returns (sys > <https://golang.org/pkg/runtime/internal/sys/>.GOOS > <https://golang.org/pkg/runtime/internal/sys/#GOOS>)... > I'd rather be safe than sorry. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.