TrimSuffix trims the suffix from the name and returns the trimmed name.
(name, suffix string)
| 508 | |
| 509 | // TrimSuffix trims the suffix from the name and returns the trimmed name. |
| 510 | func TrimSuffix(name, suffix string) (string, error) { |
| 511 | if !strings.HasSuffix(name, suffix) { |
| 512 | return "", errors.Errorf("invalid request %q with suffix %q", name, suffix) |
| 513 | } |
| 514 | return strings.TrimSuffix(name, suffix), nil |
| 515 | } |
| 516 | |
| 517 | // GetNameParentTokens returns the tokens from a resource name. |
| 518 | func GetNameParentTokens(name string, tokenPrefixes ...string) ([]string, error) { |
no test coverage detected