8000 Allow `defer` after error-handling part · Issue #85 · bombsimon/wsl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Allow defer after error-handling part #85
Closed
@LasTshaMAN

Description

@LasTshaMAN

In this PR https://github.com/bombsimon/wsl/pull/37/files#diff-676fb336aa3ff093ebaa37c4293f1cd1R417 the issue was addressed just for Close method, but in my opinion it applies to any method that is used in a similar way.

Here is an example usage of https://github.com/uber-go/automaxprocs package:

undoMaxProcs, err := maxprocs.Set()
if err != nil {
    return fmt.Errorf("failed to set GOMAXPROCS, err: %w", err)
}
defer undoMaxProcs()

// The rest of the code goes here.

I think this code aligns nicely with Go-best-practices, but wsl still complains about it:

main.go:72:2: only one cuddle assignment allowed before defer statement (wsl)
	defer undoMaxProcs()
	^

and wants to see it formatted this way:

undoMaxProcs, err := maxprocs.Set()
if err != nil {
    return fmt.Errorf("failed to set GOMAXPROCS, err: %w", err)
}

defer undoMaxProcs()

// The rest of the code goes here.

which is less ideomatic in my opinion.

< 4113 /div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0