package dcxSwitchapi import "encoding/json" type ( SwitchApiNeighbors struct { Items []*SwitchApiNeighbor `json:"items"` Links map[string]*SwitchApiLink `json:"links"` } SwitchApiNeighbor struct { Name string `json:"name"` Href string `json:"href"` IntId int `json:"interface_id"` RemoteIf string `json:"remote_if"` Type string `json:"type"` } ) func (s *Client) SwitchNeighbors(swName string) (*SwitchApiNeighbors, error) { body, err := s.get(swName + "/neighbors") if err != nil { return nil, err } var sn SwitchApiNeighbors if err = json.Unmarshal(*body, &sn); err != nil { return nil, err } return &sn, nil } func (s *SwitchApiNeighbors) UniqueList() (ns []*SwitchApiNeighbor) { sl := make(map[int]*SwitchApiNeighbor) for _, i := range s.Items { if _, ok := sl[i.IntId]; ok { if i.Type == "cdp" { sl[i.IntId] = i } continue } sl[i.IntId] = i } for _, s := range sl { ns = append(ns, s) } return }