随笔分类 -  go

1 2 3 4 5 ··· 9 下一页
摘要:``` package main import ( "fmt" "strings" ) func makeSuffixFunc(suffix string) func(string) string { return func(name string) string { if !strings.Has 阅读全文
posted @ 2023-06-13 10:35 ty1539 阅读(17) 评论(0) 推荐(0) 编辑
摘要:shangguigu_go account chapter10 chapter14 chapter15 chapter20 chapter10 chatroom chatsys customerManage familyaccount homework homework13day oa tcpdem 阅读全文
posted @ 2023-03-25 11:14 ty1539 阅读(13) 评论(0) 推荐(0) 编辑
摘要:package main import ( "errors" "fmt" "os" ) // 使用一个结构体管理环形队列 type CircleQueue struct { maxSize int // 4 array [5]int // 数组 head int //指向队列队首 0 tail in 阅读全文
posted @ 2023-03-25 11:14 ty1539 阅读(63) 评论(0) 推荐(0) 编辑
摘要:package main import ( "fmt" ) func A() int { var i int defer func() { i++ fmt.Println("defer func A",i) }() fmt.Println("func A",i) return i } func B( 阅读全文
posted @ 2022-06-15 11:53 ty1539 阅读(16) 评论(0) 推荐(0) 编辑
摘要:package main import ( "fmt" "strconv" "sync" ) type RwMap struct{ mu sync.RWMutex data map[string]int } func New() *RwMap { return &RwMap{data: make(m 阅读全文
posted @ 2022-06-14 23:51 ty1539 阅读(40) 评论(0) 推荐(0) 编辑
摘要:package main import ( "fmt" ) func main() { i := 5 defer func(i *int){ fmt.Println(*i) }(&i) i += 10 } //输出结果:i=15 //defer 即时参数计算 执行到defer的时候实际执行的是run 阅读全文
posted @ 2022-06-14 23:50 ty1539 阅读(991) 评论(0) 推荐(0) 编辑
摘要:https://www.golangroadmap.com/ go 面试 https://search.bilibili.com/all?keyword=go+%E9%9D%A2%E8%AF%95&from_source=webtop_search&spm_id_from=333.1007 阅读全文
posted @ 2022-05-15 10:55 ty1539 阅读(266) 评论(0) 推荐(0) 编辑
摘要:https://golang.org/pkg/io/ Goroutine 1进程和线程 进程是程序在操作系统中的一次执行过程,系统进行资源分配和调度的一个独立单位。 线程是进程的一个执行实体,是CPU调度和分配的基本单位,它是比进程更小的能独立运行的基本单位。 一个进程可以创建和撤销多个线程;同一个 阅读全文
posted @ 2022-05-15 09:03 ty1539 阅读(48) 评论(0) 推荐(0) 编辑
摘要:## go etcd 用脚本多次设置,无法替换, 设置后无法用 etcdctl.exe get 方法获取,有疑问 package main import ( "context" "fmt" etcd_client "go.etcd.io/etcd/clientv3" // 对于第三方开源组件, 取别 阅读全文
posted @ 2022-05-14 21:58 ty1539 阅读(117) 评论(0) 推荐(0) 编辑
摘要:##1, context.WithCancel package main import ( "context" "fmt" "time" ) func main() { test() time.Sleep(time.Second * 5) } func test() { ctx, cancel := 阅读全文
posted @ 2022-05-04 22:24 ty1539 阅读(73) 评论(0) 推荐(0) 编辑
摘要:package main import ( "fmt" ) func main() { //test_for() test_label() } func test_for() { str := "hello,world! 中国" for index, val := range str { fmt.P 阅读全文
posted @ 2022-04-30 16:52 ty1539 阅读(75) 评论(0) 推荐(0) 编辑
摘要:/* 函数也是一种类型 */ package main import ( "fmt" ) /* 自定义函数类型 接受两个int参数,返回int类型*/ type op_func func(int, int) int func main() { test_func() } func test_func 阅读全文
posted @ 2022-04-30 16:40 ty1539 阅读(27) 评论(0) 推荐(0) 编辑
摘要:栈: 先进后出, 子弹装入弹夹, 进入:压栈, 出去:出栈,弹出 函数就是栈内存, 效率高, 栈内存, 内存是在栈空间上分配的 大小 c语音的有1M, go语言有几百kb 堆: 先进先出 系统公用的一块内存, 效率没有栈高 大小 几十G 一个进程有多个线程, 线程空间就是在堆空间内分配,有加锁,解锁 阅读全文
posted @ 2022-04-30 15:29 ty1539 阅读(24) 评论(0) 推荐(0) 编辑
摘要:package main import "fmt" func calc(a , b int) (int,int){ sum := a+b sub := a-b return sum,sub } func calc1(a , b int) (sum int,sub int){ sum = a+b su 阅读全文
posted @ 2022-04-29 23:41 ty1539 阅读(29) 评论(0) 推荐(0) 编辑
摘要:package main import( "fmt" ) func justify(n int) bool{ if n <=1{ return false } for i:=2;i<n;i++{ if n %i == 0 { return false } } return true } func e 阅读全文
posted @ 2022-04-29 23:36 ty1539 阅读(27) 评论(0) 推荐(0) 编辑
摘要:func main(){ var chinese = "我是中国人, I am Chinese" fmt.Println("chinese length", len(chinese)) fmt.Println("chinese word length", len([]rune(chinese))) 阅读全文
posted @ 2022-04-27 21:26 ty1539 阅读(57) 评论(0) 推荐(0) 编辑
摘要:Day 10 http 编程 Go 原生支持 http, import "net/http" Go 的 http 服务性能和 nginx 比较接近 几行代码就可以实现一个 web 服务 简单的例子 package main import ( "fmt" "net/http" ) func Hello 阅读全文
posted @ 2022-04-26 22:49 ty1539 阅读(17) 评论(0) 推荐(0) 编辑
摘要:package main import ( "fmt" _ "github.com/go-sql-driver/mysql" "github.com/jmoiron/sqlx" ) var Db *sqlx.DB func init() { database, err := sqlx.Open("m 阅读全文
posted @ 2022-04-26 22:42 ty1539 阅读(46) 评论(0) 推荐(0) 编辑
摘要:https://www.cnblogs.com/welhzh/p/8981096.html 1, math/big package main import ( "fmt" "math/big" "time" ) const LIM = 10000 //求第10000位的费布拉切数 var fibs 阅读全文
posted @ 2022-04-24 23:52 ty1539 阅读(117) 评论(0) 推荐(0) 编辑
摘要:Day 03 strings 和 strconv 的使用 strings.HasPrefix(str string, prefix string) bool :判断字符串 str 是否以 prefix 开头 strings.HasSuffix(str string, suffix string) b 阅读全文
posted @ 2022-04-09 15:02 ty1539 阅读(42) 评论(0) 推荐(0) 编辑

1 2 3 4 5 ··· 9 下一页
点击右上角即可分享
微信分享提示