1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-06 00:03:32 +00:00

refactor: use strings.Cut to simplify code

Signed-off-by: vicerace <vicerace@sohu.com>
This commit is contained in:
vicerace
2025-11-25 18:26:16 +08:00
committed by dougal
parent 6858bf242e
commit 9be7f99bf8
4 changed files with 15 additions and 15 deletions

View File

@@ -29,16 +29,16 @@ func (bp *BwPair) String() string {
// Set the bandwidth from a string which is either
// SizeSuffix or SizeSuffix:SizeSuffix (for tx:rx bandwidth)
func (bp *BwPair) Set(s string) (err error) {
colon := strings.Index(s, ":")
before, after, ok := strings.Cut(s, ":")
stx, srx := s, ""
if colon >= 0 {
stx, srx = s[:colon], s[colon+1:]
if ok {
stx, srx = before, after
}
err = bp.Tx.Set(stx)
if err != nil {
return err
}
if colon < 0 {
if !ok {
bp.Rx = bp.Tx
} else {
err = bp.Rx.Set(srx)