gin可用作go环境的web server, 很好用,来玩下:
1. go get github.com/gin-gonic/gin 下载并安装gin库
结果出现:go build github.com/ugorji/go/codec: /usr/lib/go-1.6/pkg/tool/linux_amd64/compile: signal: killed
在网上查了一下,是oom所致, 用dmesg确认了一下, 果然如此:
[114220.386131] [ 4027] 500 4027 20792 155 41 4 0 0 curl
[114220.386132] Out of memory: Kill process 4018 (compile) score 542 or sacrifice child
[114220.387049] Killed process 4018 (compile) total-vm:492476kB, anon-rss:478772kB, file-rss:0kB
买的腾讯云机器, 内存小, 晕。
索性重启ubuntu, 再go get github.com/gin-gonic/gin一下, 就OK了。
2. 写服务s.go
package main
import "github.com/gin-gonic/gin"
func main() {
r := gin.Default()
r.GET("/ping", func(c *gin.Cont