github.com/blueinnovationsgroup/can-go@v0.0.0-20230518195432-d0567cda0028/pkg/dbc/analysis/passes/lineendings/analyzer.go (about)

     1  package lineendings
     2  
     3  import (
     4  	"bytes"
     5  	"text/scanner"
     6  
     7  	"github.com/blueinnovationsgroup/can-go/pkg/dbc/analysis"
     8  )
     9  
    10  func Analyzer() *analysis.Analyzer {
    11  	return &analysis.Analyzer{
    12  		Name: "lineendings",
    13  		Doc:  `check that the file does not contain Windows line-endings (\r\n)`,
    14  		Run:  run,
    15  	}
    16  }
    17  
    18  func run(pass *analysis.Pass) error {
    19  	if bytes.Contains(pass.File.Data, []byte{'\r', '\n'}) {
    20  		pass.Reportf(
    21  			scanner.Position{Filename: pass.File.Name, Line: 1, Column: 1},
    22  			`file must not contain Windows line-endings (\r\n)`,
    23  		)
    24  	}
    25  	return nil
    26  }