I have two structs, Employee and Project.
type Employee struct {
ID int
Projects map[*Departments]struct{}
}
type Project struct {
ID int
}
I have a Company struct that has the following:
type Company struct {
Projects map[*Project]map[*Employee]struct{}
Employees map[*Employee]struct{}
}
Given e *Employee
and c *Company
(func (c *Company) getEmployeesOnSameProject(e *Employee) []*Employee { }
)and knowing that an employee can belong to multiple projects, I am having a difficult time figuring out how to get the employees across projects.
e.Projects
might be something like -
eProjects {
P1
P2
}
c.Projects
might be something like -
cProjects {
P1 {
E1
E2
}
P2 {
E1
E2
E3
E4
}
}
If I am E1, how can I easily get the other employees on the same projects (P1 and P2) as me without having a nested for loop?