-
Notifications
You must be signed in to change notification settings - Fork 1k
Add analyzer and getter for source manager #7
Conversation
This is the minimum amount necessary to get a SourceManager working.
Also worth noting that this does codify a relationship with GOPATH - we add a new dir, |
I'm not sure what the point of getSourceManager is. Either have a singleton and use it or don't. If you have a singleton any setup should be done in |
Totally fair point. I had two reasons for not doing it in some commands - e.g. Second, because |
Hmm...but...that Yeah, I like that better. |
Also LOL i wasn't actually even writing to the |
"github.com/sdboyer/gps" | ||
) | ||
|
||
func getSourceManager() (*gps.SourceMgr, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I call this twice, I assume that I get an error on the second call based on what we discussed in slack?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct. it would be a gps.CouldNotCreateLockError
, which has enough info in it to differentiate from e.g. fs perm problems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So now, you'd have to pick one place that you create the sm, which then is also the point where you have to decide about Release()
ing it.
tbh I would just push all of this into a PR that actually uses it. |
sure, i can do that, too |
Closing in favor of #8 |
Two things in this:
analyzer
, which is the simplest possible implementation of agps.ProjectAnalyzer
. That's the thing that's responsible for pulling manifest and lock data out of dependency projects.gps.SourceManager
, which is going to be needed for all solving operations, and will have quite a number of uses outside of that, as well.I took care in gps to ensure that the default
gps.SourceManager
(*SourceMgr
, returned fromgps.NewSourceManager()
) is completely encapsulated - no package-level state. (There's still some work to be done related to exclusivity controls at the filesystem level, as well as signal handling, but we don't have to care about that right now). That makes it safe to take this dumb approach to setting up our sm.Longer term, though, it'd probably be preferable to inject the sm we use, rather than relying on a global.