Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
The Go compiler automatically takes the address of a value V when a method is called which is defined on a *V receiver. The "text/template" package should do the same. See the attached example for further details. https://groups.google.com/d/msg/golang-nuts/eKSiPCAalMQ/O5JpDk8QpxUJ
Despite my "first blush" comment, this is not a bug. The template package handles this correctly. The example here is a textbook version of the 'settability' issue described near the end of the "Laws of Reflection" blog post: http://blog.golang.org/2011/09/laws-of-reflection.html. When p2 is passed to the template library, the library receives a copy of p2, not p2 itself. It would be incorrect to take its address to discover the method. Go in general behaves the same way; if you say p2.X() the compiler can take the address of the local variable p2, but that's not the same as passing p2 to a function, calling X, and expecting the original p2 to be updated. Working as intended, if subtly.
Status changed to WorkingAsIntended.