摘要: package main /* #cgo LDFLAGS: -lre2 -lcre2 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <cre2.h> */ import ( "C" "fmt" "unsafe" 阅读全文
posted @ 2023-03-04 23:54 ty1539 阅读(14) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" ) type T struct { a int } func (t T) Get() int { return t.a } func (t *T) Set(i int) { t.a = i } //表达式`T.Get`和`(*T).Set`被称 阅读全文
posted @ 2023-03-04 23:46 ty1539 阅读(11) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "sync" "time" ) var producer = func(wg *sync.WaitGroup, l sync.Locker) { defer wg.Done() for i := 5; i > 0; i-- { l.Lock() 阅读全文
posted @ 2023-03-04 22:47 ty1539 阅读(9) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "time" ) //https://blog.csdn.net/qq_35655945/article/details/82706022 type Duration int64 const ( Nanosecond Duration = 1 阅读全文
posted @ 2023-03-04 22:45 ty1539 阅读(19) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "os" ) type point struct { x, y int } func main() { p := point{1, 2} fmt.Printf("001>>%v\n", p) // => {1 2} fmt.Printf("00 阅读全文
posted @ 2023-03-04 14:23 ty1539 阅读(73) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "strconv" ) func main() { //Go语言中不允许隐式转换,所有类型转换必须显式声明(强制转换),而且转换只能发生在两种相互兼容的类型之间。 i := 65 f := float64(i) u := uint(i) s : 阅读全文
posted @ 2023-03-04 13:53 ty1539 阅读(156) 评论(0) 推荐(0) 编辑
摘要: package main import "fmt" func main() { //申明指针的时候,如果没有指向某个变量,默认值为nil //不能直接进行操作,包括读写 //而用new返回的是有默认值的指针, 为数据类型的默认值 var p1 = new(int) *p1 = 123 // pani 阅读全文
posted @ 2023-03-04 13:42 ty1539 阅读(17) 评论(0) 推荐(0) 编辑
摘要: goland设置:https://blog.csdn.net/fly910905/article/details/127146795 阅读全文
posted @ 2023-03-04 13:27 ty1539 阅读(0) 评论(0) 推荐(0) 编辑
摘要: 参考自:https://blog.csdn.net/qq_40607566/article/details/123178731 1.在GoLand上方菜单栏点击Help->Find Action 或者 ctrl+shift+a 2.单击Find Action,输入Registry 3.单击Regis 阅读全文
posted @ 2023-03-04 12:17 ty1539 阅读(83) 评论(0) 推荐(0) 编辑
摘要: package main import "fmt" func main() { /* panic:词义"恐慌", recover:"恢复" go语言利用panic(),recover(),实现程序中的极特殊的异常的处理 panic(),让当前的程序进入恐慌,中断程序的执行 recover(),让程序 阅读全文
posted @ 2023-03-04 11:53 ty1539 阅读(15) 评论(0) 推荐(0) 编辑