uber-go / fx

A dependency injection based application framework for Go.
https://uber-go.github.io/fx/
MIT License
5.68k stars 287 forks source link

Better logging for constructors in vendor/ #539

Closed HelloGrayson closed 7 years ago

HelloGrayson commented 7 years ago

When Fx's output encounters constructors in vendor/ it should shorten:

github.com/foo/bar/vendor/go.uber.org/fx.New.func1()

to:

vendor/go.uber.org/fx.New.func1()
HelloGrayson commented 7 years ago

This can happen post-1.0 since the feature isn't controlled by the end-user.

HelloGrayson commented 7 years ago

@akshayjshah can you put down the reservations you mentioned a few weeks back about doing this?

akshayjshah commented 7 years ago

We'll need to be careful to handle nested vendor directories properly. In general, I'm mixed about changes like this - Go import paths don't contain any useless information, so including the whole path is the surest way to handle all edge cases.

glibsm commented 7 years ago

The particular implementation does a non-greedy strip, only removing things up to the first vendor. Especially since the first part happens to be the actual repository being built.

Seeing output in the format:

*A <= github.com/foo/bar/vendor/src/github.com/baz/derp

Given that I'm running github.com/foo/bar is a bit of an eye sore.

If we wanted a more bullet-proof implementation, then stripping the current package from the head of the path might be a more preferable solution. I just don't know if there is an easy way to obtain the root of the currently built project 😕