Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Is it possible to add explicit dependencies manually? #364

Closed
nathanielc opened this issue Apr 4, 2017 · 1 comment
Closed

Is it possible to add explicit dependencies manually? #364

nathanielc opened this issue Apr 4, 2017 · 1 comment

Comments

@nathanielc
Copy link
Contributor

Maybe this isn't a use case that dep should support but I have on a several occasions vendored the deps of utilities need to run go generate . This allows the build process to install the utility from the vendored directory before running go generate. As such the complete build chain is vendored instead of just the dependencies needed to run go build.

I attempted to do something similar with dep but was unsuccessful. I tired a few things like manually editing manifest files or adding overrides for nonexistant dependencies but nothing I tried worked. I even manaully checked out the code to the vendor dir but then dep removed it later during an ensure operation.

Is there a way to manually add explicit dependencies that are not imported by the source files? If not would you consider adding such a feature?

@sdboyer
Copy link
Member

sdboyer commented Apr 4, 2017

hi, excellent question! (especially because i get to say "yes" 😄)

yes! you can do this now. it's just not documented, because of the peculiar path that development was taken (we had a way that we were planning to introduce this, but now #277 has us changing course). but, if you add a required section to your manifest.json, e.g.:

"required": [
    "github.com/foo/bar",
    "github.com/path/to/pkg",
]

(note that, unlike the dependencies section, this is a list of packages, not projects.)

now, those packages will be included/required in your lock & vendor as though you'd imported them. and, specifically germane to your case, you can name main packages in the required list, without any errors arising from importing a main.

there's still the issue of actually being able to compile something from within vendor, but...well, one thing at a time :)

(note - this is also all discussed in #221)

@sdboyer sdboyer closed this as completed Apr 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants