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

x/vgo: allow "vgo vendor" to fill in vendor dir in subdir of module root #24237

Closed
the42 opened this issue Mar 4, 2018 · 3 comments

Comments

@the42
Copy link

commented Mar 4, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

Linux amd64

What did you do?

vgo vendoroutside module root

If I call vgo vendor in a subdirectory of a module, the vendor directory is still created in the module root (where go.mod is located). This is certainly intentionally. However, in the case of go command, I might be interested to create a vendor directory just for a command, located in a subdirectoy of a package and module root, eg. to be self-contained for Dockerizing

What did you expect to see?

What did you see instead?

@gopherbot gopherbot added this to the vgo milestone Mar 4, 2018

@tv42

This comment has been minimized.

Copy link

commented Mar 6, 2018

@the42 But if you were to create the vendor dir in a subdirectory, the resulting build would behave differently from vgo. Perhaps what you need is to make the command(s) their own module?

@the42

This comment has been minimized.

Copy link
Author

commented Mar 6, 2018

Ok, I tried the following:
package (go.mod)
\cmd\service\main.go (here I also created an empty go.mod)

(note: nested go.mod for the command within a go.mod for the package root / module root)

when I run vgo vendor inside package (module root) a vendor directory is created
when I run vgo build ... inside package (module root) the package and the cmd\service gets built

After vgo build ... the contents of package/cmd/service/go.mod becomes

module "github.com/the42/badge"

however no require directives get written. If I execute vgo build inside package/cmd/service I get the following error message:

can't load package: import cycle not allowed
package github.com/the42/badge
imports github.com/the42/badge
import cycle not allowed
package github.com/the42/badge
imports github.com/the42/badge

Also vgo vendor inside package/cmd/service fails with

vgo vendor: open /home/john/src/gocode/src/github.com/the42/badge/cmd/service/vendor/vgo.list: no such file or directory

I guess you meant to completely separate the package from the command, but that way it's no longer nicely encapsulated

@rsc rsc changed the title x/vgo: Support vendor directories outside module root x/vgo: allow "vgo vendor" to fill in vendor dir in subdir of module root Mar 27, 2018

@rsc

This comment has been minimized.

Copy link
Contributor

commented Mar 27, 2018

I don't think we're going to do this. The module defines a set of code versions that apply to the whole modules, not to just one subdirectory. "vgo vendor" is about freezing everything for the module, not just one command. The right place for the vendor dir really is the module root, not piecemeal within the module tree.

@rsc rsc closed this Mar 27, 2018

@golang golang locked and limited conversation to collaborators Mar 27, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants
You can’t perform that action at this time.