aristanetworks / goarista

Fairly general building blocks used in Arista Go code and open-sourced for the benefit of all.
Apache License 2.0
213 stars 68 forks source link

enhance importsort with directory support & exclude flag #47

Closed danielfoehrKn closed 4 years ago

danielfoehrKn commented 4 years ago

In multiple projects I am working on (e.g gardener - see example file), we are using the same import grouping this tool supports

Added support for directories and the possibility to define a regex pattern for excluded filenames. This is useful in our case to exclude auto-generated files.

This tool is somewhat one of the only simple enough tools I found to achieve this import grouping, so kudos for that.

codecov-io commented 4 years ago

Codecov Report

Merging #47 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #47   +/-   ##
=======================================
  Coverage   76.46%   76.46%           
=======================================
  Files          13       13           
  Lines        1198     1198           
=======================================
  Hits          916      916           
  Misses        246      246           
  Partials       36       36

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5d8d36c...51bbd6a. Read the comment docs.

danielfoehrKn commented 4 years ago

Ping?

aaronbee commented 4 years ago

Hello, thanks for the contribution!

I'd rather not add these features to importsort because you can do this filtering with other tools, like find.

For example, something like this that finds all go files that are not in the vendor directory or has a name that suggests it was generated:

files=$(find . -name '*.go' ! -path './vendor/*' ! -name '*.pb.go' ! -name '*.gen.go' -print0)
echo "$files" | xargs goimports -l
echo "$files" | xargs importsort -l

Please feel free to fork this utility. It is not being actively maintained anymore.