I have a file that has a few structs in it:
type StructBase struct {
// ... lots of fields
}
type Struct1 struct {
StructBase
// ... lots of fields
}
ImplementedStruct1 := &Struct1{
name: "test",
// ...
}
I understand in Go that all capital letter variable names are exported from the package. So naturally ImplementedStruct1
is exported. However, for whatever reason I am getting an
ImplementedStruct1 unexpected
.
Am I missing something here that will allow me to export an implemented struct object from this package? This code seems consistent with this tutorial on Go structs. I apologize if this is obvious, I have been searching and am still pretty new to Go. Thank you!
You cannot use short variable declarations in the package scope. You will have to declare your variable with the following syntax:
var ImplementedStruct1 = &Struct1{
name: "test",
// ...
}