util

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2021 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSelfDefinedHeader

func GetSelfDefinedHeader(h http.Header, k string) string

GetSelfDefinedHeader

func GitVersion

func GitVersion() string

func JsonString

func JsonString(v interface{}) ([]byte, error)

统一json @TODO resp 里面的json,不能ignore json:"-" 和 omerti ; 解析 bool 为 字符串 json.Marshal 默认 escapeHtml 为true,会转义 <、>、&

func LocalIP

func LocalIP() (addr string, err error)

LocalAddress 223.5.5.5 is aliyun public DNS. Google public DNS 8.8.8.8 is not connectable in China.

func LocalIPs

func LocalIPs() (addresses []string, err error)

LocalAddresses For multiple network cards (virtual network cards included, e.g. docker)

func OasMatchBimgs

func OasMatchBimgs(content string) string

func OasMatchBvideos

func OasMatchBvideos(content string) string

func RedirectLog

func RedirectLog(logfile string, crashfile string, mode os.FileMode)

func RemoteIP

func RemoteIP(r *http.Request) string

RemoteIP 客户端真实IP地址

func TraceStartup

func TraceStartup(msg ...string)

Types

type ImagePattern

type ImagePattern struct {
	Height      int
	Width       int
	Quality     int
	MaxWidth    int
	MaxHeight   int
	WatermarkID int
}

func NewImagePattern

func NewImagePattern(tag ...string) *ImagePattern

func (*ImagePattern) EastChinaURL

func (p *ImagePattern) EastChinaURL(url string) string

func (*ImagePattern) OasURL

func (p *ImagePattern) OasURL(url string) string

func (*ImagePattern) Parse

func (p *ImagePattern) Parse(tag string)

type LogWriter

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

func NewLogWriter

func NewLogWriter(logfile string) *LogWriter

func (*LogWriter) Write

func (lw *LogWriter) Write(p []byte) (n int, err error)

type OasBimg

type OasBimg struct {
	//Url    string `json:"url"`
	Path   string `json:"path"`
	Width  uint16 `json:"width"`
	Height uint16 `json:"height"`
	Size   uint32 `json:"size"`
}

type OasBvideo

type OasBvideo struct {
	//Url  string `json:"url"`
	Path   string `json:"path"`
	Width  uint16 `json:"width"`
	Height uint16 `json:"height"`
	Size   uint32 `json:"size"`
}

type Price

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

func NewPrice

func NewPrice(v float64, intType ...uint8) *Price

func (*Price) Add

func (p *Price) Add(b float64) *Price

func (*Price) Div

func (p *Price) Div(b float64) *Price

func (*Price) Fixed

func (p *Price) Fixed() string

func (*Price) Mul

func (p *Price) Mul(b float64) *Price

func (*Price) Percent

func (p *Price) Percent(base float64) float64

func (*Price) Sub

func (p *Price) Sub(b float64) *Price

func (*Price) Val

func (p *Price) Val() float64

func (*Price) XPercent

func (p *Price) XPercent(percent float64) *Price

Percent 参数是百分比,如 80.5 表示 80.5%

Jump to

Keyboard shortcuts

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