golang 自学系列(三)-- if,for,channel 一般情况下,if 语句跟大多数语言的 if 判断语句一样,根据一个 boolean 表达式结果来执行两个分支逻辑. 但凡总是有例外,go 语言还有这种写法: // 写法1 if i:= getID(); i < currentID { execute some logic } else { execute some other logic } // 写法2 var obj = map[string]interface{} if va…
为什么会有这个系列? 因为我要往架构方向靠拢啊. 关于架构,其实架构的书我看了<架构整洁之道>,也有<实现驱动领域设计>.但是我感觉明显还不够,所以我在极客时间买了一个架构相关的专栏,这个专栏写的编程语言是 go,为了更好的学习与理解,所以才有这个系列. 我在使用vscode进行go编程时,总会显示一下警告 type Service struct { a *ClassName } exported type Service should have comment or be une…
defer 关键字 首先来看官网的定义: A "defer" statement invokes a function whose execution is deferred to the moment the surrounding function returns, either because the surrounding function executed a return statement, reached the end of its function body, or…