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 ... 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://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 TestEmbedFiles is also present in the generated `pkg.test` package 
>> and the pkg [pkg.test] package.
>>
>> Thanks
>> Manlio
>>
>>
>> On Wednesday, June 2, 2021 at 4:23:32 AM UTC+2 nikolay.d...@gmail.com 
>> wrote:
>>
>>> 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 different
>>> - b) if you have `mypkg_test.go` and in it `pakcage mypkg` then... less 
>>> clear. As above referenced in original docs `_test.go` will be excluded 
>>> from non test build regardless of package.
>>>
>>> My personal take, is to go:embed only in case a).
>>>
>>> Cheers,
>>> On Wednesday, June 2, 2021 at 8:09:20 AM UTC+8 peterGo wrote:
>>>
>>>> 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 the test binary.
>>>>>
>>>>> Thanks
>>>>> Manlio
>>>>>
>>>>
>>>> The documentation seems clear to me.
>>>>
>>>> Package testing
>>>> https://golang.org/pkg/testing/
>>>>
>>>> To write a new test suite, create a file whose name ends _test.go that 
>>>> contains the TestXxx functions as described here. Put the file in the same 
>>>> package as the one being tested. The file will be excluded from regular 
>>>> package builds but will be included when the "go test" command is run. 
>>>>
>>>> Peter
>>>>
>>>

-- 
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/6894ae4e-7a2b-411c-a86a-d1401b149ff3n%40googlegroups.com.

Reply via email to