摘要: TCP/UDP报文头讲解 https://www.jianshu.com/p/10e34f5bf414 阅读全文
posted @ 2019-08-17 16:00 初见未来 阅读(82) 评论(0) 推荐(0) 编辑
摘要: import ("fmt""gopkg.in/mgo.v2""gopkg.in/mgo.v2/bson""log")在示例中用到的结构有:type Student struct {Id_ bson.ObjectId bson:"_id"Name string bson:"name"Phone str 阅读全文
posted @ 2019-08-17 15:53 初见未来 阅读(807) 评论(0) 推荐(0) 编辑
摘要: package os_ioutilimport ( "fmt" "io/ioutil" "os" "strings")func main() { //获取当前登录用户 //u, _ := user.Current() //fmt.Println(u.Name) //fmt.Println(u.Uid 阅读全文
posted @ 2019-08-17 15:46 初见未来 阅读(433) 评论(0) 推荐(0) 编辑
摘要: package lock_unlockimport ( "fmt" "sync")var ( num = 100 wg sync.WaitGroup n sync.Mutex)func main() { //互斥锁 //go语言中多个协程操作一个变量时会出现冲突的问题 //go eun -race 阅读全文
posted @ 2019-08-17 15:44 初见未来 阅读(882) 评论(0) 推荐(0) 编辑
摘要: mongoos学习mongoose是mongoDB的一个对象模型工具,是基于node-mongodb-native开发的mongoDB的nodejs驱动,可以在异步的环境下执行。同时它也是针对mongoDB操作的一个对象模型库,封装了mongoDB对文档的一些增删改查等常用方法,让nodejs操作m 阅读全文
posted @ 2019-08-17 15:43 初见未来 阅读(162) 评论(0) 推荐(0) 编辑
摘要: mongodb的MapReduce学习Map-Reduce部分:Map-Reduce相当于关系型数据库中的group by,主要用于统计数据之用。MongoDB提供的Map-Reduce非常灵活,对于大规模数据分析也相当实用。语法db.collection.mapReduce( map, // 即m 阅读全文
posted @ 2019-08-17 15:42 初见未来 阅读(174) 评论(0) 推荐(0) 编辑
摘要: mongodb知识点:增:use config db.config.insert({'a':1})查:show dbs show collections/show tables删:use pro //使用数据库时不加分号 db.ta.drop()//表的删除 db.dropDatabase()//删 阅读全文
posted @ 2019-08-17 15:42 初见未来 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 知识点:【http传输】respBodyMap := bson.M{"状态码": "成功", "userId": userId, "dataSource": dataSource, "upDown": upDown, "channel": channel, "full": full, "文件详细信息 阅读全文
posted @ 2019-08-17 15:41 初见未来 阅读(583) 评论(0) 推荐(0) 编辑
摘要: package mainimport ( "fmt" "io" "os" "strconv")func main() { /* 思路:断点续传,边复制,边记录复制的数据量 */ srcName := "C:\\liu\\pro\\aa.jpeg" destName := "C:\\liu\\bb.j 阅读全文
posted @ 2019-08-17 15:40 初见未来 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