common

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2019 License: Apache-2.0 Imports: 27 Imported by: 50

README

COMMON

Project description of COMMON

This is the automatic generated project description of COMMON. Stay tuned for updates :-)

License

All software is copyright and protected by the Apache License, Version 2.0. https://www.apache.org/licenses/LICENSE-2.0

Documentation

Index

Constants

View Source
const (
	// Apache license
	APACHE string = "https://www.apache.org/licenses/LICENSE-2.0.html"
	// GPL2 license
	GPL2 string = "https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html"
)
View Source
const (
	SERVICE          = "service"
	SERVICE_USER     = "service-user"
	SERVICE_PASSWORD = "service-password"
)
View Source
const (
	//Year parse mask
	Year = "2006"
	//Month parse mask
	Month = "01"
	//Day parse mask
	Day = "02"
	//Hour parse mask
	Hour = "15"
	//Minute parse mask
	Minute = "04"
	//Second parse mask
	Second = "05"
	//Milli parse mask
	Msec = ".000"
	//DateSeparator parse mask
	DateSeparator = "."
	//TimeSeparator parse mask
	TimeSeparator = ":"
	//Separator parse mask
	Separator = " "
)
View Source
const (
	// DB level
	LEVEL_FILE = iota
	// LEVEL_DEBUG level
	LEVEL_DEBUG
	// LEVEL_INFO level
	LEVEL_INFO
	// LEVEL_ERROR level
	LEVEL_WARN
	// LEVEL_ERROR level
	LEVEL_ERROR
	// LEVEL_FATAL level
	LEVEL_FATAL
)
View Source
const (
	BIG5        = "big5"
	IBM437      = "ibm437"
	IBM850      = "ibm850"
	IBM866      = "ibm866"
	ISO_8859_1  = "iso-8859-1"
	ISO_8859_10 = "iso-8859-10"

	ISO_8859_2   = "iso-8859-2"
	ISO_8859_3   = "iso-8859-3"
	ISO_8859_4   = "iso-8859-4"
	ISO_8859_5   = "iso-8859-5"
	ISO_8859_6   = "iso-8859-6"
	ISO_8859_7   = "iso-8859-7"
	ISO_8859_8   = "iso-8859-8"
	ISO_8859_9   = "iso-8859-9"
	KOI8_R       = "koi8-r"
	US_ASCII     = "us-ascii"
	UTF_16       = "utf-16"
	UTF_16BE     = "utf-16be"
	UTF_16LE     = "utf-16le"
	UTF_8        = "utf-8"
	WINDOWS_1250 = "windows-1250"
	WINDOWS_1251 = "windows-1251"
	WINDOWS_1252 = "windows-1252"
)
View Source
const MIME_TYPE_HEADER_LEN = 1024
View Source
const UNKNOWN = "unknwon"

Variables

View Source
var (
	UserName    *string
	UserHomeDir *string
)

DateMask parses only for date values

View Source
var DateMaskFilename = Year + "-" + Month + "-" + Day

DateMaskFilena,e parses for date value for file names

View Source
var DateTimeMask = DateMask + Separator + TimeMask

DateTimeMask parses for date and time values

View Source
var DateTimeMilliMask = DateMask + Separator + TimeMask + Msec

DateTimeMask parses for date and time values

View Source
var (
	NoBanner bool
)

TimeMask parses only for time values

Functions

func AddShutdownHook

func AddShutdownHook(f func() error)

func Capitalize

func Capitalize(txt string) string

Capitalize the first letter

func CleanPath

func CleanPath(path string) string

CleanPath cleans the given path and also replace to OS specific separators

func Cleanup

func Cleanup()

Exit exist app and run all registered shutdown hooks

func ClearDate

func ClearDate(v time.Time) time.Time

ClearDate returns only time part, date part set to 0

func ClearTime

func ClearTime(v time.Time) time.Time

ClearTime returns only date part, time part set to 0

func CompareDate

func CompareDate(t1 time.Time, t2 time.Time) time.Duration

EqualDateTime checks for equality of parts

func CompareIgnoreCase

func CompareIgnoreCase(s0 string, s1 string) bool

CompareIgnoreCase compares strings for equality ignoring case

func CompareTime

func CompareTime(t1 time.Time, t2 time.Time) time.Duration

EqualTime checks for equality of time

func ContainsWildcard

func ContainsWildcard(s string) bool

func ConvertToOSspecificLF

func ConvertToOSspecificLF(s string) string

func CreateTempDir

func CreateTempDir() (string, error)

CreateTempDir creates a temporary file

