incu6us / goimports-reviser

Right imports sorting & code formatting tool (goimports alternative)
MIT License
607 stars 72 forks source link

go.mod finding is broken when using stdin #70

Closed fgblomqvist closed 2 years ago

fgblomqvist commented 2 years ago

The only time I can get it to work is if the workdir is the go.mod root. If I am anywhere inside of the go project, it doesn't crawl up until it finds the go.mod, it just errors saying it wasn't able to open the go.mod.

The logic should probably be updated to be something like this:

  1. If filepath is set, get the folder of that file and then crawl upwards
  2. If filepath is not set, get the current workdir and then crawl upwards