We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go version
$ go version go1.16
Don't now
go env
context
Code example as follow.But I can't reappear agin. What can i do for it?
package test import "context" type Test struct { TraceId string context context.Context } func (p *Test) Context() context.Context { if p.context == nil { //p.context = context.WithValue(context.Background(), "trace_id", p.TraceId) //start := time.Now() //p.context = context.WithValue(p.context, "start_time", &start) traceId := "dddddddddddddsdd" p.context = context.WithValue(context.Background(), "trace_id", traceId) } return p.context }
package main import test "gitlab.ctyun.cn/vnet/ops/smoke-online/script/test_pkg" var ch = make(chan *test.Test) func getCh() chan *test.Test { return ch } func main() { go func() { testIns := &test.Test{ TraceId: "xxxxx", } getCh() <- testIns }() newTestIns := <-ch trace_id, _ := newTestIns.Context().Value("trace_id").(string) println(trace_id) }
panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x498782] goroutine 293 [running]: panic({0xcc9360, 0x14976e0}) /usr/local/go/src/runtime/panic.go:987 +0x3ba fp=0xc0003f14f0 sp=0xc0003f1430 pc=0x4379ba runtime.panicmem(...) /usr/local/go/src/runtime/panic.go:260 runtime.sigpanic() /usr/local/go/src/runtime/signal_unix.go:835 +0x2f6 fp=0xc0003f1540 sp=0xc0003f14f0 pc=0x44e636 context.(*valueCtx).Value(0xc000414000?, {0xc86b80?, 0xf21920?}) /usr/local/go/src/context/context.go:563 +0x22 fp=0xc0003f1578 sp=0xc0003f1540 pc=0x498782 gitlab.xxxx.cn/vnet/xxx-utils/log.(*Logger).OutputContext(0xc000229f20, {0xf2b8d8, 0x0}, 0x0?, 0x2, {0xdfe97b, 0x31}, {0xc0003f1960, 0x1, 0x1})
The text was updated successfully, but these errors were encountered:
1.16 is outside of our supported range
Sorry, something went wrong.
No branches or pull requests
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Don't now
What operating system and processor architecture are you using (
go env
)?context
Code example as follow.But I can't reappear agin. What can i do for it?
Panic
The text was updated successfully, but these errors were encountered: