斯普林特访问段违反

时间:2019-03-01 05:45:13

标签: go printf

当我在golang代码中使用Sprintf时,我遇到了细分违规错误。任何男孩都知道我的代码有什么问题吗? 我的代码如下:


func createTrainingPath(trainingPrefix string, uuid string, codec string) string {
    return fmt.Sprintf("%s/%s/%s/%s", trainingPrefix, codec, time.Now().Format("20060102"), uuid)
}

错误如下:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6ca1f7]

goroutine 7483565 [running]:
panic(0x1162ea0, 0x19558e0)
        /home/wenchuang.liu/go/src/runtime/panic.go:540 +0x45e fp=0xc494a569f0 sp=0xc494a56948 pc=0x697f4e
runtime.panicmem()
        /home/wenchuang.liu/go/src/runtime/panic.go:63 +0x5e fp=0xc494a56a10 sp=0xc494a569f0 pc=0x696c7e
runtime.sigpanic()
        /home/wenchuang.liu/go/src/runtime/signal_unix.go:367 +0x17c fp=0xc494a56a60 sp=0xc494a56a10 pc=0x6af2dc
runtime.memmove(0xc4200e2419, 0x0, 0x20)
        /home/wenchuang.liu/go/src/runtime/memmove_amd64.s:178 +0x147 fp=0xc494a56a68 sp=0xc494a56a60 pc=0x6ca1f7
fmt.(*buffer).WriteString(...)
        /home/wenchuang.liu/go/src/fmt/print.go:82
fmt.(*fmt).padString(0xc47dafe040, 0x0, 0x20)
        /home/wenchuang.liu/go/src/fmt/format.go:110 +0x9c fp=0xc494a56af0 sp=0xc494a56a68 pc=0x7365fc
fmt.(*fmt).fmt_s(0xc47dafe040, 0x0, 0x20)
        /home/wenchuang.liu/go/src/fmt/format.go:328 +0x61 fp=0xc494a56b28 sp=0xc494a56af0 pc=0x7373a1
fmt.(*pp).fmtString(0xc47dafe000, 0x0, 0x20, 0x7f3300000073)
        /home/wenchuang.liu/go/src/fmt/print.go:433 +0x197 fp=0xc494a56b60 sp=0xc494a56b28 pc=0x73b077
fmt.(*pp).printArg(0xc47dafe000, 0x1131bc0, 0xc4c6f94200, 0x73)
        /home/wenchuang.liu/go/src/fmt/print.go:664 +0x7b5 fp=0xc494a56be0 sp=0xc494a56b60 pc=0x73d355
fmt.(*pp).doPrintf(0xc47dafe000, 0x1232d53, 0xb, 0xc494a56dd0, 0x4, 0x4)
        /home/wenchuang.liu/go/src/fmt/print.go:996 +0x15a fp=0xc494a56d10 sp=0xc494a56be0 pc=0x740cea
fmt.Sprintf(0x1232d53, 0xb, 0xc494a56dd0, 0x4, 0x4, 0xc4c48478d8, 0x8)
        /home/wenchuang.liu/go/src/fmt/print.go:196 +0x66 fp=0xc494a56d68 sp=0xc494a56d10 pc=0x739226
i7zuoye.com/ago/gomark/service/utils.createTrainingPath(0x0, 0x20, 0x122f9f1, 0x6, 0xc42c2c9560, 0xc4209e0f68)
        /home/wenchuang.liu/gohere/src/i7zuoye.com/ago/gomark/service/utils/media.go:210 +0x190 fp=0xc494a56e20 sp=0xc494a56d68 pc=0xbdc6f0
i7zuoye.com/ago/gomark/service/utils.SaveResult(0x0, 0x20, 0xc4909e4a00, 0xf5e, 0x134f, 0x865823, 0xc4206b0301, 0xc4209e0fa8, 0x865823)
        /home/wenchuang.liu/gohere/src/i7zuoye.com/ago/gomark/service/utils/media.go:116 +0x51 fp=0xc494a56e98 sp=0xc494a56e20 pc=0xbdaf41
i7zuoye.com/ago/gomark/service/evaluate/stream.sendResponse.func1(0xc4acdfbe60, 0xc4909e4a00, 0xf5e, 0x134f, 0xc4371bc410, 0xc8, 0x0, 0x0, 0x0, 0x12392fd, ...)
        /home/wenchuang.liu/gohere/src/i7zuoye.com/ago/gomark/service/evaluate/stream/streamserver.go:390 +0x73 fp=0xc494a56f40 sp=0xc494a56e98 pc=0xbf3593
runtime.goexit()
        /home/wenchuang.liu/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc494a56f48 sp=0xc494a56f40 pc=0x6c9901
created by i7zuoye.com/ago/gomark/service/evaluate/stream.sendResponse
        /home/wenchuang.liu/gohere/src/i7zuoye.com/ago/gomark/service/evaluate/stream/streamserver.go:389 +0x179

任何帮助将不胜感激。

0 个答案:

没有答案