Enabling jump to source in Goland

70 views
Skip to first unread message

omus...@gmail.com

unread,
Sep 20, 2024, 2:16:27 AM9/20/24
to golang-nuts
I was missing the ability for logs like: `I0918 22:33:11.103850 23686 main.go:39] Hello World!`
to let me click on the `path:line_number` and jump to the exact line of code that logged the message.

I noticed this linking was working for paths in messages from `panic`, so I dug into it. The reason this doesn't work is because Goland is looking for a path:line_number without the right-bracket (or any other suffix).

I filed a bug for this: https://youtrack.jetbrains.com/issue/GO-17484/Jump-to-source-from-terminal-logs-is-broken-but-easily-fixable

In the meantime I was able to get it working using the github.com/golang/glog package by adding a space before the closing bracket in my local copy of its source:
https://github.com/golang/glog/blob/97303146a4ffecf364d4300e07fca855d0062c43/internal/logsink/logsink.go#L245

I thought I'd share in case anyone else found it helpful, or in case there's some better solution that I missed.

Omar
Reply all
Reply to author
Forward
0 new messages