mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 09:18:34 +00:00
chore: fix some errors detected by staticcheck (#3089)
* chore: fix some errors detected by staticcheck * feat: remove `rand.Seed()` usage for possibly using "fastrand64" runtime to avoid locking ref: https://pkg.go.dev/math/rand#Seed
This commit is contained in:
parent
173b03448f
commit
a994bf8b04
10 changed files with 23 additions and 27 deletions
|
@ -4,7 +4,6 @@ package dice // import "github.com/xtls/xray-core/common/dice"
|
|||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Roll returns a non-negative number between 0 (inclusive) and n (exclusive).
|
||||
|
@ -46,7 +45,3 @@ func (dd *DeterministicDice) Roll(n int) int {
|
|||
}
|
||||
return dd.Intn(n)
|
||||
}
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().Unix())
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package drain
|
|||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/xtls/xray-core/common/dice"
|
||||
)
|
||||
|
@ -36,7 +35,7 @@ func (d *BehaviorSeedLimitedDrainer) Drain(reader io.Reader) error {
|
|||
}
|
||||
|
||||
func drainReadN(reader io.Reader, n int) error {
|
||||
_, err := io.CopyN(ioutil.Discard, reader, int64(n))
|
||||
_, err := io.CopyN(io.Discard, reader, int64(n))
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue