On Wed, Jan 5, 2022 at 11:32 AM Brieuc Jeunhomme <bjeunho...@gmail.com> wrote: > > So: > $ cat mypackage.go > package mypackage > > import "something/something/foo" > > func MyFunction() { > some code > some code > some code > foo.Bar(make(chan foo.Baz), make(chan foo.Foobar)) > } > > Is the code I would really like to write. > > foo has build constraints. As you can see, my code doesn't, it's the exact > thing you recommended: the common code is in mypackage.go, the platform > specific code is in foo (which I don't control, it isn't my code, so I can't > change it). How to unit test MyFunction to verify that it uses foo.Bar > correctly?
If the foo package has build constraints such that it does not build on all targets, so must have the file which imports it. Or it will, transitively, not build on all targets as well. Can you just special-case, ie. add build constraints to the *_test.go files that import the foo package? Seems like a easy solution to me. -- 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/CAA40n-UJ%2BXG%2BPtF-3fd_0DwzAUfJQrww5x3_9%3Dmqua-V_pRg4w%40mail.gmail.com.