strs

package
v1.33.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package strs provides string manipulation functionality specific to protobuf.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnforceUTF8

func EnforceUTF8(fd protoreflect.FieldDescriptor) bool

EnforceUTF8 reports whether to enforce strict UTF-8 validation.

func EnumValueName

func EnumValueName(s string) string

EnumValueName derives the camel-cased enum value name. See protoc v3.8.0: src/google/protobuf/descriptor.cc:297-313

func GoCamelCase

func GoCamelCase(s string) string

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.

func GoSanitized

func GoSanitized(s string) string

GoSanitized converts a string to a valid Go identifier.

func JSONCamelCase

func JSONCamelCase(s string) string

JSONCamelCase converts a snake_case identifier to a camelCase identifier, according to the protobuf JSON specification.

func JSONSnakeCase

func JSONSnakeCase(s string) string

JSONSnakeCase converts a camelCase identifier to a snake_case identifier, according to the protobuf JSON specification.

func MapEntryName

func MapEntryName(s string) string

MapEntryName derives the name of the map entry message given the field name. See protoc v3.8.0: src/google/protobuf/descriptor.cc:254-276,6057

func TrimEnumPrefix

func TrimEnumPrefix(s, prefix string) string

TrimEnumPrefix trims the enum name prefix from an enum value name, where the prefix is all lowercase without underscores. See protoc v3.8.0: src/google/protobuf/descriptor.cc:330-375

func UnsafeBytes

func UnsafeBytes(s string) []byte

UnsafeBytes returns an unsafe bytes slice reference of s. The caller must treat returned slice as immutable.

WARNING: Use carefully. The returned result must not leak to the end user.

func UnsafeString

func UnsafeString(b []byte) string

UnsafeString returns an unsafe string reference of b. The caller must treat the input slice as immutable.

WARNING: Use carefully. The returned result must not leak to the end user unless the input slice is provably immutable.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder builds a set of strings with shared lifetime. This differs from strings.Builder, which is for building a single string.

func (*Builder) AppendFullName

func (sb *Builder) AppendFullName(prefix protoreflect.FullName, name protoreflect.Name) protoreflect.FullName

AppendFullName is equivalent to protoreflect.FullName.Append, but optimized for large batches where each name has a shared lifetime.

func (*Builder) MakeString

func (sb *Builder) MakeString(b []byte) string

MakeString is equivalent to string(b), but optimized for large batches with a shared lifetime.

Jump to

Keyboard shortcuts

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