Skip to content

Commit

Permalink
chore: dont generate interface method
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps committed Nov 6, 2023
1 parent a2390a3 commit 720accd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
14 changes: 4 additions & 10 deletions internal/cmd/protoc-gen-go-flipt-sdk/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ func generateGRPC(gen *protogen.Plugin) {

if len(file.Services) < 2 {
srv := file.Services[0]
if srv.Comments.Leading != "" {
leading := strings.TrimPrefix(string(srv.Comments.Leading), "//")
if strings.TrimSpace(leading) == ignoreDecl {
continue
}
if shouldIgnoreService(srv) {
continue
}

returnType := file.Services[0].GoName + "Client"
Expand All @@ -60,11 +57,8 @@ func generateGRPC(gen *protogen.Plugin) {
g.P("}\n")

for _, srv := range file.Services {
if srv.Comments.Leading != "" {
leading := strings.TrimPrefix(string(srv.Comments.Leading), "//")
if strings.TrimSpace(leading) == ignoreDecl {
continue
}
if shouldIgnoreService(srv) {
continue
}

returnType := srv.GoName + "Client"
Expand Down
14 changes: 4 additions & 10 deletions internal/cmd/protoc-gen-go-flipt-sdk/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,8 @@ func generateHTTP(gen *protogen.Plugin, grpcAPIConfig string) {

if len(file.Services) < 2 {
srv := file.Services[0]
if srv.Comments.Leading != "" {
leading := strings.TrimPrefix(string(srv.Comments.Leading), "//")
if strings.TrimSpace(leading) == ignoreDecl {
continue
}
if shouldIgnoreService(srv) {
continue
}

returnType := srv.GoName + "Client"
Expand Down Expand Up @@ -175,11 +172,8 @@ func generateHTTP(gen *protogen.Plugin, grpcAPIConfig string) {
g.P("}\n")

for _, srv := range file.Services {
if srv.Comments.Leading != "" {
leading := strings.TrimPrefix(string(srv.Comments.Leading), "//")
if strings.TrimSpace(leading) == ignoreDecl {
continue
}
if shouldIgnoreService(srv) {
continue
}

var (
Expand Down
19 changes: 14 additions & 5 deletions internal/cmd/protoc-gen-go-flipt-sdk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ func generateSubSDK(gen *protogen.Plugin, file *protogen.File) (typ, client stri

g.P("type ", typ, "Client interface {")
for _, srv := range file.Services {
if shouldIgnoreService(srv) {
continue
}

g.P(srv.GoName+"Client", "()", relativeImport(g, file, srv.GoName+"Client"))
}
g.P("}\n")
Expand All @@ -132,11 +136,8 @@ func generateSubSDK(gen *protogen.Plugin, file *protogen.File) (typ, client stri
}

for _, srv := range file.Services {
if srv.Comments.Leading != "" {
leading := strings.TrimPrefix(string(srv.Comments.Leading), "//")
if strings.TrimSpace(leading) == ignoreDecl {
continue
}
if shouldIgnoreService(srv) {
continue
}

serviceName := srv.GoName
Expand Down Expand Up @@ -271,3 +272,11 @@ func New(t Transport, opts ...Option) SDK {
return sdk
}`

func shouldIgnoreService(srv *protogen.Service) bool {
if srv.Comments.Leading != "" {
leading := strings.TrimPrefix(string(srv.Comments.Leading), "//")
return strings.TrimSpace(leading) == ignoreDecl
}
return false
}
1 change: 0 additions & 1 deletion sdk/go/evaluation.sdk.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 720accd

Please sign in to comment.