naming

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package naming contains some utilities for generating names.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AfterDot added in v0.52.0

func AfterDot(s string) string

AfterDot returns the part of the string after the first dot.

If there is no dot in the string or dot is the first character, the whole string is returned.

func Capitalize

func Capitalize(s string) string

Capitalize converts first character to upper.

If the string is invalid UTF-8 or empty, it is returned as is.

func Rule

func Rule(part string) (string, bool)

Rule returns the rule for the given part using the default ruleset, if any. Otherwise, it returns ("", false).

Types

type Ruleset added in v1.23.0

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

Ruleset maps lowered word parts to their canonical initialism form (e.g. "id" -> "ID"). Matching is case-insensitive.

Use DefaultRuleset to get a copy of ogen's built-in initialisms, or NewRuleset to build a custom set from scratch.

func DefaultRuleset added in v1.23.0

func DefaultRuleset() *Ruleset

DefaultRuleset returns a fresh Ruleset containing ogen's built-in initialisms. The returned Ruleset is safe to mutate via Ruleset.Add.

func NewRuleset added in v1.23.0

func NewRuleset(initialisms ...string) *Ruleset

NewRuleset builds a Ruleset from the given canonical initialisms. Each initialism is matched case-insensitively against word parts.

func (*Ruleset) Add added in v1.23.0

func (r *Ruleset) Add(initialism string)

Add registers an initialism in the ruleset, overriding any existing rule that matches case-insensitively. Empty strings are ignored.

func (*Ruleset) Merge added in v1.23.0

func (r *Ruleset) Merge(other *Ruleset)

Merge copies all rules from other into r, overriding rules that match case-insensitively.

func (*Ruleset) Rule added in v1.23.0

func (r *Ruleset) Rule(part string) (string, bool)

Rule returns the canonical initialism for the given part, if any. Otherwise, it returns ("", false).

Jump to

Keyboard shortcuts

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