摘要: Go函数类型的使用 type myfunc func() string // 声明函数变量 func main() { fn := func() string { return "bbb" } // 声明map myMap := make(map[string]myfunc) // map赋值 myMap["fn"] = fn fmt.Printl... 阅读全文
posted @ 2019-12-19 20:13 离地最远的星 阅读(298) 评论(0) 推荐(0) 编辑
摘要: import "sync" var ( myMap = make(map[int]int, 10) lock sync.Mutex //声明一个全局的互斥锁 //sync 包 同步 // Mutex:是互斥 ) func test(n int){ res := 1 for i:=1;i<=n;i++{ res *=1 ... 阅读全文
posted @ 2019-12-19 20:13 离地最远的星 阅读(220) 评论(0) 推荐(0) 编辑
摘要: Go序列化和反序列化 package main import ( "bufio" "encoding/json" "fmt" "os" ) type Monster struct { Name string Age int Skill string } func (m *Monster) Store(path string) { b, ... 阅读全文
posted @ 2019-12-19 20:09 离地最远的星 阅读(108) 评论(0) 推荐(0) 编辑
摘要: https://blog.csdn.net/zzhongcy/article/details/97243826来自为知笔记(Wiz) 阅读全文
posted @ 2019-12-19 20:07 离地最远的星 阅读(393) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "html/template" "net/http" ) type User struct { UserName string Age int } func info(w http.ResponseWriter, r *http.Request) { t, err := temp... 阅读全文
posted @ 2019-12-19 20:06 离地最远的星 阅读(687) 评论(0) 推荐(0) 编辑
摘要: channel的基本介绍 channel的本质是一个数据结构队列 数据是先进先出 FIFO 线程安全,多goroutine访问时,不需要加锁,就是说channel本身是线程安全的 channel是由类型的,一个string的channel只能存放string类型数据 无缓冲的channel关闭后,再往外读数据读到的是该管道数据类型的初始值 有缓冲的channel的channel关闭后,如果管道... 阅读全文
posted @ 2019-12-19 20:04 离地最远的星 阅读(1052) 评论(0) 推荐(0) 编辑
摘要: ARP与RARP详细解析 原创zlnnjit 发布于2016-04-03 15:12:15 阅读数 9544 收藏 展开 地址解析协议 ARP和逆地址解析协议RARP 1.基本关系: ​ 2.地址解析协议 ARP的实现过程: 不管网络层使用的是什么协议,在实际网络的链路上传送数据帧时,最终还是必须使用硬件地址。 ‚每一个主机都设有一个 ARP高速缓存(AR... 阅读全文
posted @ 2019-12-19 20:02 离地最远的星 阅读(344) 评论(0) 推荐(0) 编辑
摘要: package main import ( "errors" "fmt" "reflect" ) type Student struct { Name string `json:"name"` Age int `json:"age"` } type Teacher struct { name string } func (Studen... 阅读全文
posted @ 2019-12-19 20:00 离地最远的星 阅读(94) 评论(0) 推荐(0) 编辑
摘要: Go 系列教程 —— 31. 自定义错误 使用 New 函数创建自定义错误 创建自定义错误最简单的方法是使用 errors 包中的 New 函数。 在使用 New 函数 创建自定义错误之前,我们先来看看 New 是如何实现的。如下所示,是 errors 包 中的 New 函数的实现。 // Package errors implements functions to manipulate ... 阅读全文
posted @ 2019-12-19 19:57 离地最远的星 阅读(197) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "unsafe" ) type W struct { a byte b int32 c int32 } func main() { var w = W{b: 32, c: 64} t := unsafe.Pointer(&w) ... 阅读全文
posted @ 2019-12-19 19:53 离地最远的星 阅读(976) 评论(0) 推荐(0) 编辑