code: func (path *Path) SetMed(med int64, doReplace bool) error {
  	parseMed := func(orgMed uint32, med int64, doReplace bool) (*bgp.PathAttributeMultiExitDisc, error) {
  		if doReplace {
  			return bgp.NewPathAttributeMultiExitDisc(uint32(med)), nil
  		}
  
  		medVal := int64(orgMed) + med
  		if medVal < 0 {
  			return nil, fmt.Errorf("med value invalid. it's underflow threshold: %v", medVal)
  		} else if medVal > int64(math.MaxUint32) {
  			return nil, fmt.Errorf("med value invalid. it's overflow threshold: %v", medVal)
  		}
  
  		return bgp.NewPathAttributeMultiExitDisc(uint32(int64(orgMed) + med)), nil
  	}
  
  	m := uint32(0)
  	if attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC); attr != nil {
  		m = attr.(*bgp.PathAttributeMultiExitDisc).Value
  	}
  	newMed, err := parseMed(m, med, doReplace)
  	if err != nil {
  		return err
  	}
  	path.setPathAttr(newMed)
  	return nil
  }
docs: // SetMed replace, add or subtraction med with new ones.