chore: add some annotations (#1544)

ref: #1075 
because I am not a native English, maybe have a bit problem.
This commit is contained in:
田欧
2018-09-15 10:23:32 +08:00
committed by Bo-Yi Wu
parent 3f27866f80
commit d510595aa5
21 changed files with 97 additions and 16 deletions

View File

@ -6,7 +6,7 @@ import (
"github.com/gin-gonic/gin"
)
var DB = make(map[string]string)
var db = make(map[string]string)
func setupRouter() *gin.Engine {
// Disable Console Color
@ -21,7 +21,7 @@ func setupRouter() *gin.Engine {
// Get user value
r.GET("/user/:name", func(c *gin.Context) {
user := c.Params.ByName("name")
value, ok := DB[user]
value, ok := db[user]
if ok {
c.JSON(http.StatusOK, gin.H{"user": user, "value": value})
} else {
@ -50,7 +50,7 @@ func setupRouter() *gin.Engine {
}
if c.Bind(&json) == nil {
DB[user] = json.Value
db[user] = json.Value
c.JSON(http.StatusOK, gin.H{"status": "ok"})
}
})

View File

@ -10,6 +10,7 @@ import (
"gopkg.in/go-playground/validator.v8"
)
// Booking contains binded and validated data.
type Booking struct {
CheckIn time.Time `form:"check_in" binding:"required,bookabledate" time_format:"2006-01-02"`
CheckOut time.Time `form:"check_out" binding:"required,gtfield=CheckIn" time_format:"2006-01-02"`

View File

@ -13,16 +13,19 @@ func main() {
StartGin()
}
// ConfigRuntime sets the number of operating system threads.
func ConfigRuntime() {
nuCPU := runtime.NumCPU()
runtime.GOMAXPROCS(nuCPU)
fmt.Printf("Running with %d CPUs\n", nuCPU)
}
// StartWrokers start starsWorker by goroutine.
func StartWorkers() {
go statsWorker()
}
// StartGin starts gin web server with setting router.
func StartGin() {
gin.SetMode(gin.ReleaseMode)

View File

@ -50,6 +50,7 @@ func connectedUsers() uint64 {
return uint64(connected)
}
// Stats returns savedStats data.
func Stats() map[string]uint64 {
mutexStats.RLock()
defer mutexStats.RUnlock()