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
GO LIST JSON? WHY NOT!? #150
Conversation
…ne swoop, and also handle replace for json
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.
LGTM!
Just a question though, does this mean parse.GoList
is no more?
@MichelKazi yep! We would remove that (or rename the other to |
if mod.Replace != nil { | ||
if mod.Replace.Version == "" { | ||
err = &NoVersionError{err: fmt.Errorf("No version found for mod")} | ||
return | ||
} | ||
dep.Name = mod.Replace.Path | ||
dep.Version = mod.Replace.Version | ||
return | ||
} |
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.
Since #142 called this out as an issue i think we should add a test around it to make sure it is working as expected.
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.
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.
My bad i should have been more clear :) that just handles replace
for go list
and not go list -json
. We should probably have a replace test for the json path too.
{
"Path": "github.com/gorilla/websocket",
"Version": "v1.4.0",
"Replace": {
"Path": "github.com/gorilla/websocket",
"Version": "v1.4.2",
"Time": "2020-03-19T17:50:51Z",
"GoMod": "/Users/ME/go/pkg/mod/cache/download/github.com/gorilla/websocket/@v/v1.4.2.mod"
},
"Update": {
"Path": "github.com/gorilla/websocket",
"Version": "v1.4.2",
"Time": "2020-03-19T17:50:51Z"
},
"Indirect": true,
"GoMod": "/Users/ME/go/pkg/mod/cache/download/github.com/gorilla/websocket/@v/v1.4.2.mod"
}
One of those testdata files but with that and maybe another in it.
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.
In: 64079e0
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.
Code looks good to me....probably need to update the README too. And add something to the extent that you will get better results if you use go list -m -json
@zendern , README updated! |
This PR handles:
go list -m all
andgo list -json -m all
commands piped in to NancyI went with this approach as the Go Mod list command stuff is all internal. I've copied the struct for
Module
however, and trimmed it down for now to the fields we likely will ever need.The approach I took was to:
[]byte
, as I don't anticipate it being TOO big (I tried at first to do this by buffering it, but the code was getting extremely complicated for something that should never be like, massive in memory footprint)[]byte
as json. If it errors, break the loop, if it doesn't, return everything, GREAT!This new method
GoParseAgnostic
takes anio.Reader
as well, so that we can test it a bit easier.This pull request makes the following changes:
main.go
to useGoListAgnostic
func GoListAgnostic(stdIn io.Reader) (deps types.ProjectList, err error)
GoListModule
struct, which has a signature offunc modToProjectList(mod types.GoListModule) (dep types.Projects, err error)
It relates to the following issue #s:
cc @bhamail / @DarthHater