• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
孙龙 程序员
少时总觉为人易,华年方知立业难
博客园    首页    新随笔    联系   管理    订阅  订阅
07 2019 档案
golang 上下文context用法详解

摘要:背景 在go服务器中,对于每个请求的request都是在单独的goroutine中进行的,处理一个request也可能设计多个goroutine之间的交互, 使用context可以使开发者方便的在这些goroutine里传递request相关的数据、取消goroutine的signal或截止日期。 阅读全文
posted @ 2019-07-30 20:31 孙龙-程序员 阅读(20848) 评论(2) 推荐(3)
httpserver支持路由传输控制器

摘要:main.go 阅读全文
posted @ 2019-07-28 21:22 孙龙-程序员 阅读(409) 评论(0) 推荐(0)
httpserver实现简单的上下文

摘要:package main import ( "net/http" "com.jtthink.net/myhttpserver/core" ) type MyHandler struct { } func(*MyHandler) ServeHTTP(writer http.ResponseWriter 阅读全文
posted @ 2019-07-28 18:54 孙龙-程序员 阅读(268) 评论(0) 推荐(0)
httpserver

摘要:快速创建一个httpserver 路由 设置cookie 注销 判断登录 package main import ( "net/http" "time" ) type MyHandler struct { } func(*MyHandler) ServeHTTP(writer http.Respon 阅读全文
posted @ 2019-07-27 15:08 孙龙-程序员 阅读(409) 评论(0) 推荐(0)
多协成利用互斥锁按顺序执行读取文件

摘要:text文本 1、动态规划比递归快-LeetCode91-解码方法2、Linux内存描述之内存节点node--Linux内存管理3、笔试题—字符串常见的算法题集锦4、机器学习系列(14)_SVM碎碎念part2:SVM中的向量与空间距离5、大数运算(7)——大数阶乘(求阶乘)6、经典设计模式实战演练 阅读全文
posted @ 2019-07-24 21:28 孙龙-程序员 阅读(372) 评论(0) 推荐(0)
channel补充

摘要:无缓冲管道 : 指在接收前没有能力保存任何值的通道,这种类型通道要求发送gorouutine和接收goroutine同时准备好,才能完成发送和接收操作。如果两个goroutine没有同时准备好, 通道会导致先执行发送或者接收的goroutine阻塞等待,这种对通道进行发送和接收的交互行为本身就是同步 阅读全文
posted @ 2019-07-23 22:15 孙龙-程序员 阅读(245) 评论(0) 推荐(0)
获取小程序的手机号

摘要:* -41001: encodingAesKey 非法 * -41003: aes 解密失败 * -41004: 解密后得到的buffer非法 * -41005: base64加密失败 * -41016: base64解密失败 * */ class ErrorCode { public static $OK = 0; publ... 阅读全文
posted @ 2019-07-23 11:43 孙龙-程序员 阅读(399) 评论(0) 推荐(0)
php 简单加密解密

摘要:0) && substr($result, 10, 16) == substr(md5(substr($result, 26) . $keyb), 0, 16) ) { return substr($result, 26); } else { return ''; } ... 阅读全文
posted @ 2019-07-23 11:37 孙龙-程序员 阅读(876) 评论(0) 推荐(0)
goroutine channel

摘要:package main import ( "fmt" _ "time" "sync" ) // 需求:现在要计算 1-200 的各个数的阶乘,并且把各个数的阶乘放入到map中。 // 最后显示出来。要求使用goroutine完成 // 思路 // 1. 编写一个函数,来计算各个数的阶乘,并放入到 阅读全文
posted @ 2019-07-17 21:43 孙龙-程序员 阅读(256) 评论(0) 推荐(0)
json序列化和反序列化

摘要:序列化 反序列化: 阅读全文
posted @ 2019-07-17 19:36 孙龙-程序员 阅读(940) 评论(0) 推荐(0)
golang 命令行参数

摘要:package main import ( "fmt" "flag" ) func main() { //定义几个变量,用于接收命令行的参数值 var user string var pwd string var host string var port int //&user 就是接收用户命令行中输入的 -... 阅读全文
posted @ 2019-07-14 13:09 孙龙-程序员 阅读(7063) 评论(0) 推荐(0)
go 文件操作 io

摘要:缓冲区,只有当内存达到一定数量后才会写入 阅读全文
posted @ 2019-07-14 12:00 孙龙-程序员 阅读(798) 评论(0) 推荐(0)
类型断言

摘要:练习: 阅读全文
posted @ 2019-07-13 15:31 孙龙-程序员 阅读(179) 评论(0) 推荐(0)
多态

摘要:package main import ( "fmt" ) //声明/定义一个接口 type Usb interface { //声明了两个没有实现的方法 Start() Stop() } //声明/定义一个接口 type Usb2 interface { //声明了两个没有实现的方法 Start() Stop() T... 阅读全文
posted @ 2019-07-13 15:21 孙龙-程序员 阅读(154) 评论(0) 推荐(0)
实现接口和继承的区别

摘要: 阅读全文
posted @ 2019-07-13 15:20 孙龙-程序员 阅读(544) 评论(0) 推荐(0)
golang interface

摘要:package main import ( "fmt" ) //声明/定义一个接口 type Usb interface { //声明了两个没有实现的方法 Start() Stop() } //声明/定义一个接口 type Usb2 interface { //声明了两个没有实现的方法 Start() Stop(... 阅读全文
posted @ 2019-07-13 14:39 孙龙-程序员 阅读(339) 评论(0) 推荐(0)
go struct 继承

摘要: 阅读全文
posted @ 2019-07-13 14:35 孙龙-程序员 阅读(651) 评论(0) 推荐(0)
go strcut 封装

摘要:package model import "fmt" type person struct { Name string age int //其它包不能直接访问.. sal float64 } //写一个工厂模式的函数,相当于构造函数 func NewPerson(name string) *pers 阅读全文
posted @ 2019-07-13 14:20 孙龙-程序员 阅读(155) 评论(0) 推荐(0)
go struct 抽象

摘要:package main import ( "fmt" ) //定义一个结构体Account type Account struct { AccountNo string Pwd string Balance float64 } //方法 //1. 存款 func (account *Account 阅读全文
posted @ 2019-07-13 14:12 孙龙-程序员 阅读(260) 评论(0) 推荐(0)
go struct 工厂

摘要: 阅读全文
posted @ 2019-07-13 14:05 孙龙-程序员 阅读(203) 评论(0) 推荐(0)
golang struct

摘要:package main import "fmt" type Cat struct{ Name string Age int Color string Hobby string } func main(){ var cat1 Cat cat1.Name = "小白" cat1.Age = 3 cat1.Color ... 阅读全文
posted @ 2019-07-10 19:23 孙龙-程序员 阅读(182) 评论(0) 推荐(0)
golang map

摘要: 阅读全文
posted @ 2019-07-06 15:34 孙龙-程序员 阅读(137) 评论(0) 推荐(0)
golang数组 排序和查找

摘要:package main import "fmt" func BubbleSort(arr *[5]int){ fmt.Println("排序前arr=",(*arr)) temp := 0 for i := 0;i (*arr)[j+1]){ temp = (*arr)[j] (*arr)[j] = (*arr)[j+1]... 阅读全文
posted @ 2019-07-06 14:19 孙龙-程序员 阅读(9248) 评论(0) 推荐(0)
golang数组与切片

摘要:package main import "fmt" func fbn(n int) ([]uint64... 阅读全文
posted @ 2019-07-04 22:18 孙龙-程序员 阅读(223) 评论(0) 推荐(0)

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3