I am reading a file with each row containing two words separated by a space. I scan and split each line to two words (strings) and store them in the MyEntity struct (in items). The words are then added to items.
type Entity struct {
Name string
Entity string
}
type MyEntity struct {
Entities []Entity
}
func (entity *MyEntity) AddEntity(item Entity) []Entity {
entity.Entities = append(entity.Entities, item)
return entity.Entities
}
...
items := MyEntity{}
// loop here over the rows - name is first word, entity is second word
item := Entity{
name, entity,
}
items.AddEntity(item)
...
Should items not be a []struct here? I am using the gota package (https://github.com/go-gota/gota) to create a DataFrame from items but using dataframe.LoadStructs(items) fails because items is a struct and it must be a []struct.
I am fairly new to Go, so what am I missing here?
>Solution :
Load the data frame from the slice of entities:
df := dataframe.LoadStructs(items.Entities)