Func with ...[]string parameter

Hi! This is my code:

type Dog struct {
Name string json:"name"
Year_old float32 json:"year_old"
Description []string json:"description"
}

type Dogs struct {
Dogs []Dog json:"Dogs"
}

func GetMessage(descriptions …[]string) (descModify string){
//here i need received all descriptions from all objects Dog.Description
}

The questions is how send all []String Dog.Description to func GetMessage(descriptions …[]string). Always send the last object in my test!

Thank you!

Iterate over all of your dogs in a loop, append their names into a slice, pass that using ... to your GetMessage.

If that doesn’t work, show us your go implementation of my english words.

1 Like

OK Norbert,
I am testing. I’ll let you know later.