commit | ae65d273b9f43866a987aed78633d2c9ff1966ce | [log] [tgz] |
---|---|---|
author | David Symonds <dsymonds@golang.org> | Wed Sep 03 11:07:00 2014 +1000 |
committer | David Symonds <dsymonds@golang.org> | Wed Sep 03 11:13:33 2014 +1000 |
tree | ee7e67411145f206011986631545e9893516c045 | |
parent | 209d47fee4d491f62b6d6c0bac75d389bcf296a1 [diff] |
Avoid panic when an ast.Node is in a different file. Fixes #59.
diff --git a/lint.go b/lint.go index bfff95c..53a8655 100644 --- a/lint.go +++ b/lint.go
@@ -173,7 +173,10 @@ Confidence: confidence, } if pos.Filename != "" { - problem.LineText = srcLine(p.files[pos.Filename].src, pos) + // The file might not exist in our mapping if a //line directive was encountered. + if f, ok := p.files[pos.Filename]; ok { + problem.LineText = srcLine(f.src, pos) + } } argLoop: