I think the build constraints works with directory names like *'windows'* and *'unix', *tags like *`// +build windows`* or even the source code file name with postfix like *'abc_windows.go' . *All works the same like the build tags. So if you build your package on linux for Windows it will compile but wont be able to run on linux. The Unit tests (like go test . ) does both, it compiles and runs it. May compile the unit tests with command (go test -v -c -o mytests . ). But you still would need windows to run the windows API specific low-level functions.
On Tuesday, January 4, 2022 at 6:30:09 PM UTC+1 bjeun...@gmail.com wrote: > Hi, > > I'm writing code that uses the golang.org/x/sys/windows/svc package. > This package compiles only for windows builds, for other GOOS values, I get > a build error. That's fair, but I'm wondering how to unit test the code > that calls svc functions when working on a non-windows environment. So > code that looks like: > > func myFunction() { > svc.Foo(make(chan svc.Bar)) > } > > Is there a well known way to do that, or am I missing something > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/ecfb18e9-7c70-4147-b26f-a5270239eb34n%40googlegroups.com.