Documentation ¶
Index ¶
- Constants
- func GoPackageImportPathForFile(imageFile bufimage.ImageFile, importPathPrefix string) string
- type Modifier
- func CcEnableArenas(logger *zap.Logger, sweeper Sweeper, value bool, overrides map[string]string) (Modifier, error)
- func CsharpNamespace(logger *zap.Logger, sweeper Sweeper, except []bufmoduleref.ModuleIdentity, ...) Modifier
- func GoPackage(logger *zap.Logger, sweeper Sweeper, defaultImportPathPrefix string, ...) (Modifier, error)
- func JavaMultipleFiles(logger *zap.Logger, sweeper Sweeper, value bool, overrides map[string]string, ...) (Modifier, error)
- func JavaOuterClassname(logger *zap.Logger, sweeper Sweeper, overrides map[string]string, ...) Modifier
- func JavaPackage(logger *zap.Logger, sweeper Sweeper, defaultPrefix string, ...) (Modifier, error)
- func JavaStringCheckUtf8(logger *zap.Logger, sweeper Sweeper, value bool, overrides map[string]string) (Modifier, error)
- func Merge(left Modifier, right Modifier) Modifier
- func NewMultiModifier(modifiers ...Modifier) Modifier
- func ObjcClassPrefix(logger *zap.Logger, sweeper Sweeper, defaultPrefix string, ...) Modifier
- func OptimizeFor(logger *zap.Logger, sweeper Sweeper, ...) (Modifier, error)
- func PhpMetadataNamespace(logger *zap.Logger, sweeper Sweeper, overrides map[string]string) Modifier
- func PhpNamespace(logger *zap.Logger, sweeper Sweeper, overrides map[string]string) Modifier
- func RubyPackage(logger *zap.Logger, sweeper Sweeper, except []bufmoduleref.ModuleIdentity, ...) Modifier
- type ModifierFunc
- type Sweeper
Constants ¶
const ( // DefaultJavaMultipleFilesValue is the default value for the java_multiple_files modifier. DefaultJavaMultipleFilesValue = true // JavaMultipleFilesID is the ID of the java_multiple_files modifier. JavaMultipleFilesID = "JAVA_MULTIPLE_FILES" )
const ( // DefaultJavaPackagePrefix is the default java_package prefix used in the java_package modifier. DefaultJavaPackagePrefix = "com" // JavaPackageID is the ID of the java_package modifier. JavaPackageID = "JAVA_PACKAGE" )
const CcEnableArenasID = "CC_ENABLE_ARENAS"
CcEnableArenasID is the ID of the cc_enable_arenas modifier.
const CsharpNamespaceID = "CSHARP_NAMESPACE"
CsharpNamespaceID is the ID of the csharp_namespace modifier.
const GoPackageID = "GO_PACKAGE"
GoPackageID is the ID of the go_package modifier.
const JavaOuterClassNameID = "JAVA_OUTER_CLASSNAME"
JavaOuterClassNameID is the ID for the java_outer_classname modifier.
const JavaStringCheckUtf8ID = "JAVA_STRING_CHECK_UTF8"
JavaStringCheckUtf8ID is the ID of the java_string_check_utf8 modifier.
const ObjcClassPrefixID = "OBJC_CLASS_PREFIX"
ObjcClassPrefixID is the ID of the objc_class_prefix modifier.
const OptimizeForID = "OPTIMIZE_FOR"
OptimizeForID is the ID for the optimize_for modifier.
const PhpMetadataNamespaceID = "PHP_METADATA_NAMESPACE"
PhpMetadataNamespaceID is the ID of the php_metadata_namespace modifier.
const PhpNamespaceID = "PHP_NAMESPACE"
PhpNamespaceID is the ID of the php_namespace modifier.
const RubyPackageID = "RUBY_PACKAGE"
RubyPackageID is the ID of the ruby_package modifier.
Variables ¶
This section is empty.
Functions ¶
func GoPackageImportPathForFile ¶
GoPackageImportPathForFile returns the go_package import path for the given ImageFile. If the package contains a version suffix, and if there are more than two components, concatenate the final two components. Otherwise, we exclude the ';' separator and adopt the default behavior from the import path.
For example, an ImageFile with `package acme.weather.v1;` will include `;weatherv1` in the `go_package` declaration so that the generated package is named as such.
Types ¶
type Modifier ¶
type Modifier interface { // Modify modifies the Image. Modify(context.Context, bufimage.Image) error }
Modifier modifies Images.
func CcEnableArenas ¶
func CcEnableArenas( logger *zap.Logger, sweeper Sweeper, value bool, overrides map[string]string, ) (Modifier, error)
CcEnableArenas returns a Modifier that sets the cc_enable_arenas file option to the given value in all of the files contained in the Image.
func CsharpNamespace ¶
func CsharpNamespace( logger *zap.Logger, sweeper Sweeper, except []bufmoduleref.ModuleIdentity, moduleOverrides map[bufmoduleref.ModuleIdentity]string, overrides map[string]string, ) Modifier
CsharpNamespace returns a Modifier that sets the csharp_namespace file option according to the package name. It is set to the package name with each package sub-name capitalized.
func GoPackage ¶
func GoPackage( logger *zap.Logger, sweeper Sweeper, defaultImportPathPrefix string, except []bufmoduleref.ModuleIdentity, moduleOverrides map[bufmoduleref.ModuleIdentity]string, overrides map[string]string, ) (Modifier, error)
GoPackage returns a Modifier that sets the go_package file option according to the given defaultImportPathPrefix, exceptions, and overrides.
func JavaMultipleFiles ¶
func JavaMultipleFiles( logger *zap.Logger, sweeper Sweeper, value bool, overrides map[string]string, preserveExistingValue bool, ) (Modifier, error)
JavaMultipleFiles returns a Modifier that sets the java_multiple_files file option to the given value in all of the files contained in the Image. If the preserveExistingValue is set to true, then the java_multiple_files option will be preserved if set.
func JavaOuterClassname ¶
func JavaOuterClassname( logger *zap.Logger, sweeper Sweeper, overrides map[string]string, preserveExistingValue bool, ) Modifier
JavaOuterClassname returns a Modifier that sets the java_outer_classname file option in all of the files contained in the Image based on the PascalCase of their filename. If the preserveExistingValue is set to true, then the java_outer_classname option will be preserved if set.
func JavaPackage ¶
func JavaPackage( logger *zap.Logger, sweeper Sweeper, defaultPrefix string, except []bufmoduleref.ModuleIdentity, moduleOverrides map[bufmoduleref.ModuleIdentity]string, overrides map[string]string, ) (Modifier, error)
JavaPackage returns a Modifier that sets the java_package file option according to the given packagePrefix.
func JavaStringCheckUtf8 ¶
func JavaStringCheckUtf8( logger *zap.Logger, sweeper Sweeper, value bool, overrides map[string]string, ) (Modifier, error)
JavaStringCheckUtf8 returns a Modifier that sets the java_string_check_utf8 file option according to the given value.
func Merge ¶
Merge merges the given modifiers together so that they are run in the order they are provided. This is particularly useful for constructing a modifier from its initial 'nil' value.
var modifier Modifier if config.JavaMultipleFiles { modifier = Merge(modifier, JavaMultipleFiles) }
func NewMultiModifier ¶
NewMultiModifier returns a new Modifier for the given Modifiers.
func ObjcClassPrefix ¶
func ObjcClassPrefix( logger *zap.Logger, sweeper Sweeper, defaultPrefix string, except []bufmoduleref.ModuleIdentity, moduleOverride map[bufmoduleref.ModuleIdentity]string, overrides map[string]string, ) Modifier
ObjcClassPrefix returns a Modifier that sets the objc_class_prefix file option according to the package name. It is set to the uppercase first letter of each package sub-name, not including the package version, with the following rules:
- If the resulting abbreviation is 2 characters, add "X".
- If the resulting abbreviation is 1 character, add "XX".
- If the resulting abbreviation is "GPB", change it to "GPX". "GPB" is reserved by Google for the Protocol Buffers implementation.
func OptimizeFor ¶
func OptimizeFor( logger *zap.Logger, sweeper Sweeper, defaultOptimizeFor descriptorpb.FileOptions_OptimizeMode, except []bufmoduleref.ModuleIdentity, moduleOverrides map[bufmoduleref.ModuleIdentity]descriptorpb.FileOptions_OptimizeMode, overrides map[string]string, ) (Modifier, error)
OptimizeFor returns a Modifier that sets the optimize_for file option to the given value in all of the files contained in the Image.
func PhpMetadataNamespace ¶
func PhpMetadataNamespace( logger *zap.Logger, sweeper Sweeper, overrides map[string]string, ) Modifier
PhpMetadataNamespace returns a Modifier that sets the php_metadata_namespace file option according to the package name. It appends "\\GPBMetadata" to the heuristic used by PhpNamespace.
func PhpNamespace ¶
PhpNamespace returns a Modifier that sets the php_namespace file option according to the package name. It is set to the package name with each package sub-name capitalized and each "." replaced with "\\".
func RubyPackage ¶
func RubyPackage( logger *zap.Logger, sweeper Sweeper, except []bufmoduleref.ModuleIdentity, moduleOverrides map[bufmoduleref.ModuleIdentity]string, overrides map[string]string, ) Modifier
RubyPackage returns a Modifier that sets the ruby_package file option according to the given packagePrefix. It is set to the package name with each package sub-name capitalized and each "." replaced with "::".
type ModifierFunc ¶
ModifierFunc is a convenience type that implements the Modifier interface.
type Sweeper ¶
type Sweeper interface { // Sweep implements the ModifierFunc signature so that the Sweeper // can be used as a Modifier. Sweep(context.Context, bufimage.Image) error // contains filtered or unexported methods }
Sweeper is used to mark-and-sweep SourceCodeInfo_Locations from images.
func NewFileOptionSweeper ¶
func NewFileOptionSweeper() Sweeper
NewFileOptionSweeper constructs a new file option Sweeper that removes the SourceCodeInfo_Locations associated with the marks.
Source Files ¶
- bufimagemodify.go
- cc_enable_arenas.go
- csharp_namespace.go
- file_option_sweeper.go
- go_package.go
- java_multiple_files.go
- java_outer_classname.go
- java_package.go
- java_string_check_utf8.go
- multi_modifier.go
- objc_class_prefix.go
- optimize_for.go
- php_metadata_namespace.go
- php_namespace.go
- ruby_package.go
- usage.gen.go