[go-nuts] Re: embedding files in tests

2021-06-03 Thread Manlio Perillo
Actually, if a file is embedded in the main package, go list will report it in the EmbedFiles field. If a file is embedded in a test, the -test flag is required because the test binary is required. Regards Manlio On Wednesday, June 2, 2021 at 5:56:42 PM UTC+2 peterGo wrote: > "it seems a bug .

[go-nuts] Re: embedding files in tests

2021-06-02 Thread peterGo
"it seems a bug ... it should" Why? Why perform unnecessary disk directory I/O for a build to discover which files satisfy the patterns for a test? Go tools are expected to be fast. Peter On Wednesday, June 2, 2021 at 5:49:41 AM UTC-4 manlio@gmail.com wrote: > Here is an example: https://

[go-nuts] Re: embedding files in tests

2021-06-02 Thread Manlio Perillo
Here is an example: https://play.golang.org/p/ElnTtxHnF5I The output of `go list -json ./pkg` only reports `TestEmbedPatterns`. The output of `go list -json -test ./pkg` reports TestEmbedFiles for the pkg package (it seems a bug, since it should also be reported without the -test flag). The Tes

[go-nuts] Re: embedding files in tests

2021-06-01 Thread Nikolay Dubina
I think the question is about `go:embed` directive in `_test.go` files will be included in builds of non-test packages, right? Don't know for sure, but I think: - a) if you have `mypkg_test.go` and in it `package mypkg_test` then `go:embed` will not get to your non test build as the package is d

[go-nuts] Re: embedding files in tests

2021-06-01 Thread peterGo
On Tuesday, June 1, 2021 at 9:17:11 AM UTC-4 manlio@gmail.com wrote: > When a file is embedded in a test file, will the file be embedded only in > the test binary? > The documentation says nothing about this case, but the data from go list > seems to confirm that the file is only embedded in

[go-nuts] Re: embedding files in tests

2021-06-01 Thread jake...@gmail.com
I would strongly assume that the file is only embedded in the test binary. In fact it is hard to imagine a design where it would not be that way. If you really want to make sure, you could easily build two, identical binaries, that differ only in that a very large file is embedded in the test f