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
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@YoshikiShibata
Copy link

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.

@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 26, 2020
@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Aug 26, 2020
@griesemer
Copy link
Contributor

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

@griesemer griesemer added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Aug 26, 2020
@gopherbot
Copy link

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

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

@YoshikiShibata
Copy link
Author

@griesemer Thanks for the fix!!!

@golang golang locked and limited conversation to collaborators Aug 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants