commonconfig

package
v0.0.0-...-6a757b2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MIT, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAppInTestingMode = errors.New("app is in testing mode")

ErrAppInTestingMode error raised if app is in testing mode

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

View Source
var ErrAppNotInTestingMode = errors.New("app is not in testing mode")

ErrAppNotInTestingMode error raised if app is in testing 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) CleanWatehedEnvs

func (c *DevelopmentConfig) CleanWatehedEnvs()

func (*DevelopmentConfig) GetInitializeEnv

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

GetInitializeEnv get registered env by name.

func (*DevelopmentConfig) InitializeAndPanicIfNeeded

func (c *DevelopmentConfig) InitializeAndPanicIfNeeded()

InitializeAndPanicIfNeeded initialize and panic if Initializing is true

func (*DevelopmentConfig) NotTestingOrPanic

func (c *DevelopmentConfig) NotTestingOrPanic()

NotTestingOrPanic panic if Testing is true

func (*DevelopmentConfig) OnEnv

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

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

func (*DevelopmentConfig) PanicInitialized

func (c *DevelopmentConfig) PanicInitialized()

PanicInitialized panic a app initialized error.

func (*DevelopmentConfig) TestingOrPanic

func (c *DevelopmentConfig) TestingOrPanic()

TestingOrPanic panic if Testing is false

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 TimeConfig

type TimeConfig struct {
	//Timezone time zone.
	Timezone string
	//TimeLayout  format used when converting time in day.
	TimeLayout string
	//DateLayout  format used when converting date.
	DateLayout string
	//DatetimeLayout format used when converting date and time.
	DatetimeLayout 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) FormatNow

func (c *TimeConfig) FormatNow(format string) string

FormatNow format with given time

func (*TimeConfig) Location

func (c *TimeConfig) Location() *time.Location

func (*TimeConfig) MustParse

func (c *TimeConfig) MustParse(s string) time.Time

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 WatchedEnvs

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

WatchedEnvs watched env name list

func (*WatchedEnvs) ThenInitalize

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

ThenInitalize set initalizer to registered env list.

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