Closed danilvpetrov closed 6 years ago
Hi @danilvpetrov,
Thanks a lot for this PR. Is this really just to silence golint
? If so, golint
actually ignores generated code, but the headers of pegomock-generated files do not match what golint
scans for.
golint
follows this standard pattern for generated code.
See here for its implementation: https://github.com/golang/lint/blob/master/lint.go#L117-L133
So maybe it's enough to just change that header from
// Automatically generated by pegomock. DO NOT EDIT!
to
// Code generated by pegomock. DO NOT EDIT.
What do you think?
Yep, looks like changing header in generated files will do the trick. I'll remove all the changes and place a new with new header PR fairly soon.
Hi @petergtz,
Removed previous changes, added required comments to the file generation output. Could you please review?
Very nice! Thanks again, @danilvpetrov!
Hi @petergtz,
This change is about making generated mock and matcher files a bit friendlier for pre-commit checks with tools like
golint
andgofmt
. The code in changes adds comments to each generated type/method, uses a format tool to run formatting changes after each file is generated. User can specify toolsgofmt
,goimports
, andgoreturns
with -f flag to format generated files. If no parameter with -f flag is specified, the tool defaults togofmt
.Relevant unit test is included.
Hopefully you find these changes useful. Output from
golint
complaining about the formats of generated files can be really overwhelming.