package main
import (
"fmt"
)
var a map[string][]byte
func test(key string, value []byte) {
if value == nil {
a[key] = nil
} else {
a[key] = value
}
}
var b = []byte{1, 2, 3}
var c = []byte{5, 6, 7}
func main() {
a = make(map[string][]byte)
test("hello", b)
test("world", c)
test("world", nil)
value1, ok1 := a["hello"]
value2, ok2 := a["world"]
value3, ok3 := a["hhhhh"]
fmt.Println(value1, ok1)
fmt.Println(value2, ok2)
fmt.Println(value3, ok3)
}
[1 2 3] true
[] true
[] false