incu6us / goimports-reviser

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

Preserve cgo's import "C" #62

Closed fmeum closed 2 years ago

fmeum commented 2 years ago

cgo's import "C" has a special meaning as well as a relevant doc comment and should thus never be regrouped. With this commit, it is ignored by all functions that track or mutate imports.

Fixes #56.

@sudssm Could you verify that this fixes the handling of cgo imports for you?

fmeum commented 2 years ago

The tests emit data into testdata, which confuses follow-up tests. I think that it would be better to write the test files to a directory created via ioutil.TempDir.

incu6us commented 2 years ago

it appears, because cgo_example.go and example.go has different package definitions. change for a single one will fix the error

fmeum commented 2 years ago

it appears, because cgo_example.go and example.go has different package definitions. change for a single one will fix the error

I changed all package declarations to testdata.

codecov[bot] commented 2 years ago

Codecov Report

Merging #62 (d813d27) into master (c5daf54) will increase coverage by 0.15%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #62      +/-   ##
==========================================
+ Coverage   93.00%   93.15%   +0.15%     
==========================================
  Files           4        4              
  Lines         300      307       +7     
==========================================
+ Hits          279      286       +7     
  Misses         12       12              
  Partials        9        9              
Impacted Files Coverage Δ
reviser/reviser.go 94.16% <100.00%> (+0.17%) :arrow_up:

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 c5daf54...d813d27. Read the comment docs.