utils

package module
v0.0.0-...-da676ab Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2016 License: MIT Imports: 10 Imported by: 0

README

go-utils

Currently this is just a wrapper around github.com/segmentio's 2 fast case parses:

github.com/segmentio/go-camelcase

github.com/segmentio/go-snakecase

With an added Pascal Case function:

func CamelCase(str string) string
func SnakeCase(str string) string
func PascalCase(str string) string

Thank you @tj for switching to Go just before we did! ;)

Documentation

Overview

utils are currently just a wrapper on top of github/segmentio's extremely fast Camelcase and Snakecase functions, with an added PascalCase.

Thank you @tj for switching to Go just before we did! ;)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CamelCase

func CamelCase(str string) string

func GetCallStack

func GetCallStack() (stack []string)

func GetCallerName

func GetCallerName(skip int) (callerName string)

func GetCallerNames

func GetCallerNames(skip int) (typeName, callerName string)

func InterfaceToReflect

func InterfaceToReflect(val interface{}) (reflectValue reflect.Value, err error)

InterfaceToReflect helps ensure the reflect value is in an editable state It will check the type and get the correct reference if possible TODO(morphar) Make some tests

func KebabCase

func KebabCase(str string) string

func PascalCase

func PascalCase(str string) string

func PrintCallStack

func PrintCallStack()

func Slug

func Slug(str string) string

func SnakeCase

func SnakeCase(str string) string

func StringInSlice

func StringInSlice(searchStr string, strs []string) bool

func UnCase

func UnCase(str string) string

func Unique

func Unique(arr interface{}) (unique interface{}, err error)

func UniqueInts

func UniqueInts(arr []int) (unique []int)

func UniqueStrings

func UniqueStrings(arr []string) (unique []string)

Types

type ProtobufInfo

type ProtobufInfo struct {
	Type      string // wire encoding
	TagNumber int    // protocol tag number
	Optional  bool   // opt,req,rep for optional, required, or repeated
	Required  bool   // opt,req,rep for optional, required, or repeated
	Repeated  bool   // opt,req,rep for optional, required, or repeated
	Name      string // name= the original declared name
	Enum      string // enum= the name of the enum type if it is an enum-typed field.
	Proto3    bool   // proto3 if this field is in a proto3 message

}

type ProtobufTag

type ProtobufTag string

type TagString

type TagString reflect.StructTag

func (*TagString) Add

func (tag *TagString) Add(key string, val string)

Add adds the tag to the TagString

func (*TagString) AddMulti

func (tag *TagString) AddMulti(keyVals map[string]string)

AddMulti adds multiple tags to the TagString

func (TagString) Get

func (tag TagString) Get(key string) string

func (*TagString) ProtobufInfo

func (tag *TagString) ProtobufInfo() (pbInfo *ProtobufInfo)

func (*TagString) Remove

func (tag *TagString) Remove(key string) (err error)

Remove removes tags identified by key Returns an error if the key was not understood

func (*TagString) RemoveMulti

func (tag *TagString) RemoveMulti(keys []string) (err error)

RemoveMulti removes all the tags identified by the keys in the keys array Returns an error if one or more keys was not understood

func (*TagString) Set

func (tag *TagString) Set(key string, val string) (success bool)

Set ONLY sets the tag identified by key, if it already exists Returns true if a tag was found and changed

func (*TagString) SetMulti

func (tag *TagString) SetMulti(keyVals map[string]string) (success bool)

SetMulti ONLY sets the tags identified by the keys, if they already exists Returns false if one or more tag was not changed

func (*TagString) Sort

func (tag *TagString) Sort()

Sort the tags alphabetically, except favor the json tag

Jump to

Keyboard shortcuts

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