iterate and search over structs

almost 2 years ago - Direct link


I have 2 slices of structs that i need to iterate over and check if value1 on struct1 exist on struct2.

for example take the following two structs:

type parent struct {

ID int

Name string


type child struct {

ID int

Name string

Parent_ID int


i have []child and []parent, and i need to know for each child if child.Parent_ID == Parent.ID

if there is a match I'm just appending it to another slice.

how can i iterate over the two slices and find a match?

Go to article →

Links in this thread