Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultErrFormat = func(c *CallerInfo, format string, a ...interface{}) string { return fmt.Sprintf("%s %s:%d %s ", emoji.Error, c.Name, c.Line, fmt.Sprintf(format, a...)) }
View Source
var ( // ErrParamsNotAdapted params length invalid ErrParamsNotAdapted = errors.New("The number of params is not adapted.") )
View Source
var Organize = ""
Organize 项目组织名称,如github.com/hollson/gdk中的hollson
Functions ¶
func Errorf ¶
Example ¶
package main import ( "fmt" "github.com/hollson/gdk/sys" ) func main() { sys.Organize = "gdk" fmt.Println(sys.Errorf("===%s===", "sorry")) }
Output: ❌ gdk/sys_test.ExampleErrorf:25 ===[sorry]===
Types ¶
type CallerInfo ¶
type CallerInfo struct { PC uintptr // 调用者函数指针 Path string // 调用者文件路径 Name string // 调用者函数名 Line int // 调用者行号 }
func CallerMust ¶
func CallerMust() *CallerInfo
CallerMust 参考sys.Caller
Example ¶
package main import ( "fmt" "github.com/hollson/gdk" "github.com/hollson/gdk/sys" ) func main() { c := sys.CallerMust() fmt.Printf("%s\n", gdk.JsonPretty(c)) fmt.Printf("%v\n", c.Path) sys.Organize = "gdk" c = sys.CallerMust() fmt.Printf("%s", gdk.JsonPretty(c)) // Output // { // "PC": 17790296, // "Path": "/Users/xxx/github/gdk/sys/fn_test.go", // "Name": "github.com/hollson/gdk/sys_test.ExampleCallerMust", // "Line": 19 // } }
Output:
Click to show internal directories.
Click to hide internal directories.