func CreateTempFile

func CreateTempFile() (file *os.File, err error)

CreateTempFile creates a temporary file

func CurDir

func CurDir() (string, error)

CurDir returns the current directory of the app

func Debug

func Debug(t string, arg ...interface{})

Debug prints out the information

func DebugError

func DebugError(err error)

Debug prints out the information

func DebugFunc

func DebugFunc()

DebugFunc prints out the current executon func

func DefaultConsoleEncoding

func DefaultConsoleEncoding() string

func DefaultEncoding

func DefaultEncoding() string

func DetectMimeType

func DetectMimeType(buf []byte) (string, string)

func EqualWildcards

func EqualWildcards(s, mask string) (bool, error)

func Error

func Error(err error)

Error prints out the error

func Eval

func Eval(b bool, tf interface{}, ff interface{}) interface{}

func Exit

func Exit(code int)

func Fatal

func Fatal(err error)

Fatal prints out the error

func File

func File(txt string)

File prints out the information

func FileBackup

func FileBackup(filename string, count int) error

FileBackup creats backup of files

func FileCopy

func FileCopy(src string, dst string) error

FileCopy does ... guess what :-)

func FileExists

func FileExists(filename string) (bool, error)

FileExists does ... guess what :-)

func FileName

func FileName(filename string) string

Returns the complete filename "test.txt"

func FileNameExt

func FileNameExt(filename string) string

Returns the filename extension without part "test.txt" -> ".txt"

func FileNamePart

func FileNamePart(filename string) string

Returns the filename part without extension "test.txt" -> "test"

func FileSize

func FileSize(filename string) (int64, error)

FileSize does ... guess what :-)

func FileStore

func FileStore(filename string, r io.Reader) error

FileStore creats backup of files

func GetRune

func GetRune(s string, index int) (rune, error)

func IndexOf

func IndexOf(slice interface{}, search interface{}) (int, error)

func Info

func Info(t string, arg ...interface{})

Info prints out the information

func IsAMD64

func IsAMD64() bool

IsAMD64 reports true if underlying OS is 64Bit ready

func IsDebugMode

func IsDebugMode() bool

func IsDirectory

func IsDirectory(path string) (bool, error)

IsDirectory checks if the path leads to a directory

func IsFile

func IsFile(path string) bool

IsDirectory checks if the path leads to a directory

func IsFileReadOnly

func IsFileReadOnly(path string) (result bool, err error)

IsFileReadOnly checks if a file is read only

func IsLinuxOS

func IsLinuxOS() bool

IsLinuxOS reports true if underlying OS is Linux

func IsMacOS

func IsMacOS() bool

IsMacOS reports true if underlying OS is MacOS

func IsSymbolicLink(path string) bool

IsSymbolicLink checks if the path leads to symbolic link

func IsWindowsOS

func IsWindowsOS() bool

IsWindowsOS reports true if underlying OS is MS Windows

func New

func New(application *App, mandatoryFlags []string)

New struct for copyright information

func ParseDateTime

func ParseDateTime(mask string, v string) (time.Time, error)

ParseDateTime parses only date, but no time

func Rnd

func Rnd(max int) int

func Run

func Run()

func RuntimeInfo

func RuntimeInfo(pos int) ri

func SetFileReadOnly

func SetFileReadOnly(path string, readonly bool) (err error)

SetFileReadOnly sets file READ-ONLY yes or false

func SetTime

func SetTime(t time.Time, f string, v int) time.Time

func Shortener

func Shortener(s string, max int) string

func ShowBanner

func ShowBanner()

func SplitWithQuotation

func SplitWithQuotation(txt string) []string

SplitWithQuotation splits a sequented string by spaces and respects quotation

func SurroundWith

func SurroundWith(str []string, prefixSuffix string) []string

func TempDir

func TempDir() (string, error)

TempDir returns the private temporary directory of the app

func ToBool

func ToBool(s string) bool

func ToString

func ToString(cmd exec.Cmd) string

func ToStrings

func ToStrings(slice interface{}) ([]string, error)

func ToTime

func ToTime(v asDateTime) time.Time

func ToUTF8

func ToUTF8(r io.Reader, cs string) ([]byte, error)

func ToUTF8String

func ToUTF8String(s string, cs string) (string, error)

func Translate

func Translate(msg string, args ...interface{}) string

Translate a i18n message

func Trim4Path

func Trim4Path(path string) string

Trim4Path trims given path to be usefully as filename

func TruncateTime

func TruncateTime(t time.Time, f string) time.Time

