init: 1.0.0

This commit is contained in:
Chang lue Tsen
2025-04-25 12:08:29 +09:00
commit 8addcc584b
1031 changed files with 76472 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
package tool
import (
"fmt"
"math/rand"
"strconv"
"strings"
"time"
)
func GenerateTradeNo() string {
now := time.Now()
formattedTime := now.Format("20060102150405") + strconv.Itoa(now.Nanosecond())
numeric := [10]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
r := len(numeric)
source := rand.NewSource(time.Now().UnixNano())
random := rand.New(source)
var code strings.Builder
for i := 0; i < 4; i++ {
_, _ = fmt.Fprintf(&code, "%d", numeric[random.Intn(r)])
}
formattedTime += code.String()
return formattedTime
}