gpt4 book ai didi

perl - 如何在 golang 中重新创建 perl 的哈希数组?

转载 作者:数据小太阳 更新时间:2023-10-29 03:34:04 24 4
gpt4 key购买 nike

在 perl 中,我可以将 $hashref 插入 @array 并为下一个 foreach 和可能的 encode_json (HTTP POST) 提供此数据。

我不知道如何在 golang 中重新创建相同的登录名?

$VAR1 = [
{
'address' => 'test.com',
'id' => 101,
'hostgroups' => [
zero
'one',
'or many'
],
'host_name' => 'test.com',
'alias' => 'test.com',
'template' => 'generic',
'file_id' => 'etc/config'
},
{
'address' => 'test2.com',
'id' => 102,
'hostgroups' => [
zero
'one',
'or many'
],
'host_name' => 'test2.com',
'alias' => 'test2.com',
'template' => 'generic',
'file_id' => 'etc/config'
},
(..)

最佳答案

var array = []map[string]interface{}{
{"address": "test.com", "hostgroups": []string{"zero", "one", "or many"}, "id": 101},
{"address": "test2.com", "hostgroups": []string{"zero", "one", "or many"}, "id": 102},
}

关于perl - 如何在 golang 中重新创建 perl 的哈希数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54422977/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com