func Unzip

func Unzip(dest, src string) error

func Warn

func Warn(t string, arg ...interface{})

Warn prints out the information

func Zip

func Zip(filename string, files []string) error

Types

type App

type App struct {
	// Name of the application
	Name string
	// Version of the application
	Version string
	// Date of development
	Date string
	// Description of the application
	Description string
	// Developer of the application
	Developer string
	// License of the application
	License string
	// Homepage of the application
	Homepage string
	//IsService
	IsService bool
	//PrepareFunc
	PrepareFunc func() error
	//StartFunc
	StartFunc func() error
	//StopFunc
	StopFunc func() error
	//TickFunc
	TickFunc func() error
	//TickTime
	TickTime time.Duration
}

Info information of the application

func GetApp

func GetApp() *App

func (*App) Start

func (app *App) Start(s service.Service) error

func (*App) Stop

func (app *App) Stop(s service.Service) error

type ChannelError

type ChannelError struct {
	// contains filtered or unexported fields
}

func (*ChannelError) Add

func (c *ChannelError) Add(err error)

func (*ChannelError) Exists

func (c *ChannelError) Exists() bool

func (*ChannelError) Get

func (c *ChannelError) Get() error

func (*ChannelError) GetAll

func (c *ChannelError) GetAll() []error

type ErrFileNotFound

type ErrFileNotFound struct {
	FileName string
}

func (*ErrFileNotFound) Error

func (e *ErrFileNotFound) Error() string

type ErrInvalidType

type ErrInvalidType struct {
	// contains filtered or unexported fields
}

func (*ErrInvalidType) Error

func (e *ErrInvalidType) Error() string

type Jason

type Jason struct {
	// contains filtered or unexported fields
}

func NewJason

func NewJason(s string) (*Jason, error)

func (*Jason) Array

func (jason *Jason) Array(key string, index int) (*Jason, error)

func (*Jason) ArrayCount

func (jason *Jason) ArrayCount(key string) int

func (*Jason) Bool

func (jason *Jason) Bool(key string, def ...bool) (bool, error)

func (*Jason) Count

func (jason *Jason) Count() int

func (*Jason) Element

func (jason *Jason) Element(key string) (*Jason, error)

func (*Jason) Elements

func (jason *Jason) Elements() []string

func (*Jason) Exists

func (jason *Jason) Exists(key string) bool

func (*Jason) Int

func (jason *Jason) Int(key string, def ...int) (int, error)

func (*Jason) IsArray

func (jason *Jason) IsArray(key string) bool

func (*Jason) IsBool

func (jason *Jason) IsBool(key string) bool

func (*Jason) IsInt

func (jason *Jason) IsInt(key string) bool

func (*Jason) IsString

func (jason *Jason) IsString(key string) bool

func (*Jason) Pretty

func (jason *Jason) Pretty() (string, error)

func (*Jason) String

func (jason *Jason) String(key string, def ...string) (string, error)

type OrderedMap

type OrderedMap struct {
	// contains filtered or unexported fields
}

func NewOrderedMap

func NewOrderedMap(m ...interface{}) *OrderedMap

func (*OrderedMap) Clear

func (o *OrderedMap) Clear() *OrderedMap

func (*OrderedMap) Delete

func (o *OrderedMap) Delete(key interface{}) *OrderedMap

func (*OrderedMap) Get

func (o *OrderedMap) Get(key interface{}) (interface{}, bool)

func (*OrderedMap) Keys

func (o *OrderedMap) Keys() []interface{}

func (*OrderedMap) Len

func (o *OrderedMap) Len() int

func (*OrderedMap) Set

func (o *OrderedMap) Set(key interface{}, value interface{}) *OrderedMap

func (*OrderedMap) SetMap

func (o *OrderedMap) SetMap(m ...interface{}) *OrderedMap

type Quantum

type Quantum struct {
	// contains filtered or unexported fields
}

func NewQuantum

func NewQuantum() *Quantum

func (*Quantum) Add

func (q *Quantum) Add(v int)

func (*Quantum) AddRange

func (q *Quantum) AddRange(from int, to int)

func (*Quantum) Get

func (q *Quantum) Get(index int) (int, error)

func (*Quantum) Len

func (q *Quantum) Len() int

func (*Quantum) Remove

func (q *Quantum) Remove(v int)

func (*Quantum) RemoveRange

func (q *Quantum) RemoveRange(from int, to int)

func (*Quantum) String

func (q *Quantum) String() string

func (*Quantum) ToSlice

func (q *Quantum) ToSlice() []int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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