Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: allow serving module under the subdirectory of git repository #34055

Open
nhooyr opened this issue Sep 4, 2019 · 9 comments
Open

cmd/go: allow serving module under the subdirectory of git repository #34055

nhooyr opened this issue Sep 4, 2019 · 9 comments

Comments

@nhooyr
Copy link
Contributor

@nhooyr nhooyr commented Sep 4, 2019

If you head to https://github.com/nhooyr/websocket presently, you'll get blasted with a massive root directory listing, mostly due to all the Go files. It's obnoxious.

Compare that to https://github.com/nhooyr/websocket/tree/067b40e227d0d6af9e399c1efe0dd80efae1b79f where the Go module has been moved to the subdirectory ./mod inside the repository.
See nhooyr/websocket#136

So I want to move the Go module to the subdirectory ./mod inside the repository and serve that subdirectory for the nhooyr.io/websocket import path but it doesn't look like there is an easy way to do that.

The go-import meta tag only allows me to specify the import path of the repository, which in this case would make it nhooyr.io/websocket/mod which is nasty. I want to serve the subdirectory directly under nhooyr.io/websocket. Looks like I can do this with the new mod vcs to the go-import tag but then I have to run my own module server which I want to ideally avoid.

Is this something that would be considered or is already possible?

@nhooyr
Copy link
Contributor Author

@nhooyr nhooyr commented Sep 4, 2019

For now I'm redirecting go get to https://github.com/nhooyr/websocket-mod where I've moved the module to the root of the repository. Unideal for sure but works well for now.

@nhooyr
Copy link
Contributor Author

@nhooyr nhooyr commented Sep 4, 2019

I might also just switch to moving the real code into the subdir mod but have a package in the root that uses type aliases to alias directly to the mod subpkg. Would involve some duplicate code and be harder to maintain though.

@nhooyr
Copy link
Contributor Author

@nhooyr nhooyr commented Sep 4, 2019

So unfortunately people were getting confused that the mod path didn't resolve directly to the root of the repo and I tried the type alias thing but in the docs it links directly to the other package instead of inlining the docs so I'd have a decent amount of duplication if I copied the types and translated between them.

@katiehockman
Copy link
Member

@katiehockman katiehockman commented Sep 4, 2019

It's unclear what bug is being raised in this issue and/or what proposal to the go command is being suggested. I'm going to close this bug, but check out https://github.com/golang/go/wiki/Questions as it may provide a good avenue to continue this discussion.

@nhooyr
Copy link
Contributor Author

@nhooyr nhooyr commented Sep 5, 2019

Apologies for the confusion. To clarify, I'm trying to serve a subdir of my repository https://github.com/nhooyr/websocket under the import path nhooyr.io/websocket but this doesn't seem feasible with the current tooling without my own module proxy and event then GoDoc wouldn't work as it doesn't support modules yet.

@nejtr0n
Copy link

@nejtr0n nejtr0n commented Feb 25, 2020

I've got same issue. I have project with migrations, protobuf files and other infrastracture files.
So I decide to put my project under
https://vcs/vendor/project/src/.
But i could not import in go modules.

@jwinnie
Copy link

@jwinnie jwinnie commented Jul 21, 2020

I have the same issue. @katiehockman Please reopen, this is a legitimate issue that a lot of people are experiencing.

A brief proposal to fix the issue would be to add an optional fourth parameter to go-import, so if you wanted to specify a subdirectory you could do something like this:

<meta name="go-import" content="nhooyr.io/websocket git https://github.com/nhooyr/websocket mod">

This would import the mod subdirectory of the github.com/nhooyr/websocket git repository.

@katiehockman katiehockman reopened this Jul 21, 2020
@katiehockman
Copy link
Member

@katiehockman katiehockman commented Jul 21, 2020

@bcmills
Copy link
Member

@bcmills bcmills commented Jul 21, 2020

See previously #33562.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.