1 Star 0 Fork 0

Adonis / goutil

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
goutil.go 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
beilei 提交于 2021-10-19 07:42 . fix
package goutil
import (
"fmt"
"math/rand"
"strconv"
"time"
)
func SayHello() {
fmt.Println("hello qzp")
}
func FindType(i interface{}) {
switch x := i.(type) {
case int:
fmt.Println(x, "is int")
case string:
fmt.Println(x, "is string")
case nil:
fmt.Println(x, "is nil")
default:
fmt.Println(x, "not type matched")
}
}
func MyPrintf(args ...interface{}) {
for _, arg := range args {
switch arg.(type) {
case int:
fmt.Println(arg, "is an int value.")
case string:
fmt.Println(arg, "is a string value.")
case int64:
fmt.Println(arg, "is an int64 value.")
default:
fmt.Println(arg, "is an unknown type.")
}
}
}
func GetRandomWelcome() {
sWelcomeList := []string{"come on qzp", "happy everyday qzp", "take easy qzp", "you are best qzp", "relax yourself qzp", "please laugh haha qzp"}
iWelcomeListLen := len(sWelcomeList)
// for idx := 0; idx < sWelcomeLen; idx++ {
// fmt.Println(sWelcomeList[idx])
// }
t := time.Now()
dateFmt := t.Format("2006-01-02 15:04:05") //go诞生的时间
logStr := "[当前的时间是:" + dateFmt + "]" + "欢迎语长度为" + strconv.Itoa(iWelcomeListLen) + ",欢迎语为"
rand.Seed(time.Now().UnixNano())
iRandNum := rand.Intn(iWelcomeListLen)
logStr += sWelcomeList[iRandNum]
fmt.Println(logStr)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xxxieo/goutil.git
git@gitee.com:xxxieo/goutil.git
xxxieo
goutil
goutil
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891