Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gorename: not properly working on windows using cmd or powershell. #20422

Open
zer09 opened this issue May 19, 2017 · 6 comments
Open

x/tools/gorename: not properly working on windows using cmd or powershell. #20422

zer09 opened this issue May 19, 2017 · 6 comments
Labels
Milestone

Comments

@zer09
Copy link

@zer09 zer09 commented May 19, 2017

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.

@bradfitz bradfitz changed the title tools/gorename not properly working on windows using cmd or powershell. x/tools/gorename: not properly working on windows using cmd or powershell. May 19, 2017
@gopherbot gopherbot added this to the Unreleased milestone May 19, 2017
@bradfitz bradfitz added the OS-Windows label May 19, 2017
@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented May 19, 2017

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented May 19, 2017

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.

@zer09
Copy link
Author

@zer09 zer09 commented May 20, 2017

@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

@alexbrainman
Copy link
Member

@alexbrainman alexbrainman commented May 20, 2017

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

@alandonovan
Copy link
Contributor

@alandonovan alandonovan commented May 22, 2017

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

@alexbrainman
Copy link
Member

@alexbrainman alexbrainman commented May 23, 2017

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

@gopherbot gopherbot added the Tools label Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.