-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve templates, some minor package restructure
- Loading branch information
1 parent
9f60505
commit 498cd36
Showing
14 changed files
with
140 additions
and
199 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package proto | ||
|
||
import ( | ||
"errors" | ||
"strconv" | ||
|
||
"github.com/golang/protobuf/protoc-gen-go/descriptor" | ||
) | ||
|
||
// FullName is a template wrapper for protocol buffer descriptor names. | ||
func FullName(desc ...interface{}) (string, error) { | ||
switch len(desc) { | ||
case 2: | ||
file := desc[0].(*descriptor.FileDescriptorProto) | ||
svc := desc[1].(*descriptor.ServiceDescriptorProto) | ||
|
||
return ServiceFullName(file, svc), nil | ||
|
||
case 3: | ||
file := desc[0].(*descriptor.FileDescriptorProto) | ||
svc := desc[1].(*descriptor.ServiceDescriptorProto) | ||
method := desc[2].(*descriptor.MethodDescriptorProto) | ||
|
||
return MethodFullName(file, svc, method), nil | ||
|
||
default: | ||
return "", errors.New("unexpected amount of arguments (expected 2 or 3, got " + strconv.Itoa(len(desc))) | ||
} | ||
} | ||
|
||
// ServiceFullName creates a fully qualified name for the service. | ||
func ServiceFullName(file *descriptor.FileDescriptorProto, svc *descriptor.ServiceDescriptorProto) string { | ||
prefix := "" | ||
|
||
if pkg := file.GetPackage(); pkg != "" { | ||
prefix = pkg + "." | ||
} | ||
|
||
return prefix + svc.GetName() | ||
} | ||
|
||
// MethodFullName creates a fully qualified name for the service. | ||
func MethodFullName(file *descriptor.FileDescriptorProto, svc *descriptor.ServiceDescriptorProto, method *descriptor.MethodDescriptorProto) string { | ||
return ServiceFullName(file, svc) + "/" + method.GetName() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.