You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there! Thank you so much for this awesome library!
I want to write a small refactoring tool. The idea is to load a package, move some things around using dst, and then write the changes back to disk. I am able to load my package, do changes and print the result of each file to stdout with code like this:
This successfully loads the files, applies changes and resolves the imports (great!). Here's the output of calling the function above (I have these files in my /tmp/t directory: main.go, sum.go and go.mod):
$ go run ./cmd/refactorer/main.go
parsed 2 files
=====================================
package main
import "fmt"
func sum(int x, int y) {
_ = x + y
fmt.Println("Hello, World!")
}
=====================================
package main
import "fmt"
func main() { fmt.Println("Hello, World!") }
However, as far as I could see, the paths of .go files that were loaded are not exposed anywhere. This means at the moment I can't write the changes back to disk because I don't know which parsed file inside p.Syntax corresponds to which path.
It would be awesome if we could expose the file names in the struct returned by decorator.Load, perhaps by converting Syntax:
Hi there! Thank you so much for this awesome library!
I want to write a small refactoring tool. The idea is to load a package, move some things around using
dst
, and then write the changes back to disk. I am able to load my package, do changes and print the result of each file tostdout
with code like this:This successfully loads the files, applies changes and resolves the imports (great!). Here's the output of calling the function above (I have these files in my
/tmp/t
directory:main.go
,sum.go
andgo.mod
):However, as far as I could see, the paths of
.go
files that were loaded are not exposed anywhere. This means at the moment I can't write the changes back to disk because I don't know which parsed file insidep.Syntax
corresponds to which path.It would be awesome if we could expose the file names in the struct returned by
decorator.Load
, perhaps by convertingSyntax
:dst/decorator/load.go
Line 96 in ce1c8af
dst/dst.go
Line 674 in ce1c8af
The text was updated successfully, but these errors were encountered: