
go
Eider1998
这个作者很懒,什么都没留下…
展开
-
go获取任意时间段的时间戳方法
go获取任意时间段的时间戳方法: //获取当前时区 loc, _ := time.LoadLocation("Local") //日期当天02:32点时间戳(拼接字符串) eyesTime := Time.AddDate(0, 0, -i + 1).Format("20060102") startDate := eyesTime+"_02:32:00" startTime, _:= time.ParseInLocation("20060102_15:04:05",...原创 2021-04-16 15:04:46 · 1070 阅读 · 0 评论 -
go中float32转float64方法
例如a:=23,a是float32类型,现在需要将a转化为float64类型的方法:float64(a)即可。原创 2021-01-18 19:35:21 · 2228 阅读 · 0 评论 -
go读取并删除文件方法
func read_file { file, err := os.Open(txt) if err != nil { fmt.Println(err) return } defer file.Close() scanner := bufio.NewScanner(file) scanner.Split(bufio.ScanLines) // 这是我们的缓冲区 var lines []string for scanner.Scan() { lines = appe.原创 2020-12-09 17:15:30 · 1065 阅读 · 0 评论 -
git中删除指定目录的方法
https://www.cnblogs.com/chihaiping/p/6677624.html原创 2020-09-14 20:59:15 · 250 阅读 · 0 评论 -
ci.yml
Global: tool : build_submitterDefault: profile : [build]Profiles: - profile: name : build env : CENTOS6U3 command : make -f Makefile release : True原创 2020-09-14 20:03:56 · 247 阅读 · 0 评论 -
go程序需要注意的一个点
模块中要导出的函数,必须首字母大写。否则,将会无法找到需要调用的函数!原创 2020-09-07 15:49:42 · 152 阅读 · 0 评论 -
go协程demo
运行:func init() { go func() { for { fmt.Println("Enter in go func()!") time.Sleep(time.Minute) } }()}得到结果:每分钟会打印一条Enter in go func()!原创 2020-09-07 11:48:45 · 352 阅读 · 0 评论 -
expected ‘package‘, found ‘EOF‘解决方法
运行go时出现错误:expected 'package', found 'EOF'解决方法:保存一下文件,在运行即可。原创 2020-09-07 11:04:57 · 8558 阅读 · 0 评论 -
工具:json与go结构体直接转化
工具:json与go结构体直接转化https://mholt.github.io/json-to-go/原创 2020-08-24 17:47:18 · 295 阅读 · 0 评论 -
Go实现底层接口、struct转指定格式json
1.struct设计:type Series struct { Name string `json:"name, omitempty"` Data []string `json:"data, omitempty"`}type Data struct { Categories []string `json:"categories, omitempty"` Series []Series `json:"series, omitempty"`}type Linkprofile原创 2020-07-16 14:33:15 · 291 阅读 · 0 评论 -
postman连接centos的方式
直接域名+端口即可访问。例如:原创 2020-07-14 17:06:19 · 437 阅读 · 0 评论 -
go输出string类型的字符串
string(out)是string类型。for循环将其输出: for i := 0; i < len(string(out)); i++ { fmt.Printf("%c 起始于字位置%d\n", string(out)[i], i) }原创 2020-07-07 20:21:42 · 513 阅读 · 0 评论 -
go执行脚本中的工具
法1.package mainimport ( //"bytes" "fmt" //"log" "os/exec" "time" //"reflect" //"errors" //"strings")func main() { now := time.Now() yesTime := now.AddDate(0,0,-1).Add(time.Minute * -10).Format("20060102 15:04:05")原创 2020-07-06 14:40:56 · 840 阅读 · 0 评论 -
go转化时间、获取昨天的时间
注意:go的Sprintf、Printf、Println用法是不同的。package mainimport( "fmt" "time" )func main() { now := time.Now().Format("20060102 15:04:05") a := fmt.Sprintf("[%s]", now) fmt.Println(a)}...原创 2020-07-06 10:26:25 · 949 阅读 · 0 评论 -
go中的map部分用法
例:map[string]bool{} 此时键的类型是string,当有这个键的时候返回一个布尔型的值(具体自己定)原创 2020-06-29 15:13:23 · 190 阅读 · 0 评论 -
go获取n小时前的时间并且格式化
package mainimport ( "fmt" "time")func main() { now := time.Now() h, _ := time.ParseDuration("-1h") h1 := now.Add(24 * h).Format("2006010215") // 这里是获取了24小时前的时间, // 根据需要修改即可 fmt.Println(h1)}..原创 2020-06-29 11:17:43 · 2424 阅读 · 0 评论 -
go格式化时间以XXXXXXXX类型输出
package mainimport ( "fmt" "time")func main() { nTime := time.Now() yesTime := nTime.AddDate(0, 0, -1) logday := yesTime.Format("20060102") fmt.Println(nTime) fmt.Println(yesTime) fmt.Println(logday)}原创 2020-05-27 15:05:25 · 1200 阅读 · 0 评论 -
go实现阴阳历转化
5.11来了一个新的小需求需要用到go。第一天一下午学习如何用go实现快排,然后自己实现二分查找,第二天用一上午半下午,实现阴阳历转化!const.gopackage SolarLunar/** * @Author zhaojing@cd.baidu.com * @DateTime 2020-05-12 */// lunar_month_days, 每年农历每个月的天数以及闰月的月份var LMD = []int{ 1887, 0x1694, 0x16aa, 0x4原创 2020-05-12 15:31:24 · 634 阅读 · 0 评论 -
go实现快速排序
package mainimport ( "fmt" "math/rand" "time")func initData(a []int){ for i, _ := range a { a[i] = rand.Intn(100) }}func partition(a []int, lo, hi int) int { if lo > hi{ return 0 } i, j, temp := lo, hi, a[lo] for i < j{ for i .原创 2020-05-11 19:02:42 · 150 阅读 · 0 评论