github.com/searKing/golang/go@v1.2.117/runtime/example_test.go (about) 1 // Copyright 2020 The searKing Author. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package runtime_test 6 7 import ( 8 "fmt" 9 10 runtime_ "github.com/searKing/golang/go/runtime" 11 ) 12 13 func ExampleGetCaller() { 14 caller := runtime_.GetCaller(1) 15 fmt.Print(caller) 16 17 // Output: 18 // github.com/searKing/golang/go/runtime_test.ExampleGetCaller 19 } 20 21 func ExampleGetShortCallerFuncFileLine() { 22 caller, file, line := runtime_.GetShortCallerFuncFileLine(1) 23 fmt.Printf("%s() %s:%d", caller, file, line) 24 25 // Output: 26 // ExampleGetShortCallerFuncFileLine() example_test.go:22 27 }