@@ -38,26 +38,10 @@ func (kt *KhataTrace) FunctionName() string {
38
38
}
39
39
40
40
type KhataExplanation struct {
41
- message string
42
- file string
43
- line int
44
- functionName string
45
- }
46
-
47
- func (ke * KhataExplanation ) Message () string {
48
- return ke .message
49
- }
50
-
51
- func (ke * KhataExplanation ) File () string {
52
- return ke .file
53
- }
54
-
55
- func (ke * KhataExplanation ) Line () int {
56
- return ke .line
57
- }
58
-
59
- func (ke * KhataExplanation ) FunctionName () string {
60
- return ke .functionName
41
+ Message string `json:"message"`
42
+ File string `json:"file"`
43
+ Line int `json:"line"`
44
+ FunctionName string `json:"functionName"`
61
45
}
62
46
63
47
type KhataTemplate struct {
@@ -414,10 +398,10 @@ func (k *Khata) Explain(explanation string) *Khata {
414
398
lastTrace := collectCallerTrace ()
415
399
416
400
k .explanationStack = append (k .explanationStack , KhataExplanation {
417
- message : explanation ,
418
- file : lastTrace .file ,
419
- line : lastTrace .line ,
420
- functionName : lastTrace .functionName ,
401
+ Message : explanation ,
402
+ File : lastTrace .file ,
403
+ Line : lastTrace .line ,
404
+ FunctionName : lastTrace .functionName ,
421
405
})
422
406
423
407
return k
@@ -428,10 +412,10 @@ func (k *Khata) Explainf(format string, args ...interface{}) *Khata {
428
412
lastTrace := collectCallerTrace ()
429
413
430
414
k .explanationStack = append (k .explanationStack , KhataExplanation {
431
- message : fmt .Sprintf (format , args ... ),
432
- file : lastTrace .file ,
433
- line : lastTrace .line ,
434
- functionName : lastTrace .functionName ,
415
+ Message : fmt .Sprintf (format , args ... ),
416
+ File : lastTrace .file ,
417
+ Line : lastTrace .line ,
418
+ FunctionName : lastTrace .functionName ,
435
419
})
436
420
437
421
return k
@@ -462,21 +446,21 @@ func (k *Khata) Debug() *Khata {
462
446
println (fmt .Sprintf ("\n === %sExplanations%s" , colors .BoldYellow , colors .Reset ))
463
447
464
448
for _ , explanation := range explanations {
465
- file := tryTrimmingPath (explanation .file )
466
- funcName := tryTrimmingFunc (explanation .functionName )
449
+ file := tryTrimmingPath (explanation .File )
450
+ funcName := tryTrimmingFunc (explanation .FunctionName )
467
451
p := fmt .Sprintf (
468
452
" %s%s%s:%s%d%s (%s%s%s)\n └── %s%s%s" ,
469
453
colors .UnderlineGray ,
470
454
file ,
471
455
colors .Reset ,
472
456
colors .Green ,
473
- explanation .line ,
457
+ explanation .Line ,
474
458
colors .Reset ,
475
459
colors .Cyan ,
476
460
funcName ,
477
461
colors .Reset ,
478
462
colors .BoldWhite ,
479
- explanation .message ,
463
+ explanation .Message ,
480
464
colors .Reset ,
481
465
)
482
466
fmt .Println (p )
@@ -574,10 +558,10 @@ func (k *Khata) ToJSON() string {
574
558
575
559
for i , e := range explanations {
576
560
explanationsMap [i ] = map [string ]interface {}{
577
- "file" : e .file ,
578
- "line" : e .line ,
579
- "functionName" : e .functionName ,
580
- "message" : e .message ,
561
+ "file" : e .File ,
562
+ "line" : e .Line ,
563
+ "functionName" : e .FunctionName ,
564
+ "message" : e .Message ,
581
565
}
582
566
}
583
567
0 commit comments