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

Fix running in Go workspace #63

Merged
merged 4 commits into from
Aug 16, 2023
Merged

Conversation

silkeh
Copy link
Contributor

@silkeh silkeh commented Aug 14, 2023

When working with Go workspaces, go list -m -json will return multiple objects. For example:

{
	"Path": "golang.org/x/example/hello",
	"Main": true,
	"Dir": "/build/example/hello",
	"GoMod": "/build/example/hello/go.mod",
	"GoVersion": "1.19"
}
{
	"Path": "example.com/hello",
	"Main": true,
	"Dir": "/build/hello",
	"GoMod": "/build/hello/go.mod",
	"GoVersion": "1.21"
}

Ensure that the JSON decoding can handle this output by stream-decoding the JSON and returning the first suitable module.

When working with Go workspaces, `go list -m -json` will return multiple objects.
For example:

```json
{
	"Path": "golang.org/x/example/hello",
	"Main": true,
	"Dir": "/build/example/hello",
	"GoMod": "/build/example/hello/go.mod",
	"GoVersion": "1.19"
}
{
	"Path": "example.com/hello",
	"Main": true,
	"Dir": "/build/hello",
	"GoMod": "/build/hello/go.mod",
	"GoVersion": "1.21"
}
```

Ensure that the JSON decoding can handle this output by stream-decoding the JSON and returning the
first suitable module.
@tmzane tmzane self-requested a review August 15, 2023 15:29
@tmzane
Copy link
Member

tmzane commented Aug 15, 2023

Good catch, thank you for the PR!

@codecov
Copy link

codecov bot commented Aug 15, 2023

Codecov Report

Merging #63 (db5b16c) into main (fb0f11f) will decrease coverage by 1.61%.
The diff coverage is 74.07%.

@@            Coverage Diff             @@
##             main      #63      +/-   ##
==========================================
- Coverage   88.06%   86.45%   -1.61%     
==========================================
  Files           2        2              
  Lines         176      192      +16     
==========================================
+ Hits          155      166      +11     
- Misses         14       18       +4     
- Partials        7        8       +1     
Files Changed Coverage Δ
utils.go 67.64% <74.07%> (+0.98%) ⬆️

@tmzane
Copy link
Member

tmzane commented Aug 16, 2023

I'm going to add some tests and then we can merge it.

@tmzane tmzane merged commit 0ef7035 into go-simpler:main Aug 16, 2023
8 of 10 checks passed
@tmzane
Copy link
Member

tmzane commented Aug 16, 2023

Merged in v0.7.2 🎉

@silkeh
Copy link
Contributor Author

silkeh commented Aug 16, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants