Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgo: fix many linters ignoring Cgo files #3025

Merged
merged 3 commits into from
Jul 30, 2022
Merged

Commits on Jul 30, 2022

  1. Add test that gofmt and revive work with cgo

    Signed-off-by: Sven Anderson <[email protected]>
    ansiwen committed Jul 30, 2022
    Configuration menu
    Copy the full SHA
    5d6e9d7 View commit details
    Browse the repository at this point in the history
  2. Fix many linters ignoring Cgo files

    This change fixes a bug caused that many linters ignored all files that are
    using Cgo. It was introduced by PR golangci#1065, which assumed that all files
    referenced by //line directives are non-Go files, which is not true. In the case
    of Cgo they point to the original Go files which are used by Cgo as templates to
    generate other Go files.
    
    The fix replaces all calls of Pass.Fset.PositionFor with a function
    getFileNames() that first calls Pass.Fset.PositionFor with adjustment, and only
    if it results in a non-Go file it calls Pass.Fset.PositionFor again without
    adjustment.
    
    Fixes: golangci#2910
    
    Signed-off-by: Sven Anderson <[email protected]>
    ansiwen committed Jul 30, 2022
    Configuration menu
    Copy the full SHA
    ce4f33f View commit details
    Browse the repository at this point in the history
  3. Disable gci linter in cgo test

    It seems like the gci linter doesn't know about the special import rules for
    Cgo.
    ansiwen committed Jul 30, 2022
    Configuration menu
    Copy the full SHA
    ce8014b View commit details
    Browse the repository at this point in the history