【发布时间】:2021-03-23 13:48:03
【问题描述】:
我对 Golang 很陌生,我正在尝试做一些我认为很容易的事情,但我在完成它时遇到了麻烦。给定以下代码
package main
import (
"encoding/json"
"fmt"
"os"
)
type Example struct {
Data []struct {
Name string `json:"Name"`
Onboarded bool `json:"Onboarded"`
} `json:"data"`
}
func main() {
// This is what I am trying to figure out.
// How do I properly instantiate the Example type struct with values ?
// I'm not getting the Data part.
example := Example{
Data: ...
}
}
感谢任何帮助。谢谢。
【问题讨论】: