2019-02-02 16:18:25 +08:00
|
|
|
|
// Copyright 2017 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
2018-09-26 09:58:49 +08:00
|
|
|
|
//
|
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
2019-02-02 16:18:25 +08:00
|
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
2018-09-26 09:58:49 +08:00
|
|
|
|
|
|
|
|
|
package g
|
|
|
|
|
|
|
|
|
|
import (
|
2019-03-21 18:20:20 +08:00
|
|
|
|
"github.com/gogf/gf/g/container/gvar"
|
|
|
|
|
"github.com/gogf/gf/g/internal/empty"
|
2019-02-02 16:18:25 +08:00
|
|
|
|
"github.com/gogf/gf/g/net/ghttp"
|
|
|
|
|
"github.com/gogf/gf/g/util/gutil"
|
2018-09-26 09:58:49 +08:00
|
|
|
|
)
|
|
|
|
|
|
2019-02-27 22:17:09 +08:00
|
|
|
|
// NewVar creates a *Var.
|
|
|
|
|
//
|
2018-10-09 13:33:00 +08:00
|
|
|
|
// 动态变量
|
2019-01-12 23:36:22 +08:00
|
|
|
|
func NewVar(i interface{}, unsafe...bool) *Var {
|
|
|
|
|
return gvar.New(i, unsafe...)
|
2018-10-09 13:33:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-27 22:17:09 +08:00
|
|
|
|
// Wait blocks until all the web servers shutdown.
|
|
|
|
|
//
|
2018-09-26 09:58:49 +08:00
|
|
|
|
// 阻塞等待HTTPServer执行完成(同一进程多HTTPServer情况下)
|
|
|
|
|
func Wait() {
|
|
|
|
|
ghttp.Wait()
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-27 22:17:09 +08:00
|
|
|
|
// Dump dumps a variable to stdout with more manually readable.
|
|
|
|
|
//
|
2019-03-21 18:21:53 +08:00
|
|
|
|
// 格式化打印变量.
|
2018-09-26 09:58:49 +08:00
|
|
|
|
func Dump(i...interface{}) {
|
|
|
|
|
gutil.Dump(i...)
|
|
|
|
|
}
|
2018-11-06 13:53:06 +08:00
|
|
|
|
|
2019-03-21 18:21:53 +08:00
|
|
|
|
// Export exports a variable to string with more manually readable.
|
|
|
|
|
//
|
|
|
|
|
// 格式化导出变量.
|
|
|
|
|
func Export(i...interface{}) string {
|
|
|
|
|
return gutil.Export(i...)
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-27 22:17:09 +08:00
|
|
|
|
// Throw throws a exception, which can be caught by Catch function.
|
|
|
|
|
// It always be used in TryCatch function.
|
|
|
|
|
//
|
2018-11-06 13:53:06 +08:00
|
|
|
|
// 抛出一个异常
|
2018-11-06 18:53:25 +08:00
|
|
|
|
func Throw(exception interface{}) {
|
|
|
|
|
gutil.Throw(exception)
|
2018-11-06 13:53:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-27 22:17:09 +08:00
|
|
|
|
// TryCatch does the try...catch... logic.
|
2018-11-06 18:53:25 +08:00
|
|
|
|
func TryCatch(try func(), catch ... func(exception interface{})) {
|
|
|
|
|
gutil.TryCatch(try, catch...)
|
2019-03-21 18:20:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IsEmpty checks given value empty or not.
|
|
|
|
|
// false: integer(0), bool(false), slice/map(len=0), nil;
|
|
|
|
|
// true : other.
|
|
|
|
|
//
|
|
|
|
|
// 判断给定的变量是否为空。
|
|
|
|
|
// 整型为0, 布尔为false, slice/map长度为0, 其他为nil的情况,都为空。
|
|
|
|
|
// 为空时返回true,否则返回false。
|
|
|
|
|
func IsEmpty(value interface{}) bool {
|
|
|
|
|
return empty.IsEmpty(value)
|
2018-11-06 13:53:06 +08:00
|
|
|
|
}
|