更新文档,代码;

非 *nix 平台不再使用 bubble包, 减小大小
This commit is contained in:
hahafool
2022-04-22 20:11:02 +08:00
parent f5803d1ba0
commit e44e885282
5 changed files with 45 additions and 25 deletions

28
utils/strings_unix.go Normal file
View File

@@ -0,0 +1,28 @@
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd
// +build darwin dragonfly freebsd linux netbsd openbsd
package utils
import (
"github.com/tjarratt/babble"
"go.uber.org/zap"
)
func GetRandomWord() (result string) {
//babbler包 在 系统中 没有 /usr/share/dict/words 且不是windows 时会panic
defer func() {
if r := recover(); r != nil {
if ce := CanLogErr("getRandomWord babble panic"); ce != nil {
ce.Write(zap.Any("err:", r))
}
result = GenerateRandomString()
}
}()
babbler := babble.NewBabbler()
babbler.Count = 1
result = babbler.Babble()
return
}