摘要: people.xml peoples.xml 阅读全文
posted @ 2019-08-17 15:39 初见未来 阅读(213) 评论(0) 推荐(0) 编辑
摘要: package demo_route_mux_defaultimport ( "fmt" "log" "os" "os/signal" "time" //"net" "net/http")func (*Hello) HelloServer1(w http.ResponseWriter, req *h 阅读全文
posted @ 2019-08-17 15:35 初见未来 阅读(210) 评论(0) 推荐(0) 编辑
摘要: package demo_logimport ( "fmt" "log" "os" "path/filepath" "runtime" "strings" "time")func main() { const ( info = iota warn error fatal ) //第一种方法将打印信息 阅读全文
posted @ 2019-08-17 15:33 初见未来 阅读(446) 评论(0) 推荐(0) 编辑
摘要: package mainimport ( "fmt" "github.com/sirupsen/logrus" "reflect")type People struct { Name string `xml:"name"` Address string `xml:"address"`}func (t 阅读全文
posted @ 2019-08-17 15:33 初见未来 阅读(142) 评论(0) 推荐(0) 编辑
摘要: package mainimport ( "bufio" "fmt" "io/ioutil" "os" "time")// os.Openfunc read1(filepath string) string { f, err := os.Open(filepath) if err != nil { 阅读全文
posted @ 2019-08-17 15:25 初见未来 阅读(211) 评论(0) 推荐(0) 编辑
摘要: package demo_channelimport ( "fmt" "time")func main() { //无缓存chan ch := make(chan int) go func() { fmt.Println("执行") ch <- 99 //一般放在有效代码的最后,这是由于若主线程ch 阅读全文
posted @ 2019-08-17 15:24 初见未来 阅读(1003) 评论(0) 推荐(0) 编辑
摘要: package demo_caculorimport ( "fmt" "sync" "time")func main() { //线程与协程 fmt.Println("程序开始") time.AfterFunc(3e9, func() { //此类似协程需要时间,必须注意主线程是否执行时间超过3秒 阅读全文
posted @ 2019-08-17 15:23 初见未来 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 一、TCP/UDP协议TCP (Transmission Control Protocol)和UDP(User Datagram Protocol)协议属于传输层协议。其中TCP提供IP环境下的数据可靠传输,它提供的服务包括数据流传送、可靠性、有效流控、全双工操作和多路复用。通过面向连接、端到端和可 阅读全文
posted @ 2019-08-17 14:03 初见未来 阅读(365) 评论(0) 推荐(0) 编辑
摘要: 1.服务端处理理流程 a.监听端口 b.接受客户端的链接 c.创建Goroutine,处理这个链接(⼀个服务端要链接多个客户端,所以使用Goroutine⾮常简单) 题外话:要是用Java、C#服务这边每⼀个请求都开⼀个线程处理的话,顶多⼏千个,但是Goroutine就⾮常简单。package ma 阅读全文
posted @ 2019-08-17 12:56 初见未来 阅读(178) 评论(0) 推荐(0) 编辑
摘要: go语言读取yaml文件https://github.com/go-yaml/yamltest.yamlcache: enable : false list : [redis,mongoDB]mysql: user : root password : Tech2501 host : 10.11.22 阅读全文
posted @ 2019-08-16 16:52 初见未来 阅读(714) 评论(0) 推荐(0) 编辑