我有一块结构.
type Config struct {
Key string
Value string
}
// I form a slice of the above struct
var myconfig []Config
// unmarshal a response body into the above slice
if err := json.Unmarshal(respbody, &myconfig); err != nil {
panic(err)
}
fmt.Println(config)
Run Code Online (Sandbox Code Playgroud)
这是这个的输出:
[{key1 test} {web/key1 test2}]
Run Code Online (Sandbox Code Playgroud)
如何搜索此数组以获取元素在哪里key="key1"?