mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +01:00
Winni Neessen
19330fc108
Removed error handling from `randNum` in `random_test.go` and introduced new `randNum` implementations for different Go versions (1.19, 1.20-1.21, 1.22+). This ensures compatibility with different versions of Go and utilizes the appropriate version-specific random number generation methods. We are using math/rand instead crypto/rand. For our needs this should be sufficient.
20 lines
344 B
Go
20 lines
344 B
Go
// SPDX-FileCopyrightText: 2022-2023 The go-mail Authors
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
//go:build go1.20 && !go1.22
|
|
// +build go1.20,!go1.22
|
|
|
|
package mail
|
|
|
|
import (
|
|
"math/rand"
|
|
)
|
|
|
|
// randNum returns a random number with a maximum value of length
|
|
func randNum(maxval int) int {
|
|
if maxval <= 0 {
|
|
return 0
|
|
}
|
|
return rand.Intn(maxval)
|
|
}
|