package main
import (
"fmt"
)
type demo []struct {
Text string
Type string
}
func main() {
d := demo{
Text: "Hello",
Type: "string",
}
}
在这段代码中,我在声明demostruct 对象时遇到错误:
./prog.go:11:3: undefined: Text
./prog.go:11:9: cannot use "Hello" (untyped string constant) as struct{Text string; 在数组或切片文字中键入 string} 值
./prog.go:12:3: undefined: Type
./prog.go:12:9: cannot use "string" (untyped string constant) as struct{Text string; 在数组或切片文字中键入 string} 值
很明显,因为它不是普通的结构声明,所以请帮助我如何构造结构对象demo?
阿晨1998
相关分类