1
2
3
4
5
6
7 package jsontest
8
9 import (
10 "fmt"
11 "path"
12 "runtime"
13 )
14
15
16
17
18 type CaseName struct {
19 Name string
20 Where CasePos
21 }
22
23
24 func Name(s string) (c CaseName) {
25 c.Name = s
26 runtime.Callers(2, c.Where.pc[:])
27 return c
28 }
29
30
31 type CasePos struct{ pc [1]uintptr }
32
33 func (pos CasePos) String() string {
34 frames := runtime.CallersFrames(pos.pc[:])
35 frame, _ := frames.Next()
36 return fmt.Sprintf("%s:%d", path.Base(frame.File), frame.Line)
37 }
38
View as plain text