Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.8.1 windows/amd64

What operating system and processor architecture are you using (go env)?

set GOARCH=amd64 set GOBIN= set GOEXE=.exe set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOOS=windows set GOPATH=F:\GO set GORACE= set GOROOT=C:\Go set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 set GCCGO=gccgo set CC=gcc set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\User\AppData\Local\Temp\go-build311479175=/tmp/go-build -gno-record-gcc-switches set CXX=g++ set CGO_ENABLED=1 set PKG_CONFIG=pkg-config set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2

What did you do?

Rename a func using gorename on windows command prompt or powershell. please see this thread also: https://forum.golangbridge.org/t/solved-proper-way-of-using-gorename/5418

What did you expect to see?

gorename should rename the function name.

What did you see instead?

gorename give me an invalid expression error

P.S. Using bash on windows solved the problem, this issue could be just a enhancement request for gorename on MS windows.

Thanks.

Comment From: bradfitz

/cc @alandonovan

Comment From: ianlancetaylor

As far as I can see this is an issue of how to use the Windows shell. I don't think there is anything that gorename can do to fix this.

Comment From: zer09

@ianlancetaylor what do you mean "how to use the Windows shell."?

BTW I tried custom build the gorename adding fmt.Println(*fromFlag) after checking the arguments. And Windows shell rendered different result, the double quotes is removed. So what I did is change the -from value I just remove the quotes then escaped the doubles gorename -from \"github.com/samp/pack\".New -to New1 and it just works.

I don't know who to blame the flag.String or the command prmopt I am just very new to golang, but if gorename can't do anything to fix this. I think it also good to include this on a documentation, so that windows users is aware of this. IMHO 😉

Edit: for command prompt: gorename -from \"github.com/samp/pack\".New -to New1 for powershell : gorename -from '\"github.com/samp/pack\".New1' -to New

Comment From: alexbrainman

I don't know who to blame the flag.String or the command prmopt

Before gorename even gets to see the string you pass to it on the command line, the cmd.exe converts your string into different string using these https://msdn.microsoft.com/en-us/library/17w5ykft.aspx rules. That is just how cmd.exe (the command prompt) works.

It is your job to understand these rules and use them accordingly to make sure gorename will get result you want.

bash has similar problem, but everyone knows bash rules and adjust things as required.

Alex

Comment From: alandonovan

@alexbrainman In hindsight, denoting package paths using Go import syntax with quotation marks was a mistake I'll not make again.

Comment From: alexbrainman

In hindsight

Hindsight is a wonderful thing.

If you think https://msdn.microsoft.com/en-us/library/17w5ykft.aspx is complicated, you should check (I do not expect you to) http://daviddeley.com/autohotkey/parameters/parameters.htm#WIN for the complete story.

Alex

Comment From: adonovan

Belated thanks for those doc links, which are solid gold.

Comment From: seankhliao

closing as obsoleted by #69360