ats

package
v0.0.0-...-326b91d Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2019 License: MIT Imports: 1 Imported by: 8

Documentation

Overview

Package ats (= any to string) provides functions to Get a string from 'anything' (= interface{})

ats observes different conventions of 'things' (=objects) to do so:

stringer: String() - fmt.Stringer & friends
string:   string   - builtin type
namer:    Name()   - filepath.File & .FileInfo, text/template.Template ...
geter:    Get()    - do/Value
ider:     Id()     - ...

The different Get-functions just use a different sequence of attempts to obtain a meaningful string from interface{}, and return the best/first, or -as a last resort- a constant string such as "<not a Xyz>"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGet

func GetGet(any interface{}) string

GetGet - order: Get, String, string, Name, Id, "<not a Get>"

func GetId

func GetId(any interface{}) string

GetId - order: Id, Name, Get, String, string, "<not an Id>"

func GetName

func GetName(any interface{}) string

GetName - order: Name, Id, Get, String, string, "<not a Name>"

func GetString

func GetString(any interface{}) string

GetString - order: string, String, Get, Name, Id, "<not a String>"

Types

type Friendly

type Friendly interface {
	GetString() string // fmt.Stringer & friends
	GetName() string   // filepath.File & .FileInfo, text/template.Template ...
	GetGet() string    // do/Value
	GetId() string     // ...
}

Friendly - my interface - exposed for godoc - only ;-)

I love to be friendly - thus: I observe different popular API's to convert anything to a meaningful text string

Jump to

Keyboard shortcuts

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