github.com/zhongdalu/gf@v1.0.0/g/g_func.go (about) 1 // Copyright 2017 gf Author(https://github.com/zhongdalu/gf). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/zhongdalu/gf. 6 7 package g 8 9 import ( 10 "github.com/zhongdalu/gf/g/container/gvar" 11 "github.com/zhongdalu/gf/g/internal/empty" 12 "github.com/zhongdalu/gf/g/net/ghttp" 13 "github.com/zhongdalu/gf/g/util/gutil" 14 ) 15 16 // NewVar returns a *gvar.Var. 17 func NewVar(i interface{}, unsafe ...bool) *Var { 18 return gvar.New(i, unsafe...) 19 } 20 21 // Wait blocks until all the web servers shutdown. 22 func Wait() { 23 ghttp.Wait() 24 } 25 26 // Dump dumps a variable to stdout with more manually readable. 27 func Dump(i ...interface{}) { 28 gutil.Dump(i...) 29 } 30 31 // Export exports a variable to string with more manually readable. 32 func Export(i ...interface{}) string { 33 return gutil.Export(i...) 34 } 35 36 // Throw throws a exception, which can be caught by TryCatch function. 37 // It always be used in TryCatch function. 38 func Throw(exception interface{}) { 39 gutil.Throw(exception) 40 } 41 42 // TryCatch does the try...catch... mechanism. 43 func TryCatch(try func(), catch ...func(exception interface{})) { 44 gutil.TryCatch(try, catch...) 45 } 46 47 // IsEmpty checks given value empty or not. 48 // It returns false if value is: integer(0), bool(false), slice/map(len=0), nil; 49 // or else true. 50 func IsEmpty(value interface{}) bool { 51 return empty.IsEmpty(value) 52 }