给定一个结构集合,如何使用"范围"模板迭代器打印出一个表,该表为每个结构分配一行,每个字段的列没有明确命名字段?
container := []Node
type Node struct {
Contact_id int
Employer_id int
First_name string
Middle_name string
Last_name string
}
Run Code Online (Sandbox Code Playgroud)
模板代码:
{{range .container}}
<tr>
<td>{{.Prefix}}</td>
<td>{{.First_name}}</td>
<td>{{.Middle_name}}</td>
<td>{{.Last_name}}</td>
<td>{{.Contact_id}}</td>
<td>{{.Employer_id}}</td>
</tr>
{{end}}
Run Code Online (Sandbox Code Playgroud)
当我尝试使用迭代值时
{{range .container}}
{{range .}}
<td>{{.}}</td>
{{end}}
{{end}}
Run Code Online (Sandbox Code Playgroud)
有人告诉我,我无法迭代价值观.有没有干净的方法来做到这一点?
我使用此代码https://gist.github.com/svett/b7f56afc966a6b6ac2fc作为起点.
使用它并将其指向cisco路由器会收到以下错误消息:
拨号失败:ssh:握手失败:ssh:客户端到服务器密码没有通用算法; 客户提供:[aes128-ctr aes192-ctr aes256-ctr aes128-gcm@openssh.com arcfour256 arcfour128],服务器提供:[aes128-cbc 3des-cbc aes192-cbc aes256-cbc]
做了一些阅读后,我了解到我可以通过自定义配置来启用aes128-cbc:
// CBC mode is insecure and so is not included in the default config.
// (See http://www.isg.rhul.ac.uk/~kp/SandPfinal.pdf). If absolutely
// needed, it's possible to specify a custom Config to enable it.
Run Code Online (Sandbox Code Playgroud)
所以我补充说:
HostKeyAlgorithms: []string{"aes128cbcID"},
Run Code Online (Sandbox Code Playgroud)
到我的ssh.ClientConfig,我得到了一个不同的错误:
拨号失败:ssh:握手失败:ssh:主机密钥没有通用算法; 客户提供:[aes128cbcID],服务器提供:[ssh-rsa]
这基本上让我觉得我在指定客户端到服务器密码的时候指定了HostKeyAlgorithm,但我找不到足够的方法来弄清楚如何这样做.
有任何想法吗?