Hi!

I have a utility that parses Go files into AST , makes some changes on the 
tree (import paths) and format it back into the Go source code, in the 
original file.

The problem is I am using format.Node function from this 
<https://golang.org/pkg/go/format/> package. The formatting this function 
applies to the AST is very similar to what gofmt does but it is not 
identical. 

Example.

The original file may look like this

// +build !windows

package main

import (
    "<import-path>"
)

func main() {}

And the result will look like

// +build !windows
package main

import (
    "<new-import-path>"
)

func main() {}

See the 2nd line of the original: it is blank. And it disappears in the 
result. And I don't touch neither the Package token of the AST, neither the 
leading comment.

What AST into source printer can I use instead to preserve that blank line?

-- 
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/50b2e8fe-e017-403e-a2d8-f44cfd86f20a%40googlegroups.com.

Reply via email to