Documentation
¶
Overview ¶
Package names provides AIP resource generic name, which allows to extract the resource name parts from the resource name.
Index ¶
- type Composer
- func (c *Composer) Name() string
- func (c *Composer) Reset()
- func (c *Composer) WriteEmptyPart()
- func (c *Composer) WriteIntPart(part int)
- func (c *Composer) WriteIntResource(resource string, id int)
- func (c *Composer) WritePart(part string)
- func (c *Composer) WriteResource(resource, id string)
- func (c *Composer) WriteUintPart(part uint)
- func (c *Composer) WriteUintResource(resource string, id uint)
- type Name
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Composer ¶
type Composer struct {
// contains filtered or unexported fields
}
Composer is a resource name composer.
func (*Composer) WriteEmptyPart ¶
func (c *Composer) WriteEmptyPart()
WriteEmptyPart writes an empty resource name part.
func (*Composer) WriteIntPart ¶
WriteIntPart writes a resource name part from an integer.
func (*Composer) WriteIntResource ¶
WriteIntResource writes the resource plural name along with the identifier.
func (*Composer) WriteResource ¶
WriteResource writes the resource plural name along with the identifier.
func (*Composer) WriteUintPart ¶
WriteUintPart writes a resource name part from an unsigned integer.
func (*Composer) WriteUintResource ¶
WriteUintResource writes the resource plural name along with the identifier.
type Name ¶
type Name string
Name is the generic resource name type. It is used to extract the resource name parts from the resource name. I.e.: 'projects/{project}/keys/{key} ->
Name.Part(0) = projects Name.Part(1) = {project} Name.Part(2) = keys Name.Part(3) = {key} Name.Part(4) = "" Name.Part(-1) = {key} Name.Part(-2) = keys Name.Part(-3) = {project} Name.Part(-4) = projects Name.Part(-5) = ""
func (Name) Part ¶
Part returns the i-th part of the resource name. The index i is zero-based, so the first part of the name has index 0. If i is negative, the part is counted from the end of the name (i.e. -1 is the last part). The function call is safe for out-of-range indices, thus, it can be used to iterate over the name parts. If the index is out of range, the function returns an empty string.