package contoller import ( "encoding/json" "fmt" "github.com/gin-gonic/gin" "go-gin-kubernetes/service" ) func GetPerson(ctx *gin.Context) { person := service.GetPerson(ctx) j, err := json.Marshal(person) if err != nil { ctx.JSON(500, fmt.Sprintf("json marshal err: %v", err)) return } ctx.JSON(200, string(j)) }