From e343a5000356a3ac410fa506571a60dd29071143 Mon Sep 17 00:00:00 2001 From: lingling Date: Sat, 1 Apr 2023 14:51:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=93=8D=E5=BA=94=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 5101bf1..18e2375 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "net/http" + "time" "github.com/idoubi/goz" "github.com/labstack/echo/v4" @@ -15,8 +16,9 @@ type server struct { type result struct { // 通过json标签指定json字段名 - Sataus int `json:"sataus"` - Code int `json:"code"` + Sataus int `json:"sataus"` + Code int `json:"code"` + Time string `json:"time"` } func main() { @@ -41,7 +43,10 @@ func textserver(c echo.Context) error { // 通过结构体对象就可以访问json参数 json := new(result) json.Code = http.StatusOK + start := time.Now() json.Sataus = text_url(u.Url) + elapsed := time.Since(start) + json.Time = elapsed.String() return c.JSON(http.StatusOK, json) } func text_url(url string) int {