util

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: MIT Imports: 17 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 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 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 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