mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-16 12:53:23 +00:00
lorawan: simplify GetRand16() function
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -13,11 +13,8 @@ func reverseBytes(s []byte) []byte {
|
|||||||
|
|
||||||
// GetRand16 returns 2 random bytes
|
// GetRand16 returns 2 random bytes
|
||||||
func GetRand16() ([2]uint8, error) {
|
func GetRand16() ([2]uint8, error) {
|
||||||
randomBytes := make([]byte, 2)
|
var randomBytes [2]byte
|
||||||
_, err := rand.Read(randomBytes)
|
_, err := rand.Read(randomBytes[:])
|
||||||
if err != nil {
|
|
||||||
return [2]uint8{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return [2]uint8{randomBytes[0], randomBytes[1]}, nil
|
return randomBytes, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user