How to go-imports subdirectory?

263 views
Skip to first unread message

tomas...@showmax.com

unread,
Jun 8, 2020, 1:00:01 PM6/8/20
to golan...@googlegroups.com
Hello,

given repository structured as

+ $ tree .
.
├── foo
└── go
├── go.mod
└── main.go

1 directory, 3 files

I'm trying to setup go-import meta tag for it, however it just does not
seem to work. Meta tag looks like this:

<meta name="go-import" content="example.org/ git ssh://git@HOST:PORT/foo.git/go" />

It is correctly resolved to the repository, the repository is
downloaded, however the resulting pkg directory does not contain the go
directory at all. I've tracked it down to golang.org/x/mod/zip, which
seems to exclude every subdirectory with go.mod.

So I guess I need to somehow convince git to package just the go
directory (and move it one level up), but looking at
src/cmd/go/internal/modfetch/codehost/git.go:828 I do not see a way to
do it.

I assume what I'm trying to do should be possible, since it does not
sound like such a insane use-case, but I'm just not able to find a way
to do this. Could someone please point me in the right direction?

I'm using go 1.14.4 ( go version go1.14.4 linux/amd64 ).



Thank you in advance for any advice on this,

Tomas Volf

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
signature.asc

Tamás Gulácsi

unread,
Jun 9, 2020, 12:33:06 AM6/9/20
to golang-nuts
Can't you move the go.mod one level up, into the root?

Tomas Volf

unread,
Jun 9, 2020, 12:24:53 PM6/9/20
to golang-nuts


On Tuesday, June 9, 2020 at 4:33:06 AM UTC, Tamás Gulácsi wrote:
Can't you move the go.mod one level up, into the root?

But that would mean all imports paths would have the `/go` in them,
no?

Tamás Gulácsi

unread,
Jun 9, 2020, 11:23:00 PM6/9/20
to golang-nuts
Yes. But then you could use go get to import it.
Reply all
Reply to author
Forward
0 new messages