nameutil

package
v0.6.14 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Root = "pkg"

Root is the project layout root stripped from every name so the category stays visible (services/db/manager, routers/user/router). Projects with a different layout may override or clear it.

Functions

func ConfigRoot added in v0.6.14

func ConfigRoot(name string) string

ConfigRoot returns the config key root a service reads its dynamic keys under, derived from its name alone: the package segment of a category-visible name (services/db/manager -> db, so an unnamed db instance reads db.connection.*), or the whole name when it has no path (a second instance named clickhouse reads clickhouse.connection.*). The auto name itself can never be a root - an env override cannot spell its slashes - which is why the segment, not the name, is the fallback.

func Name

func Name(obj any, strip ...string) string

Name returns obj's service name: its package dir relative to the project root, with Root stripped, joined with the type name (pkg/services/db + manager -> services/db/manager). Optional prefixes are stripped after Root, whole segments only, first match wins - Name(m, "services") turns services/db/manager into db/manager.

func Package added in v0.6.11

func Package(obj any) string

Package returns the base name of obj's package dir - the identity middlewares default to, where the package name is the middleware name (middlewares/cors -> cors).

Types

This section is empty.

Jump to

Keyboard shortcuts

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