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

protoc-gen-go generator missing type in printer #517

Closed
Tommy-42 opened this issue Feb 19, 2018 · 4 comments
Closed

protoc-gen-go generator missing type in printer #517

Tommy-42 opened this issue Feb 19, 2018 · 4 comments

Comments

@Tommy-42
Copy link

Tommy-42 commented Feb 19, 2018

Hello I had a strange error today while trying to generate some custom code:
2018/02/19 14:10:09 protoc-gen-gogo: error:unknown type in printer: int64

Looking into the P() implementation I am seeing

func (g *Generator) P(str ...interface{}) {
	if !g.writeOutput {
		return
	}
	g.WriteString(g.indent)
	for _, v := range str {
		switch s := v.(type) {
 			...
		case int:
			fmt.Fprintf(g, "%d", s)
		case *int32:
			fmt.Fprintf(g, "%d", *s)
		case *int64:
			fmt.Fprintf(g, "%d", *s)
		case float64:
			fmt.Fprintf(g, "%g", s)
		case *float64:
			fmt.Fprintf(g, "%g", *s)
		default:
			g.Fail(fmt.Sprintf("unknown type in printer: %T", v))
		}
	}
	g.WriteByte('\n')
}

There is no case for case int32: && case int64: ? there is any reason for that ?

If not, an open a PR is available.

Best regards,

@Tommy-42 Tommy-42 changed the title go generator missing type in printer protoc-gen-go generator missing type in printer Feb 19, 2018
@neild
Copy link
Contributor

neild commented Feb 21, 2018

The generator package's interface isn't really intended for general-purpose use. (README.md describes it as "not supported and subject to incompatible changes without notice".) Given that the package API is intentionally unsupported as it is, I think that extending it to support additional uses would be a mistake.

@awalterschulze
Copy link

Although it is something really simple to fix and the current behavior of only printing pointers to int64 and int32 and not int64 and int32 themselves is very weird.
Are you sure you don't want to make this fix?

@neild
Copy link
Contributor

neild commented Feb 26, 2018

I'm going to close this.

The generator package is not a supported public interface. If we make a change to it to support an additional external use, we are implicitly committing to supporting that use in the future. It's simply not practical to do that with the package API as it stands, and I don't want to give the false impression that we can do so.

@neild neild closed this as completed Feb 26, 2018
@dsnet
Copy link
Member

dsnet commented Mar 9, 2018

Discussion about whether to more strongly support plugins and if so, how is over at #547.

@golang golang locked and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants