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 · 7 comments
Open
Labels
OS-Windows Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@zer09
Copy link

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
Copy link
Contributor

/cc @alandonovan

@ianlancetaylor
Copy link
Contributor

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 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

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

@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

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 This label describes issues relating to any tools in the x/tools repository. label Sep 12, 2019
@adonovan
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-Windows Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

7 participants