types: simplify ValidExchangeName function

This commit is contained in:
c9s 2023-05-16 18:32:08 +08:00
parent 9f1c2f9ae4
commit ad502f67e9
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -58,15 +58,11 @@ var SupportedExchanges = []ExchangeName{
}
func ValidExchangeName(a string) (ExchangeName, error) {
switch strings.ToLower(a) {
case "max":
return ExchangeMax, nil
case "binance", "bn":
return ExchangeBinance, nil
case "okex":
return ExchangeOKEx, nil
case "kucoin":
return ExchangeKucoin, nil
aa := strings.ToLower(a)
for _, n := range SupportedExchanges {
if string(n) == aa {
return n, nil
}
}
return "", fmt.Errorf("invalid exchange name: %s", a)