Documentation
¶
Overview ¶
Package naming implements protobuf-to-Go naming conventions aligned with protoc-gen-go. The core GoCamelCase function is ported from google.golang.org/protobuf/internal/strs (BSD-3-Clause license).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GoCamelCase ¶
GoCamelCase camel-cases a protobuf name for use as a Go identifier.
If there is an interior underscore followed by a lower case letter, drop the underscore and convert the letter to upper case.
Ported from google.golang.org/protobuf/internal/strs.GoCamelCase.
func GoEnumValueName ¶
GoEnumValueName returns the Go constant name for a protobuf enum value. The format is ParentGoName_PROTO_VALUE_NAME (no CamelCase on the value name itself), matching protoc-gen-go behavior.
parentGoName is the Go name of the containing type: the enum's Go name for top-level enums, or the message's Go name for enums nested in a message.
func GoFieldName ¶
GoFieldName returns the Go struct field name for a protobuf field name. It applies GoCamelCase to convert snake_case to CamelCase.
func GoScalarType ¶
func GoScalarType(kind model.ScalarKind) string
GoScalarType returns the Go type string for a protobuf scalar kind.
func GoTypeName ¶
GoTypeName returns the Go type name for a protobuf descriptor given its full name and the file's package name. Nested types use underscore separation (e.g., "Outer_Inner"), matching protoc-gen-go behavior.
The algorithm: strip the package prefix from the full name, then apply GoCamelCase to the remainder. Since GoCamelCase converts '.' followed by an uppercase letter to '_', nested types naturally get the Outer_Inner format.
func ResolveFieldNames ¶
ResolveFieldNames takes a slice of raw Go field names (already CamelCased) and returns a new slice with conflicts resolved. Each name is made unique against reserved names and previously assigned names, including their Get* accessors.
The order of the input slice matters: earlier fields claim names first, matching protoc-gen-go behavior.
Types ¶
This section is empty.