I don't want to use a DB at this time, I'd like to keep data, as structs, in a file. My question is how to organize and retrieve the data.
For example, I have:
type Foo struct{
Id int
Name string
}
type Bar struct{
Id int
Name string
}
I want to make a bunch of different Foos and Bars, then I want to be able to query/select particular Foos and Bars. Would I make a package then a file in the package, for instance, foo/foo.go; and in foo.go have a method that makes all of the Foos, then another method that would accept, for example, a name, and then search for that particular Foo.
func MakeFoos(){
//make the Foos here, and put them in a global array: []Foo ??
}
func GetFoo(name string) Foo{
//this would search the array populated in MakeFoos() and return a Foo ??
}
Is this an ok start to hold data in memory as opposed to a DB in Go? Any help and suggestions to get me going welcomed.