I would like to now how to return sliced data at a top level but also have the ability to use the function. The pointer reference is required to use the function but i have no idea how to cast the sliced data to the reference.
type User struct {
Id: int
Name: string
}
type Users []User
func (u *Users) SomeFunc() bool {
// Do something
}
Usage below
func run(u []pkg.UserData) *Users {
users := make([]User, 0)
if len(u) > 0 {
for _, val := range o {
// DO Mapping
}
}
return users
}
I tried making users a struct and have a child key called Users which worked fine, but i need the data at a top level and not nested. I assume i would have to do something like return &Users{ //something } but i have no idea what to do.