Commit 85b82ade by huangchengyi

比价

parent 1f627a1f
...@@ -5,8 +5,9 @@ import "fmt" ...@@ -5,8 +5,9 @@ import "fmt"
func main() { func main() {
s := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9} s := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
//s := []int{33}
fmt.Println(len(s)) fmt.Println(len(s))
s = s[3:9] s = s[1:10]
fmt.Println(s) fmt.Println(s)
fmt.Println(len(s)) fmt.Println(len(s))
fmt.Println(cap(s)) fmt.Println(cap(s))
......
package main
import (
"net/http"
"time"
"github.com/gin-contrib/timeout"
"github.com/gin-gonic/gin"
)
func emptySuccessResponse(c *gin.Context) {
time.Sleep(2* time.Second)
c.String(http.StatusOK, "")
}
func errorResponse(c *gin.Context) {
c.String(http.StatusRequestTimeout, "超时")
}
func main() {
r := gin.New()
r.GET("/", timeout.New(
timeout.WithTimeout(100*time.Microsecond),
timeout.WithHandler(emptySuccessResponse),
timeout.WithResponse(errorResponse),
))
// Listen and Server in 0.0.0.0:8080
r.Run(":8080")
}
\ No newline at end of file
...@@ -6,6 +6,7 @@ require ( ...@@ -6,6 +6,7 @@ require (
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd // indirect github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd // indirect
github.com/elliotchance/orderedmap v1.3.0 // indirect github.com/elliotchance/orderedmap v1.3.0 // indirect
github.com/gin-contrib/cors v1.3.1 github.com/gin-contrib/cors v1.3.1
github.com/gin-contrib/timeout v0.0.1 // indirect
github.com/gin-gonic/gin v1.6.3 github.com/gin-gonic/gin v1.6.3
github.com/go-ini/ini v1.57.0 github.com/go-ini/ini v1.57.0
github.com/go-playground/validator/v10 v10.4.0 // indirect github.com/go-playground/validator/v10 v10.4.0 // indirect
...@@ -34,7 +35,6 @@ require ( ...@@ -34,7 +35,6 @@ require (
github.com/prometheus/procfs v0.0.11 // indirect github.com/prometheus/procfs v0.0.11 // indirect
github.com/sirupsen/logrus v1.5.0 github.com/sirupsen/logrus v1.5.0
github.com/smartystreets/goconvey v1.6.4 // indirect github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/stretchr/testify v1.5.1 // indirect
github.com/syyongx/php2go v0.9.4 github.com/syyongx/php2go v0.9.4
github.com/tidwall/gjson v1.6.1 github.com/tidwall/gjson v1.6.1
github.com/tidwall/sjson v1.1.1 // indirect github.com/tidwall/sjson v1.1.1 // indirect
......
...@@ -152,11 +152,9 @@ func (qs *ParityService) GetParity(ctx *gin.Context) (results model.LyResponse) ...@@ -152,11 +152,9 @@ func (qs *ParityService) GetParity(ctx *gin.Context) (results model.LyResponse)
} }
} }
offset := page_from+gconv.Int(page_size) offset := page_from+gconv.Int(page_size)
if offset > allCount || page_from > allCount { if offset > allCount {
page_from = allCount
offset = allCount offset = allCount
} }
slicNew := slic[page_from:offset] slicNew := slic[page_from:offset]
pageData := PageClear(ctx,gconv.Int64(allCount)); pageData := PageClear(ctx,gconv.Int64(allCount));
pageData["took"] = gjson.Get(esResult, "took").Int() pageData["took"] = gjson.Get(esResult, "took").Int()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment