Hi Denis,

In a project of my own I encountered the same issue. This program moves a
go project to another location, then it remembers imports (that are
necessary), exported types, functions and package-scope values (var /
const) and maps them in the original go project to the newly created one.
The original goal of this program is to move packages from other packages,
while leaving everything compatible as is. Everything almost works now but
in practice, all my code has a strange look, like function/type definitions
are all stuck with one another, with no lines in between.

If anyone has suggestions or ideas, please let us know!

Thanks to all of you for your time.

Le ven. 18 oct. 2019 à 00:11, Denis Cheremisov <denis.cheremi...@gmail.com>
a écrit :

> 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
> <https://groups.google.com/d/msgid/golang-nuts/50b2e8fe-e017-403e-a2d8-f44cfd86f20a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CANgi334O7UmwiQNQ0mvuQy48Tsj62x4WDao8L9Zj414tWLvhGw%40mail.gmail.com.

Reply via email to