首页 > 解决方案 > 很奇怪的问题函数正常运行不会报错但是在debug模式下启动会报错

问题描述

直接运行是没有错误的 调试程序的时候第二次进入递归函数就报错 不要跳过方法进入方法 这是我的函数ok 很奇怪的问题

type Student struct {
    Name string
    //排序
    Sort int
    //parent
    Parent int
    //level
    Level int
    Id    int
}
func main() {
    var data []Student = []Student{
        {Name: "家用电器", Sort: 1, Parent: 0, Level: 1, Id: 1},
        {Name: "电脑办公", Sort: 2, Parent: 0, Level: 1, Id: 2},
        {Name: "男装", Sort: 3, Parent: 0, Level: 1, Id: 3},
        {Name: "手机", Sort: 1, Parent: 2, Level: 2, Id: 4},
        {Name: "数码", Sort: 2, Parent: 1, Level: 2, Id: 5},
        {Name: "汽车", Sort: 3, Parent: 1, Level: 2, Id: 6},
        {Name: "男装2", Sort: 1, Parent: 3, Level: 2, Id: 7},
        {Name: "男装2下层皮裤", Sort: 1, Parent: 7, Level: 3, Id: 8},
        {Name: "汽车2下层拖拉机", Sort: 1, Parent: 6, Level: 3, Id: 9},
    }
    result := make([]Student, len(data))
    flag := make([]bool, len(data))

    index := 0
    FindTest(&result, data, flag, 1, 0, &index)
}

在此处输入图像描述 这是错误日志:

//exception
0 {家用电器 1 0 1 1}
Exception 0xc000001d 0x0 0x0 0x4bb723
PC=0x4bb723

main.FindTest(0xc000089d58, 0xc000089da0, 0x9, 0x9, 0xc00000a0d0, 0x9, 0x9, 0x2, 0x1, 0xc000089d40)
    F:/golang/gostu/ptr/chan2.go:36 +0x573
main.FindTest(0xc000089d58, 0xc000089da0, 0x9, 0x9, 0xc00000a0d0, 0x9, 0x9, 0x1, 0x0, 0xc000089d40)
    F:/golang/gostu/ptr/chan2.go:47 +0x465
main.main()
    F:/golang/gostu/ptr/chan2.go:32 +0x184
rax     0xc000089b10
rbx     0xc000089880
rcx     0xc000036000
rdi     0xc00008e008
rsi     0x19
rbp     0xc000089ce0
rsp     0xc000089bb8
r8      0x83fd88
r9      0xc0000896e0

标签: goexception

解决方案


推荐阅读