Help us shape the future of Go! Take the 2026 Go Developer Survey

name

package module
v1.1.0 Latest Latest
Warning

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

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

README

Name

Presenting names for English-language applications where a basic model of first and last name(s) combined is sufficient.

Based off of basecamp/name_of_person.

Installation

go get -u github.com/duffn/name

Examples

// The only possible error here is not providing a first name.
n, err := name.New("Bob", "Smith")

n.Full() // Bob Smith
n.Familiar() // Bob S.
n.Abbreviated() // B. Smith
n.Sorted() // Smith, Bob
n.Possessive() // Bob Smith's
n.Initials() // BS
n.Mentionable() // bobs

Tests

go test

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Name

type Name struct {
	FirstName string
	LastName  string
}

Name is a struct of a first and last name.

func New

func New(firstName string, lastName string) (*Name, error)

New returns a new Name struct or an error if firstName is empty.

func (*Name) Abbreviated

func (name *Name) Abbreviated() string

Abbreviated is the initial of the first name plus the last name, e.g. "J. Smith".

func (*Name) Familiar

func (name *Name) Familiar() string

Familiar is the first name plus last initial, e.g. "John S.".

func (*Name) Full

func (name *Name) Full() string

Full is the full name of a person, e.g. "John Smith".

func (*Name) Initials

func (name *Name) Initials() string

Initials provides a name's initials, e.g. "JS".

func (*Name) Mentionable

func (name *Name) Mentionable() string

Mentionable creates a mentionable name, e.g. "johns".

func (*Name) Possessive

func (name *Name) Possessive() string

Possessive adds "'s" or "'" to the end of a full name, e.g. "John Smith's".

func (*Name) Sorted

func (name *Name) Sorted() string

Sorted sorts the name for sorting, e.g. "Smith, John"

Jump to

Keyboard shortcuts

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