Re: [go-nuts] possible inconsistency in the embed package documentation

2021-01-23 Thread Manlio Perillo
Il giorno venerdì 22 gennaio 2021 alle 20:02:02 UTC+1 dmit...@golang.org ha scritto: > > Consider the case where example.com/m1/nested is not a separate module. > > Due to the rule of "Patterns must not contain ‘.’ or ‘..’ path > elements", the nested package can not embed, as an example, the LI

Re: [go-nuts] possible inconsistency in the embed package documentation

2021-01-22 Thread Dmitri Shuralyov
> Consider the case where example.com/m1/nested is not a separate module. > Due to the rule of "Patterns must not contain ‘.’ or ‘..’ path elements", the nested package can not embed, as an example, the LICENSE file from the example.com/m1 package. > The LICENSE file is not outside the nested pac

Re: [go-nuts] possible inconsistency in the embed package documentation

2021-01-17 Thread Manlio Perillo
Thanks for the clarification. The goal was to understand the embedding better. I have another question. Consider the case where example.com/m1/nested is not a separate module. Due to the rule of "Patterns must not contain ‘.’ or ‘..’ path elements", the nested package can not embed, as an examp

Re: [go-nuts] possible inconsistency in the embed package documentation

2021-01-16 Thread 'Axel Wagner' via golang-nuts
In general, embedding files from directories starting with dot ("hidden directories") works fine. But you must take care, to either mention the hidden directory explicitly, or the file you want to exclude, as otherwise, the hidden directory will be skipped by embed (see https://github.com/golang/go

Re: [go-nuts] possible inconsistency in the embed package documentation

2021-01-16 Thread Dmitri Shuralyov
It gets pretty subtle. The ".git" directories aren't included in module zips by the go command (I don't know if this is documented anywhere, but it's very sensible behavior), but they aren't disallowed. A custom module zip may include a ".foo", "_foo", or even ".git" directory with files. In th

Re: [go-nuts] possible inconsistency in the embed package documentation

2021-01-16 Thread Manlio Perillo
https://golang.org/ref/mod#zip-path-size-constraints prevents directories that begin with a dot, but only because the directory is interpreted as a package. It is not clear, to me, if `.git` is ignored by the `embed` directive because it is the private directory of the VCS or because it starts w

Re: [go-nuts] possible inconsistency in the embed package documentation

2021-01-16 Thread Dmitri Shuralyov
Directories named testdata are included in the module; they're needed for tests to run. The most important thing that's left out are subdirectories that contain a go.mod file, since the content of such directories is a different module. Some good places to look for full details include https:/

Re: [go-nuts] possible inconsistency in the embed package documentation

2021-01-16 Thread 'Axel Wagner' via golang-nuts
I think this is the best doc about what is included in a module: https://golang.org/ref/mod#zip-path-size-constraints Everything not in that list is "outside" that module. On Sat, Jan 16, 2021 at 9:02 PM Manlio Perillo wrote: > Thanks. I was only considering the parent of the module's root dire

Re: [go-nuts] possible inconsistency in the embed package documentation

2021-01-16 Thread Manlio Perillo
As an example: is testdata outside the package's module? Thanks Manlio Il giorno sabato 16 gennaio 2021 alle 21:02:25 UTC+1 Manlio Perillo ha scritto: > Thanks. I was only considering the parent of the module's root directory. > Is the concept of "outside the module" defined somewhere? > > Man

Re: [go-nuts] possible inconsistency in the embed package documentation

2021-01-16 Thread Manlio Perillo
Thanks. I was only considering the parent of the module's root directory. Is the concept of "outside the module" defined somewhere? Manlio Perillo Il giorno sabato 16 gennaio 2021 alle 19:30:05 UTC+1 axel.wa...@googlemail.com ha scritto: > To put it another way: > > The second phrase is a lex

Re: [go-nuts] possible inconsistency in the embed package documentation

2021-01-16 Thread 'Axel Wagner' via golang-nuts
To put it another way: The second phrase is a lexical requirement about the pattern. It must not contain a . or .. element - whether or not the result is included in the module (e.g. "foo/../foo/bar" is not allowed either, even though it's equivalent to "foo/bar"). But, a lexical path *in* the mo

Re: [go-nuts] possible inconsistency in the embed package documentation

2021-01-16 Thread 'Axel Wagner' via golang-nuts
I don't think they do. There are two examples in the first phrase, which are not excluded by the second - the ".git" directory and a symbolic link (pointing outside of the module). On Sat, Jan 16, 2021 at 7:11 PM Manlio Perillo wrote: > I'm reading the https://tip.golang.org/pkg/embed/ package d

[go-nuts] possible inconsistency in the embed package documentation

2021-01-16 Thread Manlio Perillo
I'm reading the https://tip.golang.org/pkg/embed/ package documentation and I found a possible inconsistency. At the end of https://tip.golang.org/pkg/embed/#hdr-Directives: "Patterns must not match files outside the package's module, such as ‘.git/*’ or symbolic links" and "Patterns must not co