在 Go 中爲什麼推薦使用空結構體作爲 Context 的 key
使用 Context 進行傳值我們知道 Context 主要有兩種用法,控制鏈路和安全傳值。在此我來演示下如何使用 Context 進行安全傳值:package mainimport ( ”context” ”fmt”)const requestIdKey = ”request-id”func main() { ctx := context.Background() // ⌘ Read more
在 Go 中爲什麼推薦使用空結構體作爲 Context 的 key
使用 Context 進行傳值我們知道 Context 主要有兩種用法,控制鏈路和安全傳值。在此我來演示下如何使用 Context 進行安全傳值:package mainimport ( ”context” ”fmt”)const requestIdKey = ”request-id”func main() { ctx := context.Background() // ⌘ Read more