diff options
| author | Teddy Wing | 2023-05-21 21:39:48 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2023-05-21 21:39:48 +0200 | 
| commit | 8efe2cc2f9495b60b5a27f818af7d666651aee4d (patch) | |
| tree | 83fb472f7c31ddff74dc8920b3ced1b6120380f3 /testdata | |
| parent | af42c108f8f29fd6290940cc9fd6c5819d25ad74 (diff) | |
| download | godefererr-8efe2cc2f9495b60b5a27f818af7d666651aee4d.tar.bz2 | |
Report function signature declaration using variable name other than err
I had previously hard-coded the variable name "err" as the recommended
name declaration in the function signature for simplicity.
Now, use the name assigned in the `defer` instead, which is more
correct.
Diffstat (limited to 'testdata')
| -rw-r--r-- | testdata/signature.go | 15 | 
1 files changed, 15 insertions, 0 deletions
| diff --git a/testdata/signature.go b/testdata/signature.go index 73203ee..b668558 100644 --- a/testdata/signature.go +++ b/testdata/signature.go @@ -45,6 +45,21 @@ func returnedErrorMustMatchDeferErrorName() (err error) {  	return err2 // want "does not return 'err'"  } +func deferUsesUnconventionalErrName() error { // want "return signature should be '\\(anErr error\\)'" +	var anErr error + +	anErr = nil +	if anErr != nil { +		return anErr +	} + +	defer func() { +		anErr = errors.New("defer error") +	}() + +	return anErr +} +  func good() (err error) {  	err = nil  	if err != nil { | 
