<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 10, 2015 at 6:13 PM, roger peppe <span dir="ltr"><<a href="mailto:roger.peppe@canonical.com" target="_blank">roger.peppe@canonical.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On 10 March 2015 at 12:52, John Meinel <<a href="mailto:john@arbash-meinel.com">john@arbash-meinel.com</a>> wrote:<br>
> So there are 2 changes that I encountered with upgrading go to 1.4.2:<br>
><br>
> 1) They changed how they sort import paths. Currently all our imports are:<br>
><br>
> "<a href="http://github.com/juju/juju/bar" target="_blank">github.com/juju/juju/bar</a>"<br>
> coretesting "<a href="http://github.com/juju/juju/testing" target="_blank">github.com/juju/juju/testing</a>"<br>
> (sorted by the import string)<br>
><br>
> It wants to sort them as:<br>
><br>
> coretesting "<a href="http://github.com/juju/juju/testing" target="_blank">github.com/juju/juju/testing</a>"<br>
> "<a href="http://github.com/juju/juju/bar" target="_blank">github.com/juju/juju/bar</a>"<br>
><br>
> (sorted by the local name)<br>
<br>
</span>Are you sure about this? I believe that <a href="http://play.golang.org" target="_blank">play.golang.org</a><br>
is running go 1.4 and this code is canonically formatted there,<br>
despite unordered local names: <a href="http://play.golang.org/p/5R8dyHJG5e" target="_blank">http://play.golang.org/p/5R8dyHJG5e</a><br>
<span class=""><br></span></blockquote><div><br></div><div>Yeah, I was wrong here. It had moved a line I hadn't changed, and I was confused, but it was user error, not the tool.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">
> 2) It no longer works if you have a symlink in your PWD<br>
> Because of the need for exact paths, I have a link from $HOME/jc =><br>
> $HOME/dev/go/src/<a href="http://github.com/juju/juju" target="_blank">github.com/juju/juju</a><br>
> However, if I do "go fmt" it now complains that:<br>
> stat ../../../dev/go/src/<a href="http://github.com/juju/juju/worker/uniter/deployer.go" target="_blank">github.com/juju/juju/worker/uniter/deployer.go</a>: no<br>
> such file or directory<br>
><br>
> (it seems to be using pwd -P and then using relative paths to that)<br>
><br>
> Anyone know why it would need to do that?<br>
><br>
> I can work around it with "cd jc; cd `pwd -P`" or some other form so I don't<br>
> have to type the long form each time.<br>
<br>
</span>Can you show a step-by-step way to reproduce this please?<br>
If you cd into jc, surely you are now in $HOME/dev/go/src/<a href="http://github.com/juju/juju" target="_blank">github.com/juju/juju</a>,<br>
and I don't see how that's a problem. (but I've not seen the pwd -P flag<br>
before and don't understand how that works either - how can the pwd<br>
command know what symlinks were used to get to the current working<br>
directory?)<br>
<br>
cheers,<br>
rog.<br></blockquote><div><br></div><div>So if I do:</div><div><br></div><div>$ cd $HOME</div><div>$ mkdir $HOME/dev/foo</div><div>$ ln -s $HOME/dev/foo bar</div><div>$ cd bar</div><div>$ echo $PWD</div><div>/home/jameinel/bar</div><div>$ pwd</div><div>/home/jameinel/bar</div><div>$ pwd -P</div><div>/home/jameinel/dev/foo</div><div><br></div><div>So Bash sets $PWD based on what you actually issued to "cd".</div><div>If I write this go code:</div><div><br></div><div>package main</div><div><br></div><div>import (</div><div> "os"<br> "fmt"</div><div> "path/filepath"</div><div>)</div><div><br></div><div>func main() {</div><div> dir, _ := os.Getwd()</div><div> fmt.Printf("dir: %s\n", dir)</div><div> pwd := os.Getenv("PWD")</div><div> fmt.Printf("PWD: %s\n", pwd)</div><div> expand, _ := filepath.EvalSymlinks(pwd)<br><div> fmt.Printf("expanded: %s\n", expand)</div>}</div><div><br></div><div><br></div><div>I get:</div><div><br></div><div>dir: /home/jameinel/dev/foo</div><div>PWD: /home/jameinel/bar</div><div>expanded: /home/jameinel/dev/foo</div><div><br></div><div>So it would seem that "go fmt" is using os.Getenv("PWD") or some variant instead of using os.Getwd().</div><div><br></div><div>What I *really* don't understand is that if I'm at the top level and I do "go fmt" it shows:</div><div><br></div><div>~/jc $ go fmt </div><div>...</div><div>stat ../dev/go/src/<a href="http://github.com/juju/juju/doc.go">github.com/juju/juju/doc.go</a>: no such file or directory</div><div><br></div><div>~/jc $ cd worker/uniter/filter</div><div>~/jc/worker/uniter/filter $ go fmt</div><div>...</div><div>stat ../../../../dev/go/src/<a href="http://github.com/juju/juju/worker/uniter/filter/filter.go">github.com/juju/juju/worker/uniter/filter/filter.go</a>: no such file or directory</div><div><br></div><div>I really don't understand all the interactions with PWD or why it is trying to stat "../../../../". How does it know about dev/go/src/<a href="http://github.com/juju/juju">github.com/juju/juju</a> but then try to apply that to PWD?</div><div><br></div><div>If you have go 1.4 it should be easy to test this.</div><div><br></div><div>John</div><div>=:-></div></div></div></div>