feat: use cobra to run the app
This commit is contained in:
		@ -22,25 +22,19 @@
 | 
			
		||||
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
// Use the init of automaxprocs package to get the real max procs in a
 | 
			
		||||
// container, in order to avoid latency caused by too many threads.
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"os"
 | 
			
		||||
 | 
			
		||||
	"github.com/gin-gonic/gin"
 | 
			
		||||
	"git.vinchent.xyz/vinchent/howmuch/internal/howmuch"
 | 
			
		||||
	_ "go.uber.org/automaxprocs"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const port = 8080
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	fmt.Println("How much do I owe you?")
 | 
			
		||||
	command := howmuch.NewHowMuchCommand()
 | 
			
		||||
 | 
			
		||||
	r := gin.Default()
 | 
			
		||||
 | 
			
		||||
	r.GET("/", func(ctx *gin.Context) {
 | 
			
		||||
		ctx.JSON(http.StatusOK, gin.H{
 | 
			
		||||
			"message": "how much?",
 | 
			
		||||
		})
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	r.Run(fmt.Sprintf(":%d", port))
 | 
			
		||||
	if err := command.Execute(); err != nil {
 | 
			
		||||
		os.Exit(1)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user