// ValidateASNumber takes a string as an input and makes sure it's a valid ASNumber. // Returns the parsed ASNumber, and prints error and exits if not. func ValidateASNumber(str string) numorstring.ASNumber { asn, err := numorstring.ASNumberFromString(str) if err != nil { fmt.Printf("Error executing command: invalid AS Number specified: %s\n", str) os.Exit(1) } return asn }
func (a asnum) set(value, node string) error { if node != "" { return errors.New("--node should not be specified") } asn, err := numorstring.ASNumberFromString(value) if err != nil { return errors.New("the supplied AS number is not valid") } return a.c.SetGlobalASNumber(asn) }