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

How to set a Go project as a Go module?

When we create an aswsome project written by Go, we always want to provide it for others. Some good projects like gorilla websocket, gorm and gin, we can easily to run go get github.com/xxx to get the Go module and then use it in our projects. So, how can we build our own Go project as a Go module? Github In the platform of Github, you may want to build your projects for all the users so they can use your project directly....

January 1, 2023 · 3 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