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

cmd/go2go: please update gofmt #41053

Closed
YoshikiShibata opened this issue Aug 26, 2020 · 4 comments
Closed

cmd/go2go: please update gofmt #41053

YoshikiShibata opened this issue Aug 26, 2020 · 4 comments
Assignees
Labels
Milestone

Comments

@YoshikiShibata
Copy link

@YoshikiShibata YoshikiShibata commented Aug 26, 2020

Now the translator rejects the following code with generic.go2:10:20: expected operand, found 'type' (and 4 more errors)

type genericStream[type T any] struct {
    prevReq  chan struct{}
    prevData chan T
    nextReq  chan struct{}
    nextData chan T
}

func newGenericStream[type T any](gs *genericStream[T]) *genericStream[T] {
    return &genericStream[T]{
        prevReq:  gs.nextReq,
        prevData: gs.nextData,
        nextReq:  make(chan struct{}),
        nextData: make(chan T), 
    }   
}

So I just modified like this:

type genericStream[T any] struct {
    prevReq  chan struct{}
    prevData chan T
    nextReq  chan struct{}
    nextData chan T
}

func newGenericStream[T any](gs *genericStream[T]) *genericStream[T] {
    return &genericStream[T]{
        prevReq:  gs.nextReq,
        prevData: gs.nextData,
        nextReq:  make(chan struct{}),
        nextData: make(chan T), 
    }   
}

Now the translator translate this code, but gofmt will insert the deleted type again.

gofmt is important because it is the only tool to format *.go2 files.

Or this might be an issue for the translator.

@griesemer
Copy link
Contributor

@griesemer griesemer commented Aug 26, 2020

Thanks for this issue. I missed that. Will take care of this today or tomorrow.

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 27, 2020

Change https://golang.org/cl/250998 mentions this issue: [dev.go2go] go/printer: don't write "type" keyword in type parameter lists if brackets are used

gopherbot pushed a commit that referenced this issue Aug 27, 2020
…lists if brackets are used

When the printer mode UseBrackets is set, use the new unified parameter
list syntax: use []'s for type parameters without the "type" keyword.
This will also change gofmt behavior accordingly.

Fixes #41053.

Change-Id: Ibaf490ea9ed178684bea34da5b57afa823a6829f
Reviewed-on: https://go-review.googlesource.com/c/go/+/250998
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
@griesemer
Copy link
Contributor

@griesemer griesemer commented Aug 27, 2020

This should be fixed now in the dev.go2go branch with https://golang.org/cl/250998.

@griesemer griesemer closed this Aug 27, 2020
@YoshikiShibata
Copy link
Author

@YoshikiShibata YoshikiShibata commented Aug 27, 2020

@griesemer Thanks for the fix!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.