Closed
Description
What version of Go are you using (go version
)?
go version go1.11.2 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
GOARCH="amd64" GOBIN="" GOCACHE="/Users/anjmao/Library/Caches/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/anjmao/go" GOPROXY="" GORACE="" GOROOT="/usr/local/go" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/l6/jh91jsw90fvbxtpm54k_5fgc0000gn/T/go-build462335630=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
I'm using go tools astutil package to replace ast node with some new node which I'm getting from parser.ParseExpr
.
Here is demo showing the issue https://github.com/anjmao/astpartup/blob/master/main.go#L79
If I create new ast node tree manually then it works fine and I get correctly formatted result back (also shown in demo).
What did you expect to see?
I expect to see correctly formatted file
package main
import "fmt"
func main() {
log.Println("new value")
var a int
}
What did you see instead?
package main
import "fmt"
func main() {
log.
Println("new value",
)
var a int
}