|
|
Descriptionsrc/env.bash: Workaround/fix so compiling works on windows (MingW).
Otherwise you would get the following when compiling Go
make: pwd: Command not found
make: echo: Command not found
make: *** [go-env] Error 127
Did not find Go environment variables.
Patch Set 1 #
MessagesTotal messages: 24
What causes the commands not to be found and why does rearranging directory order in $PATH fix it?
Sign in to reply to this message.
I really have no idea. This is just something that came up when I looked at older revisions (5ca1e6b0cbe7) of the env.bash file. When I changed it back, compiling worked again, so I assume MingW has some problems with it. On 18 apr, 17:21, Russ Cox <r...@google.com> wrote: > What causes the commands not to be found > and why does rearranging directory order in > $PATH fix it?
Sign in to reply to this message.
On Mon, Apr 18, 2011 at 13:36, Mr_Dark <mr_dark@darkweb.nl> wrote: > I really have no idea. This is just something that came up when I > looked at older revisions (5ca1e6b0cbe7) of the env.bash file. > When I changed it back, compiling worked again, so I assume MingW has > some problems with it. I'd prefer to find out what is wrong with mingw. Maybe we should be using ; to separate path elements, for example. Can any other MinGW users chime in?
Sign in to reply to this message.
Russ, In Windows paths, a colon is a volume separator and a semi-colon is a path list separator. MSYS, which provides a Unix-like shell for MinGW, knows that it needs to translate a Windows path list to Unix for the expanded PATH environment variable. `c:\go\bin` is translated to `/c/go/bin` and colons are used for path list separators. MSYS doesn't know that it needs to translate for GOBIN, GOROOT, and other Go path environment variables in a bash script. MSYS stops searching the PATH environment variable when it finds an invalid path in the list. If `"$GOBIN"` is first in the path list and it's invalid then the `/bin` and `/usr/bin` paths are not searched and the Unix pwd and echo commands are not found. For example, for $GOBIN = p:/go/bin After export PATH="$GOBIN":/bin:/usr/bin:$PATH Then $PATH = p:/go/bin:/bin:/usr/bin:.:/usr/local/bin:/mingw/bin:/bin: ... Note that the volume separator now looks like a path list separator. If GOBIN is changed to accomodate Unix, then it's not valid for Windows. For example, $GOBIN = /p/go/bin Revision: 5ca1e6b0cb - Log: build: move $GOBIN ahead of /bin, /usr/bin in build $PATH http://code.google.com/p/go/source/detail?r=5ca1e6b0cb Since this revision, I've have used a script to change the MSYS GOROOT and GOBIN environment variables for Windows. I believe Joe Poirer has encountered this problem too. Peter
Sign in to reply to this message.
On Mon, Apr 18, 2011 at 14:28, <go.peter.90@gmail.com> wrote: > Russ, > > In Windows paths, a colon is a volume separator and a semi-colon is a > path list separator. MSYS, which provides a Unix-like shell for MinGW, > knows that it needs to translate a Windows path list to Unix for the > expanded PATH environment variable. `c:\go\bin` is translated to > `/c/go/bin` and colons are used for path list separators. MSYS doesn't > know that it needs to translate for GOBIN, GOROOT, and other Go path > environment variables in a bash script. MSYS stops searching the PATH > environment variable when it finds an invalid path in the list. If > `"$GOBIN"` is first in the path list and it's invalid then the `/bin` > and `/usr/bin` paths are not searched and the Unix pwd and echo commands > are not found. > > For example, for > > $GOBIN = p:/go/bin > > After > > export PATH="$GOBIN":/bin:/usr/bin:$PATH > > Then > > $PATH = p:/go/bin:/bin:/usr/bin:.:/usr/local/bin:/mingw/bin:/bin: > ... > > Note that the volume separator now looks like a path list separator. > > If GOBIN is changed to accomodate Unix, then it's not valid for Windows. > For example, > > $GOBIN = /p/go/bin > > Revision: 5ca1e6b0cb - Log: build: move $GOBIN ahead of /bin, /usr/bin > in build $PATH > http://code.google.com/p/go/source/detail?r=5ca1e6b0cb > > Since this revision, I've have used a script to change the MSYS GOROOT > and GOBIN environment variables for Windows. Thanks. What does your script do? It seems like rearranging $PATH is ignoring the fact that $GOBIN is set wrong. Should env.bash set $GOBIN to something like /c/go/bin instead of c:\go\bin on Windows? Russ
Sign in to reply to this message.
Russ This is a quick kludge that I threw together to get over the immediate problem. Windows has very limited environment setting and expansion capability. Permanent Windows User Enviroment Variables for MSYS: GOROOTVOL=c GOROOTDIR=gowin GOBIN=/%GOROOTVOL%/%GOROOTDIR%/bin => /c/gowin/bin GOROOT=/%GOROOTVOL%/%GOROOTDIR% => /c/gowin I can now run using MSYS/MinGw. Permanent Windows User Enviroment Variables for Windows: GOROOTWIN=%GOROOTVOL%:\%GOROOTDIR% => c:\gowin GOBINWIN=%GOROOTVOL%:\%GOROOTDIR%\bin =>c:\gowin\bin Windows Command file script: set GOROOT=GOROOTWIN set GOBIN=GOBINWIN Now I can run using Windows. Then, when I clone the repository, I just change GOROOTDIR. Peter
Sign in to reply to this message.
Russ, > It seems like rearranging $PATH > is ignoring the fact that $GOBIN is set wrong. Should env.bash > set $GOBIN to something like /c/go/bin instead of c:\go\bin > on Windows? You should be able to set the $PATH list in whatever order you want. At the very least, for GOOS=="windows", if GOROOT or GOBIN start with a Windows volume, '^[a-zA-z]:', then env.bash should convert them to a Unix-like path for MSYS/MinGW. For example, convert c:\go\bin to /c/go/bin. Do you agree? Peter
Sign in to reply to this message.
Just converting the \ to / also works. MSYS/MinGW doesn't seem to have a problem with that. `c:\go\bin` -> `c:/go/bin` As for the `.:` which need to be at the front of the PATH it can be possible to do something like this: NEWPATH="$GOBIN":/bin:/usr/bin:$PATH export PATH=.:${NEWPATH//.:/} which will remove `.:` from NEWPATH and then put it in front of it while setting the PATH variable. On 18 apr, 22:41, go.peter...@gmail.com wrote: > Russ, > > > It seems like rearranging $PATH > > is ignoring the fact that $GOBIN is set wrong. Should env.bash > > set $GOBIN to something like /c/go/bin instead of c:\go\bin > > on Windows? > > You should be able to set the $PATH list in whatever order you want. > > At the very least, for GOOS=="windows", if GOROOT or GOBIN start with a > Windows volume, '^[a-zA-z]:', then env.bash should convert them to a > Unix-like path for MSYS/MinGW. For example, convert c:\go\bin to > /c/go/bin. > > Do you agree? > > Peter > > http://codereview.appspot.com/4368059/
Sign in to reply to this message.
On 2011/04/18 20:49:55, Mr_Dark wrote: > Just converting the \ to / also works. MSYS/MinGW doesn't seem to have > a problem with that. > `c:\go\bin` -> `c:/go/bin` Windows: P:\>set GO GOARCH=386 GOBIN=p:/go/bin GOOS=windows GOROOT=p:/go MSYS/MinGW: $ hg id ab386ee780c0 tip $ env | grep 'GO' GOBIN=p:/go/bin GOARCH=386 GOROOT=p:/go GOOS=windows peter /p/go/src $ cd $GOROOT peter /p/go $ cd src peter p/go/src $ ./all.bash make: pwd: Command not found make: echo: Command not found make: *** [go-env] Error 127 Did not find Go environment variables.
Sign in to reply to this message.
You still need to fix $PATH otherwise it'll you will get that error. env.bash - export PATH="$GOBIN":/bin:/usr/bin:$PATH + export PATH=/bin:/usr/bin:"$GOBIN":$PATH On 18 apr, 23:22, go.peter...@gmail.com wrote: > On 2011/04/18 20:49:55, Mr_Dark wrote: > > > Just converting the \ to / also works. MSYS/MinGW doesn't seem to have > > a problem with that. > > `c:\go\bin` -> `c:/go/bin` > > Windows: > > P:\>set GO > GOARCH=386 > GOBIN=p:/go/bin > GOOS=windows > GOROOT=p:/go > > MSYS/MinGW: > > $ hg id ab386ee780c0 tip > > $ env | grep 'GO' > GOBIN=p:/go/bin > GOARCH=386 > GOROOT=p:/go > GOOS=windows > > peter /p/go/src > $ cd $GOROOT > peter /p/go > $ cd src > peter p/go/src > $ ./all.bash > make: pwd: Command not found > make: echo: Command not found > make: *** [go-env] Error 127 > Did not find Go environment variables. > > http://codereview.appspot.com/4368059/
Sign in to reply to this message.
On Mon, Apr 18, 2011 at 4:49 PM, Mr_Dark <mr_dark@darkweb.nl> wrote: > You still need to fix $PATH otherwise it'll you will get that error. > > env.bash > - export PATH="$GOBIN":/bin:/usr/bin:$PATH > + export PATH=/bin:/usr/bin:"$GOBIN":$PATH > > On 18 apr, 23:22, go.peter...@gmail.com wrote: >> On 2011/04/18 20:49:55, Mr_Dark wrote: >> >> > Just converting the \ to / also works. MSYS/MinGW doesn't seem to have >> > a problem with that. >> > `c:\go\bin` -> `c:/go/bin` >> >> Windows: >> >> P:\>set GO >> GOARCH=386 >> GOBIN=p:/go/bin >> GOOS=windows >> GOROOT=p:/go >> >> MSYS/MinGW: >> >> $ hg id ab386ee780c0 tip >> >> $ env | grep 'GO' >> GOBIN=p:/go/bin >> GOARCH=386 >> GOROOT=p:/go >> GOOS=windows >> >> peter /p/go/src >> $ cd $GOROOT >> peter /p/go >> $ cd src >> peter p/go/src >> $ ./all.bash >> make: pwd: Command not found >> make: echo: Command not found >> make: *** [go-env] Error 127 >> Did not find Go environment variables. >> >> http://codereview.appspot.com/4368059/ I brought this up on the list http://tinyurl.com/44qo2qs From the readme I mention: Possible hacks when GOBIN and/or GOROOT are set by the user ================================================ msys.bat -------- if not "x%GOBIN%" == "x" set GOBIN=/%GOBIN::=% if not "x%GOROOT%" == "x" set GOROOT=/%GOROOT::=% *an extra forward slash gets added for some reason? env.bash -------- export OLDPATH=$PATH if [ "$MSYSTEM" = "MINGW32" ]; then export PATH="/${GOBIN/:/}":/bin:/usr/bin:$PATH else export PATH="$GOBIN":/bin:/usr/bin:$PATH fi ENVBASH="env.bash" if [ "$GOOS" = "windows" ]; then ENVBASH="winenv.bash" fi *are there any side effects? GOBIN ============= - it's where the tools get put - if no GOBIN exists it's set based on the path of the in progress build - GOBIN might have been set by the user, with two possibilities for how it's set: 1) explicit path or 2) appending bin to the expansion of GOROOT - env.bash creates GOBIN if it doesn't exist and prepends GOBIN to PATH, the freshly built Go toolchain should be used to build the packages, issue 424905 ensures it happens
Sign in to reply to this message.
...left out the first part of the readme Go-dev issue 424905 moved GOBIN in front of /bin and /usr/bin in env.bash which caused a bug to surface on the windows build, ie it caused the build to break immediately under certain circumstances. Msys does the path conversion for GOBIN internally when it's set in env.bash but not when GOBIN has already been set by the user. What gets prepended when the user set GOBIN is c:/go/bin which doesn't work in Msys' unix like environment, c:/go/bin should actually be converted to /c/go/bin for it to work. By default, GOOS and GOARCH are set based on the host system if they aren't already, they don't need to be set for a standard build. Likewise, GOROOT and GOBIN can take on defaults set in env.bash and Msys handles the path conversions without problem. tl;dr there's no need to set GOOS, GARCH, GOROOT, or GOBIN for a standard Go build and setup. On Mon, Apr 18, 2011 at 6:11 PM, Joseph Poirier <jdpoirier@gmail.com> wrote: > On Mon, Apr 18, 2011 at 4:49 PM, Mr_Dark <mr_dark@darkweb.nl> wrote: >> You still need to fix $PATH otherwise it'll you will get that error. >> >> env.bash >> - export PATH="$GOBIN":/bin:/usr/bin:$PATH >> + export PATH=/bin:/usr/bin:"$GOBIN":$PATH >> >> On 18 apr, 23:22, go.peter...@gmail.com wrote: >>> On 2011/04/18 20:49:55, Mr_Dark wrote: >>> >>> > Just converting the \ to / also works. MSYS/MinGW doesn't seem to have >>> > a problem with that. >>> > `c:\go\bin` -> `c:/go/bin` >>> >>> Windows: >>> >>> P:\>set GO >>> GOARCH=386 >>> GOBIN=p:/go/bin >>> GOOS=windows >>> GOROOT=p:/go >>> >>> MSYS/MinGW: >>> >>> $ hg id ab386ee780c0 tip >>> >>> $ env | grep 'GO' >>> GOBIN=p:/go/bin >>> GOARCH=386 >>> GOROOT=p:/go >>> GOOS=windows >>> >>> peter /p/go/src >>> $ cd $GOROOT >>> peter /p/go >>> $ cd src >>> peter p/go/src >>> $ ./all.bash >>> make: pwd: Command not found >>> make: echo: Command not found >>> make: *** [go-env] Error 127 >>> Did not find Go environment variables. >>> >>> http://codereview.appspot.com/4368059/ > > I brought this up on the list http://tinyurl.com/44qo2qs > > From the readme I mention: > > Possible hacks when GOBIN and/or GOROOT are set by the user > ================================================ > > msys.bat > -------- > if not "x%GOBIN%" == "x" set GOBIN=/%GOBIN::=% > if not "x%GOROOT%" == "x" set GOROOT=/%GOROOT::=% > > *an extra forward slash gets added for some reason? > > > env.bash > -------- > export OLDPATH=$PATH > if [ "$MSYSTEM" = "MINGW32" ]; then > export PATH="/${GOBIN/:/}":/bin:/usr/bin:$PATH > else > export PATH="$GOBIN":/bin:/usr/bin:$PATH > fi > > ENVBASH="env.bash" > if [ "$GOOS" = "windows" ]; then > ENVBASH="winenv.bash" > fi > > *are there any side effects? > > GOBIN > ============= > - it's where the tools get put > - if no GOBIN exists it's set based on the path of the in progress build > - GOBIN might have been set by the user, with two possibilities for > how it's set: 1) explicit path or 2) appending bin to the expansion > of GOROOT > - env.bash creates GOBIN if it doesn't exist and prepends GOBIN to > PATH, the freshly built Go toolchain should be used to build the > packages, issue 424905 ensures it happens >
Sign in to reply to this message.
Unfortunately I have nothing useful to add. I think this http://code.google.com/p/go/issues/detail?id=1587 is related. Alex
Sign in to reply to this message.
Just to clarify - when I say the user may have already set an environment variable I'm referring to it being hard coded e.g. via right-click "My Computer" > Properties > Advanced > "Environment Variable" where the normal windows format uses a colon in the path: C:/go/bin - if GOBIN is hard coded to something like C:/go/bin the following code does the conversion for an msys environment where C:/go/bin becomes /C/go/bin env.bash -------- export OLDPATH=$PATH if [ "$MSYSTEM" = "MINGW32" ]; then export PATH="/${GOBIN/:/}":/bin:/usr/bin:$PATH else export PATH="$GOBIN":/bin:/usr/bin:$PATH fi On Mon, Apr 18, 2011 at 6:15 PM, Joseph Poirier <jdpoirier@gmail.com> wrote: > ...left out the first part of the readme > > Go-dev issue 424905 moved GOBIN in front of /bin and /usr/bin in env.bash > which caused a bug to surface on the windows build, ie it caused the build > to break immediately under certain circumstances. > > Msys does the path conversion for GOBIN internally when it's set in env.bash > but not when GOBIN has already been set by the user. What gets prepended > when the user set GOBIN is c:/go/bin which doesn't work in Msys' unix > like environment, c:/go/bin should actually be converted to /c/go/bin for > it to work. > > By default, GOOS and GOARCH are set based on the host system if they aren't > already, they don't need to be set for a standard build. Likewise, GOROOT > and GOBIN can take on defaults set in env.bash and Msys handles the path > conversions without problem. > > tl;dr there's no need to set GOOS, GARCH, GOROOT, or GOBIN for a standard > Go build and setup. > > On Mon, Apr 18, 2011 at 6:11 PM, Joseph Poirier <jdpoirier@gmail.com> wrote: >> On Mon, Apr 18, 2011 at 4:49 PM, Mr_Dark <mr_dark@darkweb.nl> wrote: >>> You still need to fix $PATH otherwise it'll you will get that error. >>> >>> env.bash >>> - export PATH="$GOBIN":/bin:/usr/bin:$PATH >>> + export PATH=/bin:/usr/bin:"$GOBIN":$PATH >>> >>> On 18 apr, 23:22, go.peter...@gmail.com wrote: >>>> On 2011/04/18 20:49:55, Mr_Dark wrote: >>>> >>>> > Just converting the \ to / also works. MSYS/MinGW doesn't seem to have >>>> > a problem with that. >>>> > `c:\go\bin` -> `c:/go/bin` >>>> >>>> Windows: >>>> >>>> P:\>set GO >>>> GOARCH=386 >>>> GOBIN=p:/go/bin >>>> GOOS=windows >>>> GOROOT=p:/go >>>> >>>> MSYS/MinGW: >>>> >>>> $ hg id ab386ee780c0 tip >>>> >>>> $ env | grep 'GO' >>>> GOBIN=p:/go/bin >>>> GOARCH=386 >>>> GOROOT=p:/go >>>> GOOS=windows >>>> >>>> peter /p/go/src >>>> $ cd $GOROOT >>>> peter /p/go >>>> $ cd src >>>> peter p/go/src >>>> $ ./all.bash >>>> make: pwd: Command not found >>>> make: echo: Command not found >>>> make: *** [go-env] Error 127 >>>> Did not find Go environment variables. >>>> >>>> http://codereview.appspot.com/4368059/ >> >> I brought this up on the list http://tinyurl.com/44qo2qs >> >> From the readme I mention: >> >> Possible hacks when GOBIN and/or GOROOT are set by the user >> ================================================ >> >> msys.bat >> -------- >> if not "x%GOBIN%" == "x" set GOBIN=/%GOBIN::=% >> if not "x%GOROOT%" == "x" set GOROOT=/%GOROOT::=% >> >> *an extra forward slash gets added for some reason? >> >> >> env.bash >> -------- >> export OLDPATH=$PATH >> if [ "$MSYSTEM" = "MINGW32" ]; then >> export PATH="/${GOBIN/:/}":/bin:/usr/bin:$PATH >> else >> export PATH="$GOBIN":/bin:/usr/bin:$PATH >> fi >> >> ENVBASH="env.bash" >> if [ "$GOOS" = "windows" ]; then >> ENVBASH="winenv.bash" >> fi >> >> *are there any side effects? >> >> GOBIN >> ============= >> - it's where the tools get put >> - if no GOBIN exists it's set based on the path of the in progress build >> - GOBIN might have been set by the user, with two possibilities for >> how it's set: 1) explicit path or 2) appending bin to the expansion >> of GOROOT >> - env.bash creates GOBIN if it doesn't exist and prepends GOBIN to >> PATH, the freshly built Go toolchain should be used to build the >> packages, issue 424905 ensures it happens >> >
Sign in to reply to this message.
Joe, On 2011/04/19 02:08:28, Joe Poirier wrote: > - if GOBIN is hard coded to something like C:/go/bin the following > code does the conversion for an msys environment where C:/go/bin > becomes /C/go/bin > > env.bash > -------- > export OLDPATH=$PATH > if [ "$MSYSTEM" = "MINGW32" ]; then > export PATH="/${GOBIN/:/}":/bin:/usr/bin:$PATH > else > export PATH="$GOBIN":/bin:/usr/bin:$PATH > fi c:/go/bin -> c:/go/bin c:\go\bin -> /cgobin Peter
Sign in to reply to this message.
Joe, Sorry, it should have read, c:/go/bin -> /c/go/bin c:\go\bin -> /cgobin Peter
Sign in to reply to this message.
Joe, Plus, c:\go/bin -> /cgo/bin c:/go\bin -> /c/gobin First, replace \ by /. Peter
Sign in to reply to this message.
Joe, On 2011/04/19 02:08:28, Joe Poirier wrote: > env.bash > -------- > export OLDPATH=$PATH > if [ "$MSYSTEM" = "MINGW32" ]; then > export PATH="/${GOBIN/:/}":/bin:/usr/bin:$PATH > else > export PATH="$GOBIN":/bin:/usr/bin:$PATH > fi $MSYSTEM may be "MINGW32" or "MSYS". msys.bat: if "x%MSYSTEM%" == "x" set MSYSTEM=MINGW32 if "%1" == "MINGW32" set MSYSTEM=MINGW32 if "%1" == "MSYS" set MSYSTEM=MSYS You shouldn't assume that just because I'm using MSYS as a Unix-like shell that I'm using the MinGW 32-bit C compiler. I may be using MinGW 64-bit or some other C compiler. Peter
Sign in to reply to this message.
Thanks for all the information. I'm having a bit of a hard time following it but I trust the Windows experts. As I understand it, the problem right now is that if $GOBIN is incorrect for inclusion in $PATH, then it invalidates everything that follows it in the path. The current CL hides the problem by moving $GOBIN further down the $PATH, but it does not fix the real problem, namely that $GOBIN is not correct. So this CL is not okay. If someone sends a CL that makes env.bash work in more Windows configurations by addressing the $GOBIN problem itself, I will gladly apply it. Russ
Sign in to reply to this message.
On Tue, Apr 19, 2011 at 11:15 AM, Russ Cox <rsc@google.com> wrote: > Thanks for all the information. > I'm having a bit of a hard time following it but I trust > the Windows experts. > > As I understand it, the problem right now is that if $GOBIN > is incorrect for inclusion in $PATH, then it invalidates everything > that follows it in the path. The current CL hides the problem > by moving $GOBIN further down the $PATH, but it does not > fix the real problem, namely that $GOBIN is not correct. > So this CL is not okay. > > If someone sends a CL that makes env.bash work in more > Windows configurations by addressing the $GOBIN problem > itself, I will gladly apply it. > > Russ > Correct, it masks the problem. The msys shell environment handles the path conversions for the PATH environment variable but knows nothing about GOBIN. As long as the user does not set GOBIN via windows (using the normal windows path format) then GOBIN being set in env.bash works fine, because it sets it in a unix'y way. I guess if the user is absolutely sure the msys shell environment is being used, which for all practical purposes it would be at this point, GOBIN could be set via windows using a unix format and all would be fine. My previous replies were informational only and the readme I'd mentioned listed the work-around as a quick fix. Concerning forward and back slashes. I've always recommended using forward slashes on windows and my quick fix assumed the user understood/knew that. If I remember correctly, the (experimental at this point) 64 bit mingw/msys sets MINGW32 and will forever. There's a thread about it on one of the forum but I'll have to find it. For the CL to work it needs to: if windows: if GOBIN already exists: if back slashes in GOBIN path: convert back slashes to forward slashes convert colon to forward slash prepend forward slash add the modified GOBIN to the start of the new PATH -joe
Sign in to reply to this message.
I can do the CL tonight unless someone else has already started one? -joe On Tue, Apr 19, 2011 at 11:47 AM, Joseph Poirier <jdpoirier@gmail.com> wrote: > On Tue, Apr 19, 2011 at 11:15 AM, Russ Cox <rsc@google.com> wrote: >> Thanks for all the information. >> I'm having a bit of a hard time following it but I trust >> the Windows experts. >> >> As I understand it, the problem right now is that if $GOBIN >> is incorrect for inclusion in $PATH, then it invalidates everything >> that follows it in the path. The current CL hides the problem >> by moving $GOBIN further down the $PATH, but it does not >> fix the real problem, namely that $GOBIN is not correct. >> So this CL is not okay. >> >> If someone sends a CL that makes env.bash work in more >> Windows configurations by addressing the $GOBIN problem >> itself, I will gladly apply it. >> >> Russ >> > > Correct, it masks the problem. > > The msys shell environment handles the path conversions for the PATH > environment variable but knows nothing about GOBIN. As long as the > user does not set GOBIN via windows (using the normal windows path > format) then GOBIN being set in env.bash works fine, because it sets > it in a unix'y way. > > I guess if the user is absolutely sure the msys shell environment is > being used, which for all practical purposes it would be at this > point, GOBIN could be set via windows using a unix format and all > would be fine. > > My previous replies were informational only and the readme I'd > mentioned listed the work-around as a quick fix. > > Concerning forward and back slashes. I've always recommended using > forward slashes on windows and my quick fix assumed the user > understood/knew that. > > If I remember correctly, the (experimental at this point) 64 bit > mingw/msys sets MINGW32 and will forever. There's a thread about it on > one of the forum but I'll have to find it. > > For the CL to work it needs to: > > if windows: > if GOBIN already exists: > if back slashes in GOBIN path: > convert back slashes to forward slashes > convert colon to forward slash > prepend forward slash > add the modified GOBIN to the start of the new PATH > > -joe >
Sign in to reply to this message.
Joe, On 2011/04/19 16:47:52, Joe Poirier wrote: > For the CL to work it needs to: > > if windows: > if GOBIN already exists: > if back slashes in GOBIN path: > convert back slashes to forward slashes > convert colon to forward slash > prepend forward slash > add the modified GOBIN to the start of the new PATH This looks exactly like the set of conversion rules I use in Go. func GoPath(path string) string { if runtime.GOOS == "windows" { q := make([]byte, len(path)+1) p := q[1:] for i := 0; i < len(p); i++ { b := path[i] if b == '\\' { b = '/' } p[i] = b } // Windows volume, '^[a-zA-z]:' if len(p) >= 2 && p[1] == ':' { if v := p[0]; 'a' <= v && v <= 'z' || 'A' <= v && v <= 'Z' { p[1] = p[0] p[0] = '/' if len(p) >= 3 { if p[2] != '/' { p = q p[0] = p[1] p[1] = p[2] p[2] = '/' } } } } return string(p) } return path } Peter
Sign in to reply to this message.
Russ, You clearly understand the problem. We need a CL that converts $GOBIN from a Windows path to a Unix-like path before it's inserted in the $PATH list. This CL is not okay. Peter
Sign in to reply to this message.
|