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

Stablise program name in generated code preamble #610

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cmd/protoc-gen-connect-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ func generatePreamble(g *protogen.GeneratedFile, file *protogen.File) {
leadingComments(g, protogen.Comments(syntaxLocation.LeadingComments), false /* deprecated */)
g.P()

g.P("// Code generated by ", filepath.Base(os.Args[0]), ". DO NOT EDIT.")
programName := filepath.Base(os.Args[0])
// Remove .exe suffix on Windows so that generated code is stable, regardless
// of whether it was generated on a Windows machine or not.
if ext := filepath.Ext(programName); strings.ToLower(ext) == ".exe" {
programName = strings.TrimSuffix(programName, ext)
}
g.P("// Code generated by ", programName, ". DO NOT EDIT.")
g.P("//")
if file.Proto.GetOptions().GetDeprecated() {
wrapComments(g, file.Desc.Path(), " is a deprecated file.")
Expand Down