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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user