nautilus

package module
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: MIT Imports: 9 Imported by: 8

README

Nautilus

Nautilus is collection of tools that used in Ocean Framework

Installation

go get -u github.com/Kamva/nautilus

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Empty added in v0.1.2

func Empty(i interface{}) bool

Empty Check if i is empty (Zero valued)

func GetEnv added in v0.1.2

func GetEnv(key string, fallback string) string

GetEnv get the environment variable and set it to given fallback if not present

func GetFieldPointer

func GetFieldPointer(i interface{}, fieldName string) interface{}

GetFieldPointer returns a pointer to given struct field with given field name

func GetType

func GetType(v interface{}) string

GetType get the type name of a struct variable For example, if v is an int, GetType(v) return int as string Or if v is a struct or custom type, GetType(v) return type name

func Plural

func Plural(str string) string

Plural return the plural version of given string It uses inflection package

func PointerToValue

func PointerToValue(i interface{}) interface{}

PointerToValue converts given variable (if it is a pointer) to its value

func SetFieldValue

func SetFieldValue(i interface{}, field string, value interface{})

SetFieldValue sets value of field with given name in given struct with given value

func Singular

func Singular(str string) string

Singular return singular version of given string It uses inflection package

func ToCamel

func ToCamel(str string) string

ToCamel convert given string case to camel case For example, if str is like "example_string" or "ExampleString" the output will be exampleString

func ToKebab

func ToKebab(str string) string

ToKebab is similar to ToSnake but instead of using underscore, it uses dash. For example, if str is like "exampleString" or "ExampleString" the output will be example-string

func ToPascal

func ToPascal(str string) string

ToPascal convert given string case to pascal case For example, if str is like "example_string" or "exampleString" the output will be ExampleString

func ToScreamingKebab

func ToScreamingKebab(str string) string

ToScreamingKebab is similar to ToScreamingSnake but instead of using underscore, it uses dash. For example, if str is like "exampleString" or "ExampleString" the output will be EXAMPLE-STRING

func ToScreamingSnake

func ToScreamingSnake(str string) string

ToScreamingSnake convert given string case to all capital snake case. For example, if str is like "exampleString" or "ExampleString" the output will be EXAMPLE_STRING

func ToSnake

func ToSnake(str string) string

ToSnake convert given string case to snake case For example, if str is like "exampleString" or "ExampleString" the output will be example_string

Types

type BaseTaggable added in v0.1.4

type BaseTaggable struct{}

BaseTaggable is a base struct for helper for struct needed to implement Taggable interface

func (BaseTaggable) GetTag added in v0.1.4

func (r BaseTaggable) GetTag(caller interface{}, field string, tag string) string

GetTag Get `tag` value on the `field` of `caller`

type CORS added in v0.1.8

type CORS struct {
	AllowedOrigins     []string
	AllowedMethods     []string
	AllowedHeaders     []string
	DisableCredentials bool
}

CORS is struct containing data of CORS related headers.

func (CORS) Handle added in v0.1.8

func (c CORS) Handle(context iris.Context)

Handle is a middleware for adding CORS headers in response.

type FieldData

type FieldData struct {
	Name      string
	Type      reflect.Type
	Tags      reflect.StructTag
	Value     interface{}
	Exported  bool
	Anonymous bool
}

FieldData containing struct field data such as name, type and tag

func GetStructFieldsData

func GetStructFieldsData(i interface{}) ([]FieldData, error)

GetStructFieldsData analyze the given struct and return information about exported fields such as name, type and tag value

type Taggable added in v0.1.2

type Taggable interface {
	GetTag(caller interface{}, field string, tag string) string
}

Taggable is an interface for struct that have tagging

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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