Documentation ¶
Overview ¶
Package protostrs contains common string manipulation functionality for Protobuf packages and files.
This is used in the format, lint, and create packages. The Java rules in this package roughly follow https://cloud.google.com/apis/design/file_structure.
Index ¶
- func CSharpNamespace(packageName string) string
- func GoPackage(packageName string) string
- func GoPackageV2(packageName string) string
- func JavaOuterClassname(filename string) string
- func JavaPackage(packageName string) string
- func JavaPackagePrefixOverride(packageName string, prefixOverride string) string
- func MajorBetaVersion(packageName string) (uint64, uint64, bool)
- func OBJCClassPrefix(packageName string) string
- func PHPNamespace(packageName string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CSharpNamespace ¶
CSharpNamespace returns the value for the file option "csharp_namespace" given a package name. It will capitalize each part of the package name taking special care for beta packages.
func GoPackage ¶
GoPackage returns the value for the file option "go_package" given a package name. This will be equal to the last value of the package separated by "."s, followed by "pb". If packageName is empty, this will return an empty string.
func GoPackageV2 ¶
GoPackageV2 returns the value for the file option "go_package" given a package name. This will be equal to the last two values of the package separated by "."s if the package is a MajorBetaPackage, or GoPackage otherwise.
func JavaOuterClassname ¶
JavaOuterClassname returns the value for the file option "java_outer_classname" given a file name. This will be equal to the basename of the file with it's extension stripped, UpperCamelCased, followed by "Proto". If filename is empty, this will return an empty string.
func JavaPackage ¶
JavaPackage returns the value for the file option "java_package" given a package name. This will be equal to "com." followed by the package. If packageName is empty, this will return an empty string.
func JavaPackagePrefixOverride ¶
JavaPackagePrefixOverride returns the value for the file option "java_package" given a package name. This will be equal to "com." followed by the package. If prefixOverride is set, this will be equal to prefixOveride.package. If packageName is empty, this will return an empty string.
func MajorBetaVersion ¶
MajorBetaVersion extracts the major and beta version number from the package name, if present. A package must be of the form "foo.vMAJORVERSION" or "foo.vMAJORVERSIONbetaBETAVERSION" . Returns the major version, beta version and true if the package is of this form, 0 and false otherwise. If there is no beta version, 0 is returned. Valid versions are >=1.
func OBJCClassPrefix ¶
OBJCClassPrefix returns the value for the file option "objc_class_prefix" given a package name. It takes the first letter of each package part and capitalizes it, then concatenates these. If the length is 2, an "X" is added. If the length is 1, "XX" is added. If the length is 0, this returns empty. If the name is "GPB", this returns "GPX". The version part is dropped before all operations.
func PHPNamespace ¶
PHPNamespace returns the value for the file option "php_namespace" given a package name. It will capitalize each part of the package name taking special care for beta packages.
Types ¶
This section is empty.