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

ensure: provide a way to remove unwanted entries from Gopkg.toml #1470

Closed
rogpeppe opened this issue Dec 21, 2017 · 6 comments
Closed

ensure: provide a way to remove unwanted entries from Gopkg.toml #1470

rogpeppe opened this issue Dec 21, 2017 · 6 comments

Comments

@rogpeppe
Copy link

When I remove a dependency from a project, I'd like all unwanted entries
in Gopkg.toml to go away ASAP. I don't see that there's a way to do that currently
without manually checking each dependency.

It's perhaps arguable that dep ensure -add could do this automatically, as it may well be what most people want most of the time, although that doesn't fit very well with the name "add".

Perhaps:

dep ensure -constraints

might work for ensuring that both Gopkg.toml and Gopkg.lock are up to date.
Alternatively, dep init could be made to work with existing Gopkg.toml and Gopkg.lock files.

@sdboyer
Copy link
Member

sdboyer commented Dec 21, 2017

#302 - I know, embarrassingly old - is about adding warnings for ineffectual items. it's won't be automated, but at least you don't have to figure out what to remove yourself.. would you consider that good enough?

@rogpeppe
Copy link
Author

I'd prefer there to be a way of doing it automatically. Much like Go import statements, I'm not sure that it's ever appropriate to have repos mentioned that aren't used.

@cmcginty
Copy link

Is the only workaround to manually edit the Gopkg file?

@sdboyer
Copy link
Member

sdboyer commented Dec 29, 2017

@cmcginty yes.

@rogpeppe huh. yknow, I've never thought of those being directly analogous in quite that way before, but it's a really interesting parallel, now that you make it.

unfortunately, our hands are rather tied with respect to doing this in an automated way, as that would entail rewriting the Gopkg.toml file - and we can't currently do that while also preserving comments.

@rogpeppe
Copy link
Author

@sdboyer I wondered if that was the case. I wonder how hard it would be to be able to preserve comments when rewriting TOML. A few different possible approaches come to mind. (Aside: it's for reasons like this that I respect the JSON decision to omit comments from the spec.)

@sdboyer
Copy link
Member

sdboyer commented Dec 30, 2017

to be clear, this was an intentional choice - TOML having comments was an essential part of the design, and we made certain sacrifices to allow it - including the possibility of things like this.

however, if a comment-preserving TOML implementation were to appear, I'd be down with revisiting things like this in a heartbeat. in the meantime, though, automated trimming would best be implemented as a standalone tool. shouldn't be too difficult to do.

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

4 participants