It’s an absolute nightmare to publish modules from subdirectories. I gave
up for ANTLR and created a new repo with the source code in the root
directory.

But the art is that you need to create a tag named with the subdirectory. I
was able to make that work until we needed a v{n} tag. Which as far as I
can tell, just doesn’t work.

I found that go get will duplicate the entire repo anyway, will create a
pseudo tag from the commit, will download after every commit anyway, even
if the go source wasn’t updated, and neither was the tag… the list goes
on.  I looked at the source code for this part of go - it seems the authors
wrestle with this on every release. There are open issues around it too. I
can see how hairy the issues are and I am surprised this does not come up
more often - when I first asked here about it, it was crickets all the way
to the bottom. Also, the import will need to have your subdirectories in
the path, which looks a bit wonky even if it works.

So basically. Don’t do this as you are doing it, even though, on paper, go
does not impose any particular structure on your repo beyond a few basic
things such as excluding testdata, internal, and so on.

Keep your go source at the root of the repo and tag that. If you have a
choice, keep non-go artifacts in another repo, otherwise place that code in
sub-directories, not the go code.

If you have not created a tag, the go will create a pseudo version for you,
which is its default. That’s ok, but it’s difficult to know what source
level you are at from the git commit hash.

I recommend using git flow methodology to make this stuff easier, though
there is nothing forcing you to do so of course.




On Fri, Sep 15, 2023 at 08:34 Lenny Kneller <lennyknel...@gmail.com> wrote:

> Hi Bruno,
>
> This command works `github.com/flatgeobuf/flatgeobuf/src/go@master`
> <http://github.com/flatgeobuf/flatgeobuf/src/go@master>.
> I wonder if `@master` is needed because the repo has no packages published?
> There's more info about pseudo-versions here
> <https://go.dev/ref/mod#pseudo-versions>
>
> -Lenny-
>
> On Thursday, September 14, 2023 at 5:59:39 PM UTC-4 Bruno Albuquerque
> wrote:
>
>> It is likely that I am doing something stupid but as I am out of ideas,
>> here goes nothing.
>>
>> I pushed an initial Go flatgeobuf implementation here:
>>
>> github.com/flatgeobuf/flatgeobuf/src/go
>>
>> This directory in the repository has a go.mod file with the following
>> contents:
>>
>> module github.com/flatgeobuf/flatgeobuf/src/go
>> go 1.20
>> require github.com/google/flatbuffers v22.11.23+incompatible
>>
>> Just in case it might be relevant, the actual repository is
>> github.com/flatgeobuf/flatgeobuf, src/go is a subdirectory there.
>>
>> If I try to use this module, it fails. For example:
>>
>> # go get -u github.com/flatgeobuf/flatgeobuf/src/go
>> go: downloading github.com/flatgeobuf/flatgeobuf
>> v0.0.0-20230914202020-25c11d75fe28
>> go: module github.com/flatgeobuf/flatgeobuf@upgrade found
>> (v0.0.0-20230914202020-25c11d75fe28), but does not contain package
>> github.com/flatgeobuf/flatgeobuf/src/go
>>
>> What am I missing?
>>
>> -Bruno
>>
>> --
> 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/98b7c5b7-5d5b-4a84-8237-b099dd623a53n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/98b7c5b7-5d5b-4a84-8237-b099dd623a53n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAGPPfg-YT%2BQ4B1R3Wyj%2BQqcfHyeiTJErnZwVKWhMy1%3DzhCQJgg%40mail.gmail.com.

Reply via email to