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/cmd/eg: invalid double expansion #10937

Closed
crawshaw opened this issue May 22, 2015 · 3 comments
Closed

x/tools/cmd/eg: invalid double expansion #10937

crawshaw opened this issue May 22, 2015 · 3 comments
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@crawshaw
Copy link
Member

$ cat $GOPATH/src/p/p.go
package p

type S struct{ R int }

type T struct{ *S }

func F(t T) int { return t.R }
$ cat template.go
package p

import "p"

func before(t p.T) int { return t.R }
func after(t p.T) int  { return t.S.R }

Run with eg -t template.go junk produces:

package p

type S struct{ R int }

type T struct{ *S }

func F(t T) int { return t.S.S.R }

One too many .S.

@josharian
Copy link
Contributor

Dup of #10252? (Sorry about the lousy title on that bug.)

Incidentally, my workaround for this so far has been to use a very distinctive string for S, run eg, use gofmt -r to convert .S.S to .S, and then use gorename to make .S be the string I originally wanted.

@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Jun 3, 2015
@Ripounet
Copy link

Yes this looks like a dupe of #10252.

I noticed the same problem each time the "after" matches the "before" pattern, e.g. :

func before(str string) string { return strings.ToLower(str) }
func after(str string) string  { return strings.ToLower("[" + str + "]") }

-> brackets added twice instead of once.

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 12, 2019
@stamblerre
Copy link
Contributor

Duplicate of #10252

@stamblerre stamblerre marked this as a duplicate of #10252 Apr 14, 2020
@golang golang locked and limited conversation to collaborators Apr 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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