gf/g/g_func.go

53 lines
1.4 KiB
Go
Raw Normal View History

// 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,
// You can obtain one at https://github.com/gogf/gf.
2018-09-26 09:58:49 +08:00
package g
import (
2019-06-19 09:06:52 +08:00
"github.com/gogf/gf/g/container/gvar"
"github.com/gogf/gf/g/internal/empty"
"github.com/gogf/gf/g/net/ghttp"
"github.com/gogf/gf/g/util/gutil"
2018-09-26 09:58:49 +08:00
)
// NewVar returns a *gvar.Var.
2019-06-19 09:06:52 +08:00
func NewVar(i interface{}, unsafe ...bool) *Var {
return gvar.New(i, unsafe...)
}
2019-02-27 22:17:09 +08:00
// Wait blocks until all the web servers shutdown.
2018-09-26 09:58:49 +08:00
func Wait() {
2019-06-19 09:06:52 +08:00
ghttp.Wait()
2018-09-26 09:58:49 +08:00
}
2019-02-27 22:17:09 +08:00
// Dump dumps a variable to stdout with more manually readable.
2019-06-19 09:06:52 +08:00
func Dump(i ...interface{}) {
gutil.Dump(i...)
2018-09-26 09:58:49 +08:00
}
2019-03-21 18:21:53 +08:00
// Export exports a variable to string with more manually readable.
2019-06-19 09:06:52 +08:00
func Export(i ...interface{}) string {
return gutil.Export(i...)
2019-03-21 18:21:53 +08:00
}
// Throw throws a exception, which can be caught by TryCatch function.
2019-02-27 22:17:09 +08:00
// It always be used in TryCatch function.
func Throw(exception interface{}) {
2019-06-19 09:06:52 +08:00
gutil.Throw(exception)
}
2019-06-21 22:23:07 +08:00
// TryCatch does the try...catch... mechanism.
2019-06-19 09:06:52 +08:00
func TryCatch(try func(), catch ...func(exception interface{})) {
gutil.TryCatch(try, catch...)
}
// IsEmpty checks given value empty or not.
// It returns false if value is: integer(0), bool(false), slice/map(len=0), nil;
// or else true.
func IsEmpty(value interface{}) bool {
2019-06-19 09:06:52 +08:00
return empty.IsEmpty(value)
}