Hi all, I'm trying to learn how to write a linter (because long weekend, 
etc)

I looked at Fatih's very fine blog post (
https://arslan.io/2019/06/13/using-go-analysis-to-write-a-custom-linter/) 
as well as the one that precedes it, although I was a LOT lost reading that 
one.

Copying and pasting 
https://github.com/fatih/addlint/blob/master/addcheck/addcheck.go got me 
started, but the linter I have in mind needs to see strings, a trip to 
https://golang.org/src/go/token/token.go and 
https://golang.org/src/go/ast/ast.go showed me the possibilities. This  
(fortunately?) made me switch priorities slightly, as I now want to write 
something that is going to print each and every node (and this is where my 
problems began).

I used Fatih's run and render functions but discovered that an error is 
being generated for the Doc comment, and I cannot see *why* 
(ast.CommentGroup is fine in parts of the code.. except for `func (p 
*printer) printNode(node interface{}) error`
 (https://golang.org/src/go/printer/printer.go 
<https://golang.org/src/go/printer/printer.go> line 1073), the format node 
section (lines 1125 - 1155) take me to the unsupported label, which 
generates an error

My code (main.go, lencheck.go, and complete output can be found 
at https://play.golang.org/p/olvJ64EDdKZ, please excuse the length of the 
paste, I put *everything* in there)

As you can see in my code there are 4 nodes that throw errors, and I don't 
understand if 1) that is intended or 2) I am doing (or not doing as the 
case may be) something to cause the issue.

 Any help/pointers appreciated

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e305e103-c8d1-46e5-816d-87f45ec9b963%40googlegroups.com.

Reply via email to