2020-05-20 18:20补充:
感谢yif同学提供指导,出现错误并且打印大量信息的原因是函数递归调用导致栈溢出。
而导致递归调用的关键代码是%v
- 类型实现了error的interface
- %v的时候会反射类型,发现实现了error接口,然后调用error的.Error()方法
- 结果Error()方法中又使用了%v,导致递归
结论:使用%v打印,一定要了解其背后的反射原理,并避免递归。
(未完待续,还有第二个问题)
先贴代码:
package main
import (
"fmt"
"log"
)
type MyError struct{
MyErrorCode int
}
func (e *MyError)Error()string{
return fmt.Sprintf("%v", e)
}
func f1()(int32, error){
return 1, nil
}
func f2()(string, *MyError){
return "aaa", &MyError{MyErrorCode:1000}
}
func main(){
a, err := f1()
log.Println(a, err)
b, err := f2()
log.Println(b, err)
}
崩溃信息很长很长:
2020/05/20 17:14:40 1 <nil>
runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc0201612f8 stack=[0xc020160000, 0xc040160000]
fatal error: stack overflow
runtime stack:
runtime.throw(0x6add24, 0xe)
C:/Go/src/runtime/panic.go:1112 +0x79
runtime.newstack()
C:/Go/src/runtime/stack.go:1034 +0x6dc
runtime.morestack()
C:/Go/src/runtime/asm_amd64.s:449 +0x97
goroutine 1 [running]:
runtime.assertE2I2(0x667f20, 0x65eb20, 0xc0000a0848, 0x0, 0x0, 0x0)
C:/Go/src/runtime/iface.go:487 +0xa5 fp=0xc020161308 sp=0xc020161300 pc=0x40a515
fmt.(*pp).handleMethods(0xc005c816c0, 0x76, 0xc020161600)
C:/Go/src/fmt/print.go:594 +0x8f fp=0xc020161578 sp=0xc020161308 pc=0x4be5ff
fmt.(*pp).printArg(0xc005c816c0, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc020161610 sp=0xc020161578 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c816c0, 0x6ab3b7, 0x2, 0xc020161788, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc0201616f8 sp=0xc020161610 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020161788, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020161750 sp=0xc0201616f8 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc0201617a8 sp=0xc020161750 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c815f0, 0x76, 0xc020161a01)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc020161a18 sp=0xc0201617a8 pc=0x4be752
fmt.(*pp).printArg(0xc005c815f0, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc020161ab0 sp=0xc020161a18 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c815f0, 0x6ab3b7, 0x2, 0xc020161c28, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc020161b98 sp=0xc020161ab0 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020161c28, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020161bf0 sp=0xc020161b98 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc020161c48 sp=0xc020161bf0 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c81520, 0x76, 0xc020161f01)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc020161eb8 sp=0xc020161c48 pc=0x4be752
fmt.(*pp).printArg(0xc005c81520, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc020161f50 sp=0xc020161eb8 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c81520, 0x6ab3b7, 0x2, 0xc0201620c8, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc020162038 sp=0xc020161f50 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc0201620c8, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020162090 sp=0xc020162038 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc0201620e8 sp=0xc020162090 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c81450, 0x76, 0xc020162401)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc020162358 sp=0xc0201620e8 pc=0x4be752
fmt.(*pp).printArg(0xc005c81450, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc0201623f0 sp=0xc020162358 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c81450, 0x6ab3b7, 0x2, 0xc020162568, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc0201624d8 sp=0xc0201623f0 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020162568, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020162530 sp=0xc0201624d8 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc020162588 sp=0xc020162530 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c81380, 0x76, 0xc020162801)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc0201627f8 sp=0xc020162588 pc=0x4be752
fmt.(*pp).printArg(0xc005c81380, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc020162890 sp=0xc0201627f8 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c81380, 0x6ab3b7, 0x2, 0xc020162a08, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc020162978 sp=0xc020162890 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020162a08, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc0201629d0 sp=0xc020162978 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc020162a28 sp=0xc0201629d0 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c812b0, 0x76, 0xc020162d01)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc020162c98 sp=0xc020162a28 pc=0x4be752
fmt.(*pp).printArg(0xc005c812b0, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc020162d30 sp=0xc020162c98 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c812b0, 0x6ab3b7, 0x2, 0xc020162ea8, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc020162e18 sp=0xc020162d30 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020162ea8, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020162e70 sp=0xc020162e18 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc020162ec8 sp=0xc020162e70 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c811e0, 0x76, 0xc020163101)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc020163138 sp=0xc020162ec8 pc=0x4be752
fmt.(*pp).printArg(0xc005c811e0, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc0201631d0 sp=0xc020163138 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c811e0, 0x6ab3b7, 0x2, 0xc020163348, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc0201632b8 sp=0xc0201631d0 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020163348, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020163310 sp=0xc0201632b8 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc020163368 sp=0xc020163310 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c81110, 0x76, 0xc020163601)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc0201635d8 sp=0xc020163368 pc=0x4be752
fmt.(*pp).printArg(0xc005c81110, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc020163670 sp=0xc0201635d8 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c81110, 0x6ab3b7, 0x2, 0xc0201637e8, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc020163758 sp=0xc020163670 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc0201637e8, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc0201637b0 sp=0xc020163758 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc020163808 sp=0xc0201637b0 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c81040, 0x76, 0xc020163b01)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc020163a78 sp=0xc020163808 pc=0x4be752
fmt.(*pp).printArg(0xc005c81040, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc020163b10 sp=0xc020163a78 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c81040, 0x6ab3b7, 0x2, 0xc020163c88, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc020163bf8 sp=0xc020163b10 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020163c88, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020163c50 sp=0xc020163bf8 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc020163ca8 sp=0xc020163c50 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c80f70, 0x76, 0xc020163f01)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc020163f18 sp=0xc020163ca8 pc=0x4be752
fmt.(*pp).printArg(0xc005c80f70, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc020163fb0 sp=0xc020163f18 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c80f70, 0x6ab3b7, 0x2, 0xc020164128, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc020164098 sp=0xc020163fb0 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020164128, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc0201640f0 sp=0xc020164098 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc020164148 sp=0xc0201640f0 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c80ea0, 0x76, 0xc020164401)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc0201643b8 sp=0xc020164148 pc=0x4be752
fmt.(*pp).printArg(0xc005c80ea0, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc020164450 sp=0xc0201643b8 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c80ea0, 0x6ab3b7, 0x2, 0xc0201645c8, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc020164538 sp=0xc020164450 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc0201645c8, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020164590 sp=0xc020164538 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc0201645e8 sp=0xc020164590 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c80dd0, 0x76, 0xc020164901)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc020164858 sp=0xc0201645e8 pc=0x4be752
fmt.(*pp).printArg(0xc005c80dd0, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc0201648f0 sp=0xc020164858 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c80dd0, 0x6ab3b7, 0x2, 0xc020164a68, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc0201649d8 sp=0xc0201648f0 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020164a68, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020164a30 sp=0xc0201649d8 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc020164a88 sp=0xc020164a30 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c80d00, 0x76, 0xc020164d01)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc020164cf8 sp=0xc020164a88 pc=0x4be752
fmt.(*pp).printArg(0xc005c80d00, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc020164d90 sp=0xc020164cf8 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c80d00, 0x6ab3b7, 0x2, 0xc020164f08, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc020164e78 sp=0xc020164d90 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020164f08, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020164ed0 sp=0xc020164e78 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc020164f28 sp=0xc020164ed0 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c80c30, 0x76, 0xc020165201)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc020165198 sp=0xc020164f28 pc=0x4be752
fmt.(*pp).printArg(0xc005c80c30, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc020165230 sp=0xc020165198 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c80c30, 0x6ab3b7, 0x2, 0xc0201653a8, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc020165318 sp=0xc020165230 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc0201653a8, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020165370 sp=0xc020165318 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc0201653c8 sp=0xc020165370 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c80b60, 0x76, 0xc020165601)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc020165638 sp=0xc0201653c8 pc=0x4be752
fmt.(*pp).printArg(0xc005c80b60, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc0201656d0 sp=0xc020165638 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c80b60, 0x6ab3b7, 0x2, 0xc020165848, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc0201657b8 sp=0xc0201656d0 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020165848, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020165810 sp=0xc0201657b8 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc020165868 sp=0xc020165810 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c80a90, 0x76, 0xc020165b01)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc020165ad8 sp=0xc020165868 pc=0x4be752
fmt.(*pp).printArg(0xc005c80a90, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc020165b70 sp=0xc020165ad8 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c80a90, 0x6ab3b7, 0x2, 0xc020165ce8, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc020165c58 sp=0xc020165b70 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020165ce8, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020165cb0 sp=0xc020165c58 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc020165d08 sp=0xc020165cb0 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c809c0, 0x76, 0xc020166001)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc020165f78 sp=0xc020165d08 pc=0x4be752
fmt.(*pp).printArg(0xc005c809c0, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc020166010 sp=0xc020165f78 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c809c0, 0x6ab3b7, 0x2, 0xc020166188, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc0201660f8 sp=0xc020166010 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020166188, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020166150 sp=0xc0201660f8 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc0201661a8 sp=0xc020166150 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c808f0, 0x76, 0xc020166401)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc020166418 sp=0xc0201661a8 pc=0x4be752
fmt.(*pp).printArg(0xc005c808f0, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc0201664b0 sp=0xc020166418 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c808f0, 0x6ab3b7, 0x2, 0xc020166628, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc020166598 sp=0xc0201664b0 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020166628, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc0201665f0 sp=0xc020166598 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc020166648 sp=0xc0201665f0 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c80820, 0x76, 0xc020166901)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc0201668b8 sp=0xc020166648 pc=0x4be752
fmt.(*pp).printArg(0xc005c80820, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc020166950 sp=0xc0201668b8 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c80820, 0x6ab3b7, 0x2, 0xc020166ac8, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc020166a38 sp=0xc020166950 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020166ac8, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020166a90 sp=0xc020166a38 pc=0x4bb6bd
main.(*MyError).Error(0xc0000a0848, 0x65eb20, 0xc0000a0848)
D:/source/ahfuzhang/test/report.go:16 +0x77 fp=0xc020166ae8 sp=0xc020166a90 pc=0x62c5d7
fmt.(*pp).handleMethods(0xc005c80750, 0x76, 0xc020166e01)
C:/Go/src/fmt/print.go:624 +0x1e2 fp=0xc020166d58 sp=0xc020166ae8 pc=0x4be752
fmt.(*pp).printArg(0xc005c80750, 0x65eb20, 0xc0000a0848, 0xc000000076)
C:/Go/src/fmt/print.go:713 +0x1eb fp=0xc020166df0 sp=0xc020166d58 pc=0x4bee1b
fmt.(*pp).doPrintf(0xc005c80750, 0x6ab3b7, 0x2, 0xc020166f68, 0x1, 0x1)
C:/Go/src/fmt/print.go:1030 +0x161 fp=0xc020166ed8 sp=0xc020166df0 pc=0x4c26f1
fmt.Sprintf(0x6ab3b7, 0x2, 0xc020166f68, 0x1, 0x1, 0x667ea0, 0x43375d)
C:/Go/src/fmt/print.go:219 +0x6d fp=0xc020166f30 sp=0xc020166ed8 pc=0x4bb6bd
...additional frames elided...
Process finished with exit code 2
- 1.原来有个error类型的err, 然后我把*MyError类型赋值给err,这个是我不小心,我认
- 2.MyError虽然实现了接口,但是赋值的时候为什么编译期不能检查出来?
- 3.崩溃信息为何会那么长?