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/protoc-gen-go-grpc: don't emit const blocks for services with no methods #7055

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

conorevans
Copy link
Contributor

@conorevans conorevans commented Mar 20, 2024

Closes #7054

With proto of

syntax = "proto3";
package foobar;
option go_package = "github.com/foobar";

service Foobar {}

you get

// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc             v4.25.3
// source: service-foobar.proto

package foobar

import (
	grpc "google.golang.org/grpc"
)

// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7

const ()

// FoobarClient is the client API for Foobar service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type FoobarClient interface {
}

which causes a gofmt failure due to empty const block

RELEASE NOTES: none
(protoc-gen-go-grpc does not use these relnotes)

Signed-off-by: Conor Evans <coevans@tcd.ie>
Copy link

codecov bot commented Mar 20, 2024

Codecov Report

Merging #7055 (8322327) into master (4ffccf1) will decrease coverage by 0.25%.
Report is 2 commits behind head on master.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7055      +/-   ##
==========================================
- Coverage   82.62%   82.38%   -0.25%     
==========================================
  Files         300      300              
  Lines       31351    31351              
==========================================
- Hits        25905    25827      -78     
- Misses       4401     4458      +57     
- Partials     1045     1066      +21     

see 18 files with indirect coverage changes

@zasweq zasweq self-requested a review March 20, 2024 17:18
@zasweq zasweq self-assigned this Mar 20, 2024
Copy link
Contributor

@zasweq zasweq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although I don't think we guarantee generated protos pass gofmt.

@zasweq zasweq assigned dfawley and unassigned zasweq Mar 21, 2024
@zasweq zasweq requested a review from dfawley March 21, 2024 20:47
@zasweq
Copy link
Contributor

zasweq commented Mar 21, 2024

Passing to Doug for a second review.

@dfawley dfawley added this to the 1.64 Release milestone Mar 21, 2024
@dfawley dfawley changed the title fix: exit before writing const block if no service methods cmd/protoc-gen-go-grpc: don't emit const blocks for services with no methods Mar 21, 2024
@dfawley dfawley merged commit a975978 into grpc:master Mar 21, 2024
14 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

protoc-gen-go-grpc: empty const block causing gofmt failure
3 participants