xgo icon indicating copy to clipboard operation
xgo copied to clipboard

Proposal: trap init functions

Open xhd2015 opened this issue 2 years ago • 2 comments

Currently init functions are skipped, that makes it impossible to inject mock and collect trace during the init stage.

However since init functions just run once and run serially, it has no performance impact at all. It might be useful.

xhd2015 avatar Apr 23 '24 06:04 xhd2015

At least allow to trace package initialization traces. This can be done by simply inserting an init function in each package, and emit a print statement.

And maybe xgo can provide a tool called xgo inspect check-init, when invoked will do a static analysis to recursively find all imports and render the import tree in a web UI.

xhd2015 avatar May 17 '24 14:05 xhd2015

A successor of https://github.com/xhd2015/go-inspect/tree/master/cmd/depcheck

xhd2015 avatar May 17 '24 14:05 xhd2015