• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
留白
世人慌慌张张,不过图碎银几两
博客园    首页    新随笔       管理    订阅  订阅
07 2020 档案
go 的 protoc 插件调用逻辑

摘要:要让protoc使用插件,需要做下面事情: Place the plugin binary somewhere in the PATH and give it the name "protoc-gen-NAME" (replacing "NAME" with the name of your plu 阅读全文
posted @ 2020-07-30 09:50 留白s 阅读(621) 评论(0) 推荐(0)
微服务 雪崩效应 与 Hystrix 断路器使用入门

摘要:雪崩效应 概述 雪崩效应 1、假设因为某些原因导致服务提供者的响应非常缓慢,消费者对提供者的请求被强制等待,直到服务返回,在高负载场景下,如果不做任何处理,这种问题很可能造成所有处理用户请求的线程都被耗竭,而不能响应用户的进一步请求。 2、在徽服务架构中通常会有多个服务层调用,大量的微服务通过网络进 阅读全文
posted @ 2020-07-22 11:29 留白s 阅读(242) 评论(0) 推荐(0)
TCP 为什么是三次握手,而不是两次或四次?

摘要:双方都需要确认对方收到了自己的序列号 阅读全文
posted @ 2020-07-21 17:05 留白s 阅读(261) 评论(0) 推荐(0)
Mysql 中 MyISAM 和 InnoDB 的区别有哪些?

摘要:作者:oscarwin 链接:https://www.zhihu.com/question/20596402/answer/211492971 来源:知乎 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 区别:1. InnoDB 支持事务,MyISAM 不支持事务。这是 MyS 阅读全文
posted @ 2020-07-21 16:06 留白s 阅读(196) 评论(0) 推荐(0)
面试必备之乐观锁与悲观锁

摘要:悲观锁 总是假设最坏的情况,每次去拿数据的时候都认为别人会修改,所以每次在拿数据的时候都会上锁,这样别人想拿这个数据就会阻塞直到它拿到锁(共享资源每次只给一个线程使用,其它线程阻塞,用完后再把资源转让给其它线程)。传统的关系型数据库里边就用到了很多这种锁机制,比如行锁,表锁等,读锁,写锁等,都是在做 阅读全文
posted @ 2020-07-21 15:53 留白s 阅读(184) 评论(0) 推荐(0)
事务属性 ACID 都是什么?

摘要:事务四大特征:原子性,一致性,隔离性和持久性。 原子性(Atomicity) 一个原子事务要么完整执行,要么干脆不执行。这意味着,工作单元中的每项任务都必须正确执行。如果有任一任务执行失败,则整个工作单元或事务就会被终止。即此前对数据所作的任何修改都将被撤销。如果所有任务都被成功执行,事务就会被提交 阅读全文
posted @ 2020-07-21 14:44 留白s 阅读(393) 评论(0) 推荐(0)
如何使用go module导入本地包

摘要:go module是Go1.11版本之后官方推出的版本管理工具,并且从Go1.13版本开始,go module将是Go语言默认的依赖管理工具。到今天Go1.14版本推出之后Go modules 功能已经被正式推荐在生产环境下使用了。 这几天已经有很多教程讲解如何使用go module,以及如何使用g 阅读全文
posted @ 2020-07-21 11:50 留白s 阅读(894) 评论(0) 推荐(0)
go tour --Interfaces

摘要:package main import ( "fmt" "math" ) type Abser interface { Abs() float64 Abs2() float64 } func main() { var a Abser f := MyFloat(-math.Sqrt2) v := Ve 阅读全文
posted @ 2020-07-21 10:29 留白s 阅读(123) 评论(0) 推荐(0)
go tour --sync.Mutex 互斥锁

摘要:package main import ( "fmt" "sync" "time" ) // SafeCounter is safe to use concurrently. type SafeCounter struct { mu sync.Mutex v map[string]int } // 阅读全文
posted @ 2020-07-20 15:32 留白s 阅读(129) 评论(0) 推荐(0)
go tour --Exercise: Equivalent Binary Trees

摘要:package main import ( "golang.org/x/tour/tree" "fmt" ) // Walk walks the tree t sending all values // from the tree to the channel ch. func Walk(t *tr 阅读全文
posted @ 2020-07-20 15:23 留白s 阅读(277) 评论(0) 推荐(0)
go tour --select or Default Selection

摘要:select语句让goroutine等待多个通信操作。 select会一直阻塞,直到其中一个case可以运行,然后执行那个case。如果有多个就绪,它就随机选择一个。 package main import "fmt" func fibonacci(c, quit chan int) { x, y 阅读全文
posted @ 2020-07-20 14:40 留白s 阅读(150) 评论(0) 推荐(0)
go tour --Channels 与 Buffered Channels

摘要:无缓冲通道(阻塞通道) 写入后立即阻塞,需要另一个协程读取通道的数据后,才能继续执行。 通道操作符 ch <- v // Send v to channel ch. v := <-ch // Receive from ch, and // assign value to v. 无缓冲通道 ch := 阅读全文
posted @ 2020-07-20 14:35 留白s 阅读(137) 评论(0) 推荐(0)
go tour --Exercise: Images

摘要:package main import ( "golang.org/x/tour/pic" "image/color" "image" ) type Image struct{} func (i Image) ColorModel() color.Model { return color.RGBAM 阅读全文
posted @ 2020-07-20 11:46 留白s 阅读(330) 评论(0) 推荐(0)
go tour --Exercise: rot13Reader

摘要:package main import ( "io" "os" "strings" ) type rot13Reader struct { r io.Reader } func (rot rot13Reader) Read (b []byte) (int, error){ n, error := r 阅读全文
posted @ 2020-07-20 11:14 留白s 阅读(220) 评论(0) 推荐(1)
go tour --Exercise: Readers

摘要:package main import "golang.org/x/tour/reader" type MyReader struct{} // TODO: Add a Read([]byte) (int, error) method to MyReader. func (m MyReader) R 阅读全文
posted @ 2020-07-20 10:17 留白s 阅读(351) 评论(0) 推荐(0)
go tour --Errors

摘要:Go程序用error表示错误状态。 error类型是一个类似fmt.Stringer的内置接口 type error interface { Error() string } (与fmt.Stringer, fmt包在打印值错误的值时查找error接口。) 函数通常返回一个error,调用代码应该通 阅读全文
posted @ 2020-07-17 17:35 留白s 阅读(148) 评论(0) 推荐(0)
go tour --Exercise: Stringers

摘要:package main import ( "fmt" "strings" "strconv" ) type IPAddr [4]byte func (ip IPAddr) String() string{ array := make([]string, len(ip)) for i, b := r 阅读全文
posted @ 2020-07-17 16:31 留白s 阅读(215) 评论(0) 推荐(0)
go tour --Stringers

摘要:Stringers 类似java 中的toString type Stringer interface { String() string } Stringer是一种可以将自身描述为字符串的类型。fmt包(和许多其他包)寻找这个接口来打印值。 package main import "fmt" ty 阅读全文
posted @ 2020-07-17 16:30 留白s 阅读(156) 评论(0) 推荐(0)
go tour --Type assertions

摘要:类型断言提供对接口值的底层具体值的访问。 t := i.(T) 该语句断言接口值i持有具体类型T,并将底层T值赋给变量t。 如果i不持有T,该语句将触发恐慌panic。 要测试接口值是否包含特定类型,类型断言可以返回两个值:底层值和报告断言是否成功的布尔值。 t, ok := i.(T) 如果i持有 阅读全文
posted @ 2020-07-17 16:06 留白s 阅读(129) 评论(0) 推荐(0)
go tour --方法值接收器和指针接收器区别

摘要:有两个理由使用指针接收器 第一个是为了让方法可以修改它的接收器指向的值。 第二种方法是避免在每次方法调用时复制值。例如,如果接收方是一个大的结构体,这可能会更有效率。 通常,给定类型上的所有方法都应该具有值或指针接收器,但不能两者混合。(我们将在接下来的几页中看到原因。) 接口 接口是定义的一组方法 阅读全文
posted @ 2020-07-17 15:24 留白s 阅读(471) 评论(0) 推荐(0)
go tour --函数,方法值参数与指针参数区别

摘要:函数 值参数是值传递 package main import ( "fmt" ) type Vertex struct { X, Y float64 } func update(v Vertex){ v.X = 2 v.Y = 2 } func main() { v := Vertex{3, 4} 阅读全文
posted @ 2020-07-17 11:23 留白s 阅读(172) 评论(0) 推荐(0)
go tour --Exercise: Fibonacci closure

摘要:package main import "fmt" // fibonacci is a function that returns // a function that returns an int. func fibonacci() func() int { a, b := 0, 1 return 阅读全文
posted @ 2020-07-16 15:56 留白s 阅读(138) 评论(0) 推荐(0)
go tour --Exercise: Maps

摘要:package main import ( "golang.org/x/tour/wc" "strings" ) func WordCount(s string) map[string]int { countMap := make(map[string]int) for _, k := range 阅读全文
posted @ 2020-07-16 14:43 留白s 阅读(90) 评论(0) 推荐(0)
go 返回中文字符串字串索引

摘要:方法一 str := "返回中文字符串字串索引" subStr := "回" idx := strings.Index(str, subStr) // 3 preStrByt := []byte(str)[:idx] preRune := []rune(string(preStrByt )) ret 阅读全文
posted @ 2020-07-16 12:12 留白s 阅读(1024) 评论(0) 推荐(0)
go tour --Exercise: Slices

摘要:Exercise: Slices package main import "golang.org/x/tour/pic" func Pic(dx, dy int) [][]uint8 { array := make([][]uint8, dy) for i := range array { arra 阅读全文
posted @ 2020-07-16 11:34 留白s 阅读(199) 评论(1) 推荐(0)
VS Code 中的代码自动补全和自动导入包

摘要:VSCode 必须安装以下插件: 首先你必须安装 Golang 插件,然后再给 Go 安装工具包。 在 VS Code 中,使用快捷键:command+shift+P,然后键入:go:install/update tools,将所有 16 个插件都勾选上,然后点击 OK 即开始安装。 修改默认配置的 阅读全文
posted @ 2020-07-15 15:06 留白s 阅读(10638) 评论(0) 推荐(0)
Demystifying Containers - Part I: Kernel Space(翻译)

摘要:原文: https://medium.com/@saschagrunert/demystifying-containers-part-i-kernel-space-2c53d6979504 This series of blog posts and corresponding talks aims 阅读全文
posted @ 2020-07-14 16:02 留白s 阅读(351) 评论(0) 推荐(0)
docker 笔记

摘要:创建镜像 docker build -t getting-started . 启动容器 docker run -dp 3000:3000 getting-started 给镜像打标签 docker tag getting-started YOUR-USER-NAME/getting-started 阅读全文
posted @ 2020-07-10 16:35 留白s 阅读(245) 评论(0) 推荐(0)
docker 官方 getting-started BUG

摘要:Using Docker Compose 一节 使用compose 启动的mysql 容器不能访问,出现错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 我们知道,这是因为my 阅读全文
posted @ 2020-07-10 16:22 留白s 阅读(1118) 评论(0) 推荐(0)
常用西肭字母即读音

摘要::Alpha,音标 /ælfə/,中bai文读音为du“阿尔zhi法” β:beta,音标/'beitə/,中文读音为“贝塔” δ:daodelta,音标/'deltə/,中文读音为“得尔塔” ε:epsilon,音标/ep'silon/,中文读音为“艾普西隆” η:eta,音标/'i:tə/,中文 阅读全文
posted @ 2020-07-09 11:02 留白s 阅读(3574) 评论(0) 推荐(0)
数据库关系代数表达式学习

摘要:关系代数是关系数据库系统查询语言的理论基础。很有必要学习一下,有些是用代数表达式很方便的东西,用SQL写出来还是挺麻烦的,并不是想象当中那么直接。 一、关系代数的9种操作: 关系代数中包括了:并、交、差、乘、选择、投影、联接、除、自然联接等操作。 五个基本操作: 并(∪)、差(-)、笛卡尔积(×)、 阅读全文
posted @ 2020-07-09 10:43 留白s 阅读(6220) 评论(0) 推荐(0)
条件连接(θ连接),等值连接和自然连接之间的差异

摘要:1,条件连接(θ连接),逻辑上是table之间先做笛卡儿积,再做对应选择操作。 如: Table R A B a 1 b 2 Table S H C 1 x 1 y 3 z θ连接的条件为:B<=H A B H C a 1 1 x a 1 1 y a 1 3 z b 2 3 z 2,等值连接,是θ连 阅读全文
posted @ 2020-07-09 10:29 留白s 阅读(3958) 评论(0) 推荐(1)

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