Documentation ¶
Index ¶
- Constants
- Variables
- func AddErrorMap(errNo int64, errMsg string)
- func ConvertToInt(v interface{}) int
- func GetAddrForListen(addr string) (string, error)
- func GetAppName() string
- func GetAppPath() string
- func GetCaller(depth int) (file string, line int)
- func GetClientIP(r *http.Request) string
- func GetEnv() string
- func GetErrorMap(errNo int64) string
- func GetHostIP(interfaceName string) (host string, err error)
- func GetHostName() string
- func GetPid() int
- func GetPureUUID(oldS ...string) (s string)
- func GetRegisterAddress(interfaceName, address string) (host string, port int, err error)
- func GetServerAddr(listendAddr, addr string) string
- func GetStack() []byte
- func GetTraceIDFromIncomingContext(ctx context.Context) string
- func GetTraceIDFromOutgoingContext(ctx context.Context) string
- func GetTraceIDFromRequest(r *http.Request) (traceID string)
- func GetVersion() string
- func IsDevEnv() bool
- func IsDir(filepath string) bool
- func IsExist(filepath string) bool
- func IsGoRun() bool
- func IsGoTest() bool
- func IsInStringArray(val string, arr []string) bool
- func IsProdEnv() bool
- func IsTestEnv() bool
- func Max(i int, j ...int) int
- func Md5(str string) string
- func Min(i int, j ...int) int
- func ParseFlag() (err error)
- func SetErrorMap(m map[int64]string)
- func ToOsCode(text string) string
- func UtfToUnicode(d []byte) (reader *bytes.Buffer, err error)
- func Uuid() string
- type RespErr
- type Response
Constants ¶
View Source
const ( DEV = "dev" TEST = "test" PROD = "prod" )
View Source
const GrpcHTTPTraceIDKey = "Trace_id"
View Source
const GrpcTraceIDKey = "trace_id"
Variables ¶
View Source
var ( APPPATH = GetAppPath() APPNAME = GetAppName() )
View Source
var ( //VERSION 版本 //通过go build -ldflags "-X github.com/hsyan2008/hfw/common.VERSION=v0.2"赋值 //也可以通过环境变量赋值,此方式优先 VERSION string = "v0.1" //ENVIRONMENT 环境 ENVIRONMENT string //通过go build -ldflags "-X github.com/hsyan2008/hfw/common.GOPATH=~/go"赋值 GOPATH string = os.Getenv("GOPATH") PID = os.Getpid() HOSTNAME, _ = os.Hostname() )
Functions ¶
func AddErrorMap ¶
func ConvertToInt ¶
func ConvertToInt(v interface{}) int
func GetAddrForListen ¶
监听127.0.0.1用于限定内部访问,完整的返回 其他情况用于注册服务,只返回端口部分
func GetAppName ¶
func GetAppName() string
func GetAppPath ¶
func GetAppPath() string
func GetErrorMap ¶
func GetHostName ¶
func GetHostName() string
func GetPureUUID ¶
func GetRegisterAddress ¶
如果address是完整的ip:port,则返回 否则取本机的ip地址,加上address的端口
func GetServerAddr ¶
取listend的端口,加上配置的host(可能为空)
func GetTraceIDFromRequest ¶
func GetVersion ¶
func GetVersion() string
func IsInStringArray ¶
func SetErrorMap ¶
func UtfToUnicode ¶
把中文转成\u8981之类的unicode编码 参考http://blog.cyeam.com/json/2014/08/04/go_json utf8包
Types ¶
Click to show internal directories.
Click to hide internal directories.