Skip to content

proposal: add constant flag in logging to log the goroutine id to trace the bug #27361

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

Closed
NetWilliam opened this issue Aug 30, 2018 · 3 comments

Comments

@NetWilliam
Copy link

I have understood that there are some disadvantages in getting the goroutine ID in the program. However, I also have noticed that in https://golang.org/pkg/log/#pkg-constants we have some approach to logging the file name and line no etc...

I think it would very useful in the debugging of a program if goroutine ID could be logged in a similar way.

@gopherbot gopherbot added this to the Proposal milestone Aug 30, 2018
@mvdan
Copy link
Member

mvdan commented Aug 30, 2018

There's no such thing as a goroutine ID, so I don't see how this proposal can be accepted: https://golang.org/doc/faq#no_goroutine_id

@agnivade
Copy link
Contributor

@NetWilliam is aware of the faq link. I had pointed it out here #27329 (comment).

@NetWilliam - You will have to provide good counter-arguments as to why you believe a goroutine id is necessary. You are proposing to change one of the major features of the language, so unless the benefits outweigh the disadvantages due to added API, it is unlikely to be accepted. Just mentioning "debugging" is not very helpful.

@rsc
Copy link
Contributor

rsc commented Sep 19, 2018

In general logical work can move around between goroutines. What you want is to print, explicitly, some indicator of the work being done, and then you can correlate log prints. Like it says in the FAQ and other places, we don't want to give any special meaning to goroutine identity.

Note also that if you are trying to understand the goroutine behavior explicitly, there is the runtime tracer (go tool trace).

@rsc rsc closed this as completed Sep 19, 2018
@golang golang locked and limited conversation to collaborators Sep 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants