[go-nuts] Re: An mistake in tip spec?

2022-01-05 Thread tapi...@gmail.com
Should it be interface{ int | any } // no specific types (intersection is empty) instead On Wednesday, January 5, 2022 at 11:20:16 PM UTC+8 tapi...@gmail.com wrote: > https://tip.golang.org/ref/spec#Structure_of_interfaces > >interface{ int; any } // no specific types (intersection is

[go-nuts] Re: unit testing OS specific code

2022-01-05 Thread Asad Ur Rahman
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 com

[go-nuts] An mistake in tip spec?

2022-01-05 Thread tapi...@gmail.com
https://tip.golang.org/ref/spec#Structure_of_interfaces interface{ int; any } // no specific types (intersection is empty) Why the constraint has no specific types. Doesn't it specify int? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] unit testing OS specific code

2022-01-05 Thread Jan Mercl
On Wed, Jan 5, 2022 at 11:32 AM Brieuc Jeunhomme 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 r

Re: [go-nuts] unit testing OS specific code

2022-01-05 Thread 'Axel Wagner' via golang-nuts
On Wed, Jan 5, 2022 at 11:32 AM Brieuc Jeunhomme 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 re

Re: [go-nuts] unit testing OS specific code

2022-01-05 Thread 'Axel Wagner' via golang-nuts
I'm also confused. On Wed, Jan 5, 2022 at 11:09 AM Brieuc Jeunhomme wrote: > For example, let's say you want to unit test MyFunction, which calls > foo.Bar(chan foo.Baz, chan foo.Foobar) and foo compiles only under a single > OS. If you want to write a portable unit test for MyFunction, you can

Re: [go-nuts] unit testing OS specific code

2022-01-05 Thread Brieuc Jeunhomme
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, i

Re: [go-nuts] unit testing OS specific code

2022-01-05 Thread Jan Mercl
On Wed, Jan 5, 2022 at 11:09 AM Brieuc Jeunhomme wrote: > But here ,since under non-windows platforms, I can't import the package, it > means I have to define wrappers for everything I use: types, constants, > functions. I don't get it. Put the common code in a file/in files with no build cons

Re: [go-nuts] unit testing OS specific code

2022-01-05 Thread Brieuc Jeunhomme
Yes, that's what I wanted to do, but it looks very tedious at best. In "normal" unit tests, it's simple: import the package you're using, inject its functions, reuse its types and constants. But here ,since under non-windows platforms, I can't import the package, it means I have to define wrap