Categorygithub.com/blacktear23/tgin
repositorypackage
1.0.8
Repository: https://github.com/blacktear23/tgin.git
Documentation: pkg.go.dev

# README

tgin

GoDoc

tgin is a light weight web framework

tgin API is most like gin web framework. But it is implements by basic go http library. If you focus on small compiled binary size and not very relay on all gin features, you can use it instead of gin.

Binary Size

Gin sample code:

package main

import (
	"github.com/gin-gonic/gin"
)

func main() {
	gin.SetMode(gin.ReleaseMode)
	r := gin.Default()
	r.GET("/ping", func(c *gin.Context) {
		msg := "Hello World"
		value, have := c.GetQuery("name")
		if have {
			msg = "Hello " + value
		}
		c.IndentedJSON(200, gin.H{"Message": msg})
	})
	r.Run("0.0.0.0:8888")
}

tgin sample code:

package main

import (
	gin "github.com/blacktear23/tgin"
)

func main() {
	r := gin.Default()
	r.GET("/ping", func(c *gin.Context) {
		msg := "Hello World"
		value, have := c.GetQuery("name")
		if have {
			msg = "Hello " + value
		}
		c.IndentedJSON(200, gin.H{"Message": msg})
	})
	r.Run("0.0.0.0:8888")
}

Compile command:

go build -trimpath -ldflags "-s -w"

Compiled binary size:

PackageBinary Size (byte)Reduce Ratiogo version
gin11863092 Byte0%1.14
tgin6076500 Byte48%1.14
gin11819212 Byte0%1.15
tgin5186060 Byte56%1.15