commonconfig

package
v0.0.0-...-b579be4 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2019 License: MIT, MIT, MIT, + 1 more Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAppInitialized = errors.New("app is Initialized,should not be initialized again")

ErrAppInitialized error raised if app is initialized

View Source
var ErrAppIsInInitializingMode = errors.New("app is in initializing mode.you should turn 'Initializing' in 'config/development.toml' to false")

ErrAppIsInInitializingMode error rasied if app is in initializing mode

Functions

This section is empty.

Types

type DevelopmentConfig

type DevelopmentConfig struct {
	//Debug if app is in debug mod.
	Debug bool
	//Testing if app is in testing mode
	Testing bool
	//Profiling if app is in profiling mode
	Profiling bool
	//Benchmarking if app is in benchmarking mode
	Benchmarking bool
	//Initializing if app is Initializing.
	//App should panic before serveing if Initializing setted to True.
	Initializing bool
	// contains filtered or unexported fields
}

DevelopmentConfig program development staus config

func (*DevelopmentConfig) GetInitializeEnv

func (c *DevelopmentConfig) GetInitializeEnv(name string) string

GetInitializeEnv get registered env by name.

func (*DevelopmentConfig) MustNotInitializing

func (c *DevelopmentConfig) MustNotInitializing()

MustNotInitializing panic if Initializing is true

func (*DevelopmentConfig) OnEnv

func (c *DevelopmentConfig) OnEnv(envs ...string) *RegisteredEnvs

OnEnv declare env name list which will be used by initializer.

func (*DevelopmentConfig) PanicInitialized

func (c *DevelopmentConfig) PanicInitialized()

PanicInitialized panic a app initialized error.

type ErrInitializingEnvIsSet

type ErrInitializingEnvIsSet string

ErrInitializingEnvIsSet err raied if initializing env is set. Use ErrInitializingEnvIsSet("envname") to create new error.

func (ErrInitializingEnvIsSet) Error

func (e ErrInitializingEnvIsSet) Error() string

type RegisteredEnvs

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

RegisteredEnvs registered env name list

func (*RegisteredEnvs) ThenInitalize

func (e *RegisteredEnvs) ThenInitalize(handler func() bool) []string

ThenInitalize set initalizer to registered env list.

type TimeConfig

type TimeConfig struct {
	//Timezone time zone.
	Timezone string
	//TimeFormat  format used when converting time in day.
	TimeFormat string
	//DateFormat  format used when converting date.
	DateFormat string
	//DatetimeFormata format used when converting date and time.
	DatetimeFormat string
	// contains filtered or unexported fields
}

TimeConfig app time config

func (*TimeConfig) Date

func (c *TimeConfig) Date(t time.Time) string

Date format date. Panic if Timezone error.

func (*TimeConfig) DateUnix

func (c *TimeConfig) DateUnix(ts int64) string

DateUnix format date from unix timestamp

func (*TimeConfig) Datetime

func (c *TimeConfig) Datetime(t time.Time) string

Datetime format date and time

func (*TimeConfig) DatetimeUnix

func (c *TimeConfig) DatetimeUnix(ts int64) string

DatetimeUnix format date and time from unix timestamp Panic if Timezone error.

func (*TimeConfig) Parse

func (c *TimeConfig) Parse(s string) (time.Time, error)

Parse time string to local time. Panic if Timezone error.

func (*TimeConfig) Time

func (c *TimeConfig) Time(t time.Time) string

Time format time.

func (*TimeConfig) TimeInLocation

func (c *TimeConfig) TimeInLocation(t time.Time) time.Time

TimeInLocation set time location to given time zone. Panic if Timezone error.

func (*TimeConfig) TimeUnix

func (c *TimeConfig) TimeUnix(ts int64) string

TimeUnix format time from unix timestamp

type WebsiteConfig

type WebsiteConfig struct {
	//Name website name.
	Name string
	//Description website description.
	//Description should be set to meta description.
	Description string
	//Keywords website Keywords
	//Keywords should be set to meta keywords.
	Keywords string
	//Email admin email.
	Email string
	//Homepage homepage url.
	Homepage string
}

WebsiteConfig common website config

Jump to

Keyboard shortcuts

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