protostrs

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2020 License: MIT Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CSharpNamespace added in v1.4.0

func CSharpNamespace(packageName string) string

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

func GoPackage(packageName string) string

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 added in v1.4.0

func GoPackageV2(packageName string) string

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

func JavaOuterClassname(filename string) string

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

func JavaPackage(packageName string) string

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 added in v1.4.0

func JavaPackagePrefixOverride(packageName string, prefixOverride string) string

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 added in v1.4.0

func MajorBetaVersion(packageName string) (uint64, uint64, bool)

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 added in v1.4.0

func OBJCClassPrefix(packageName string) string

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 added in v1.4.0

func PHPNamespace(packageName string) string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL