code: func (path *Path) SetCommunities(communities []uint32, doReplace bool) {
  
  	if len(communities) == 0 && doReplace {
  		// clear communities
  		path.delPathAttr(bgp.BGP_ATTR_TYPE_COMMUNITIES)
  		return
  	}
  
  	newList := make([]uint32, 0)
  	attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_COMMUNITIES)
  	if attr != nil {
  		c := attr.(*bgp.PathAttributeCommunities)
  		if doReplace {
  			newList = append(newList, communities...)
  		} else {
  			newList = append(newList, c.Value...)
  			newList = append(newList, communities...)
  		}
  	} else {
  		newList = append(newList, communities...)
  	}
  	path.setPathAttr(bgp.NewPathAttributeCommunities(newList))
  
  }
docs: // SetCommunities adds or replaces communities with new ones.
  // If the length of communities is 0 and doReplace is true, it clears communities.