Oh that's brilliant, I didn't realize $GOPATH acted like $PATH. Haha, seems 
obvious when writing it out, but I thought it was just an environment 
variable. Thanks Matt!

On Wednesday, December 27, 2017 at 10:40:21 AM UTC+7, Matt Harden wrote:
>
> You can put them anywhere on your GOPATH. So for example, if you're on a 
> unix-y system, $HOME/go is normally your GOPATH, and you want to rewrite 
> the file $HOME/go/src/github.com/my/repo/hello.go, you could store the 
> rewritten file at /tmp/go/src/github.com/my/repo/hello.go, and run the go 
> tool with the GOPATH environment variable set to /tmp/go:$HOME/go. This 
> would cause the tool to find the rewritten file before the original. If 
> there are other files in the same package that you are *not* rewriting, 
> you may have to copy those anyway to the new directory; I'm not sure 
> whether the go tool expects all files in a package to be in the same 
> directory or not.
>
> The way to call "go run" from Go is to use the os/exec 
> <http://godoc.org/os/exec#example-Cmd-CombinedOutput> package to 
> literally run the command.
>
> On Mon, Dec 25, 2017 at 6:48 AM Matt Mueller <mattm...@gmail.com 
> <javascript:>> wrote:
>
>> Hey folks!
>>
>> I'm using the new 
>> https://godoc.org/golang.org/x/tools/go/ast/astutil#Apply function, but 
>> keep running into the question:
>>
>> After I rewrite these files, where do I stick them so they're still 
>> buildable with the rest of the program? Is there anyway to call "go run" 
>> after modifying the AST of these files? 
>>
>> Thanks!
>>
>> -- 
>> 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...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to