![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
golang
文章平均质量分 79
lcyouyu
一个有强迫症的程序员
展开
-
用golang实现jsonrpc服务供php调用
项目做大了,免不了要用到微服务,并且是跨语言的。下面用go自带的 Jsonrpc 实现微服务供php调用。 服务端:jsonRpcService.go package main import ( "fmt" "log" "net" "net/rpc" "net/rpc/jsonrpc" "os" ) type RpcService struct { } //请求数据结构体 type RequestData struct { type int data string } // 响原创 2020-10-21 17:33:38 · 603 阅读 · 0 评论 -
golang日志 log包
olang日志 log包 golang提供了一个简单的日志输出包log,常用用法,已经基本满足日常的日志输出需求 1、日志级别有3个,info,fatal,panic 2、 日志文件的输出 import ( "log" "os" ) func main() { logFile,err:=os.Create("./log.log") defer logFile.Close() if err !=nil{ log.Fatalln("create file转载 2020-09-11 14:07:02 · 175 阅读 · 0 评论 -
深入golang中的协程
深入golang中的协程 原文的地址为:https://github.com/forthealll… 介绍go中的协程之前,首先看以下go中的defer函数,defer函数不是普通的函数,defer函数会在普通函数返回之后执行。defer函数中可以释放函数内部变量、关闭数据库连接等等操作,举例来说: func print(){ fmt.Println(2); } func main() { defer print(); fmt.Println(1); } 上述的例子中先输出1后输出2,说明de转载 2020-07-27 15:22:27 · 407 阅读 · 0 评论