jmattheis / goverter

Generate type-safe Go converters by simply defining an interface
https://goverter.jmattheis.de/
MIT License
496 stars 46 forks source link

feat: enable working directory #15

Closed nissim-natanov-outreach closed 2 years ago

nissim-natanov-outreach commented 2 years ago

This PR enables working directory support for all packages.Load call. It is required when running unit tests in isolated directories with their own go.mod files - in this case the packages.Load call must be executed inside that directory.

This PR preserves the original ParseDocs method signature for back compat, introducing new DocsParser to process the comments.

This PR also removes the use of go/importer package. It does not support the new go/modules well and both of its Import and ImportFrom methods are marked as deprecated. The golang.org/x/tools/go/packages is supposed to supersede the go/importer package, and it is already heavily used to parse docs and find convert methods, so there is no reason using the go/importer anymore. Moreover, there is no need to re-parse sources ... so I updated code to store the scope on the Converter itself.

codecov-commenter commented 2 years ago

Codecov Report

Merging #15 (2808039) into main (a0f0141) will increase coverage by 0.22%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #15      +/-   ##
==========================================
+ Coverage   93.38%   93.61%   +0.22%     
==========================================
  Files          22       22              
  Lines        1043     1049       +6     
==========================================
+ Hits          974      982       +8     
+ Misses         52       51       -1     
+ Partials       17       16       -1     
Impacted Files Coverage Δ
generator/generator.go 97.26% <ø> (ø)
comments/parse_docs.go 96.89% <100.00%> (+0.09%) :arrow_up:
generator/generate.go 93.54% <100.00%> (+5.66%) :arrow_up:
generator/packages.go 92.00% <100.00%> (+0.33%) :arrow_up:
runner.go 90.90% <100.00%> (+1.43%) :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 a0f0141...2808039. Read the comment docs.

nissim-natanov-outreach commented 2 years ago

@jmattheis Jannis, please take a look at this PR, share your thoughts!

nissim-natanov-outreach commented 2 years ago

comments addressed, PTAL