 7f48cc88b8
			
		
	
	
		7f48cc88b8
		
			
		
	
	
	
	
		
			
			If the target files contains `//line` directive and it indicates a non-go file, the linter is going to handle it as a go file, which results in failure. The cause of this issue is that the linters (`Analyzer`s) are using `pass.Fset.Position()`. This func returns the adjusted position using `//line` directive. The example project reported in #998 has `//line` directive that indicates other non-go file. According to the description of "Compiler Directives” (https://golang.org/cmd/compile/#hdr-Compiler_Directives), line directives is mainly used for reporting original positions to the generators or something. On linters of golangci-lint, `pass.Fset.Position()` is used just to aggregate file names; we don't have to adjust positions. This changes `Analyzer`s that use `pass.Fset.Position()` to aggregate file names to use `pass.Fset.PositionFor()` with `adjusted == false`. Relates: #998
		
			
				
	
	
		
			38 lines
		
	
	
		
			358 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			358 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Refers a existent, but non-go file with line directive
 | |
| //line hello.tmpl:1
 | |
| package main
 | |
| 
 | |
| import (
 | |
| 	"github.com/ryancurrah/gomodguard"
 | |
| )
 | |
| 
 | |
| func _() {
 | |
| 	var x int
 | |
| 	_ = x
 | |
| 	x = 0 //x
 | |
| }
 | |
| 
 | |
| func main() {
 | |
| 	a()
 | |
| 	b()
 | |
| 	wsl()
 | |
| }
 | |
| 
 | |
| func a() {
 | |
| 	fmt.Println("foo")
 | |
| }
 | |
| 
 | |
| func b() {
 | |
| 	fmt.Println("foo")
 | |
| }
 | |
| 
 | |
| func wsl() bool {
 | |
| 
 | |
| 	return true
 | |
| }
 | |
| 
 | |
| func notFormatted()  {
 | |
| }
 | |
| 
 | |
| // langauge
 |