The Unit Test Case Guideline Of Golang Gin

At this post, I have brief introduced how to test our gin APIs. And one test case tests one API, maybe this API including thousands functions, this kind of test we allways call Integration Test. The Integration Test always care whether the API works well or not, it does’t care the codes coverage and whether a certain function works as expect or not. So, we need to write Unit Test to ensure our program robust and keeps the issues number at a very low level....

August 24, 2023 · 10 min · wuqiangroy

How to test the APIs of your Go-Gin service?

As the pre-post said, Gin is a famouse web framework writen by Go. I love it and always use it. When I wrote a web server using Go-Gin, how do I test the APIs? This may confused me, only use a command-line tool to verify them? It’s seems ridiculous and non-product. We need to have a full-check for the APIs and it’s better to make it automatic, then we need to integrate it in the CI-CD pipline, make sure that it will run automaticly after we commit codes....

January 3, 2023 · 5 min · wuqiangroy

Integrate websocket to gin

Introduction Gin is a famous web framework written in Go, we can easy to build our web server by following codes: 1 2 3 4 5 6 7 8 9 10 11 12 package main import "github.com/gin-gonic/gin" func main() { r := gin.Default() r.GET("/hello-world", func(c *gin.Context) { c.JSON(200, gin.H{ "message": "hello, world", }) }) r.Run() // listen and serve on 0.0.0.0:8080 } Saving these 11 lines codes as a hello.go file, then run go run hello....

December 16, 2022 · 5 min · wuqiangroy