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

cmd/cover: Add flag to select browser for go tool cover -html #10365

Closed
ChimeraCoder opened this issue Apr 7, 2015 · 5 comments
Closed

cmd/cover: Add flag to select browser for go tool cover -html #10365

ChimeraCoder opened this issue Apr 7, 2015 · 5 comments

Comments

@ChimeraCoder
Copy link
Contributor

@ChimeraCoder ChimeraCoder commented Apr 7, 2015

Currently, go tool cover-html=coverage.out appears to use xdg-open on Linux, which doesn't always select the right browser. Even if the $BROWSER environment variable is set, the cover tool doesn't always select the right browser.

Figuring out the right browser to open is tricky, and even xdg-open doesn't always get this right. It'd therefore be helpful if the cover tool either accepts a flag to specify the browser, and/or perhaps use the $BROWSER environment variable if defined.

(This is related to #10259 in that the fix is probably the same, but it affects the coverage tool too.)

@mikioh mikioh changed the title Add flag to select browser for go tool cover -html cmd/cover: Add flag to select browser for go tool cover -html Apr 8, 2015
@mikioh mikioh added the repo-tools label Apr 8, 2015
@robpike
Copy link
Contributor

@robpike robpike commented Apr 8, 2015

Seems to me the place to fix this is in xdg-open. I don't want our tools to have more configuration to support broken operating systems.

@robpike robpike closed this Apr 8, 2015
@cespare
Copy link
Contributor

@cespare cespare commented Apr 8, 2015

Note that in this case, xdg-open is not even picking a working browser for @ChimeraCoder, rendering cover -html unusable. (From discussion on IRC.)

@robpike
Copy link
Contributor

@robpike robpike commented Apr 8, 2015

Regardless, I think it's wrong to build os-specific hacks into every tool that wants to talk to a browser (or any other tool) when that is the os's responsibility. I can think of many ways to fix this that do not involve changing the cover tool.

@dherbst
Copy link

@dherbst dherbst commented Apr 15, 2015

You can use the flag -o to Write out an HTML file instead of launching a web browser and then use the web browser to open the file.

go tool cover -html=c.out -o coverage.html

@ChimeraCoder
Copy link
Contributor Author

@ChimeraCoder ChimeraCoder commented May 25, 2015

@dherbst Thanks, this is a good workaround.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.