Skip to content

Commit

Permalink
fix: fix metadata bug
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkgos committed Apr 29, 2024
1 parent 80ecbe8 commit cfe288a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
13 changes: 10 additions & 3 deletions cmd/protoc-gen-dyn-gin/gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,19 @@ func lineComment(s string) string {
return ""
}
b := &strings.Builder{}
first := true
lines := strings.Split(strings.TrimSuffix(s, "\n"), "\n")
for i, line := range lines {
b.WriteString(strings.TrimSpace(strings.TrimPrefix(line, "//")))
if i+1 < len(lines) {
for _, line := range lines {
ss := strings.TrimSpace(strings.TrimPrefix(line, "//"))
if ss == "" {
continue
}
if !first {
b.WriteString(", ")
} else {
first = false
}
b.WriteString(ss)
}
return b.String()
}
4 changes: 3 additions & 1 deletion example/gen/hello/hello.gin.pb.go

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

4 changes: 4 additions & 0 deletions example/gen/hello/hello.resty.pb.go

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

4 changes: 4 additions & 0 deletions example/gen/hello/hello_grpc.pb.go

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

2 changes: 2 additions & 0 deletions example/proto/hello/hello.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import "google/api/annotations.proto";
// The greeting service definition.
service Greeter {
// Sends a hello
//
// 多一行
rpc SayHello(HelloRequest) returns (HelloReply) { // I am a trailing comment
option (google.api.http) = {
post: "/v1/hello",
Expand Down

0 comments on commit cfe288a

Please sign in to comment.