css

文字框CSS

導覽列JS

html img

<img src="smiley.gif" alt="Smiley face" height="42" width="42">

<a href="連結前往的網址"><img src="圖片網址" border="0"></a>

參考

Go Time

var startTime time.Time
startTime, err = time.Parse("2006-01-02 15:04:05", "2019-03-07 10:14:35")

startTimeStr := startTime.Format("2006-01-02 15:04:05")

Gin-swagger

建立文檔網站用套件。搭配gin。
get


import



生成文檔用的套件
get swagger cmd


建立文檔,需在main.go路徑執行。


import (
_ "chatservice/docs" // 加這行才能在網頁顯示文檔

    "github.com/gin-gonic/gin"
    ginSwagger "github.com/swaggo/gin-swagger"
    "github.com/swaggo/gin-swagger/swaggerFiles"
)

// @Title blogger
// @Version 1.0.0
// @Description blog example
// @Host localhost:1234
// @BasePath /api
func main() {
    router := gin.Default()
router.POST("/api/post/test", Test)
    router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
    router.Run("localhost:1234")
}

// Test for demo
// @Summary test method
// @Description test for test
// @Tags test tag
// @Accept application/x-www-form-urlencoded

// @Produce json
// @Param Param1 formData string true "string parameter" default(stringValue)

// @Success 200 {string} string "成功"
// @Failure 500 {string} string "内部错误"
// @Router /post/test [post]
func Test(c *gin.Context) {
    p1String := c.PostForm("Param1")

生成的yaml檔
basePath: /api
host: localhost:1234
info:
contact: {}
description: blog example
license: {}
title: blogger
version: 1.0.0
paths:
/post/test:
post:
consumes:
- application/x-www-form-urlencoded
description: test for test
parameters:
- default: stringValue
description: string parameter
in: formData
name: Param1
required: true
type: string
produces:
- application/json
responses:
"200":
description: 成功
schema:
type: string
"500":
description: 内部错误
schema:
type: string
summary: test method
tags:
- test tag
swagger: "2.0"


在啟動程式後,透過網址開啟文檔。
http://localhost:1234/swagger/index.html

註解文檔

gin-swagger連結

Mysql連線字串

account:password@tcp(localhost:3306)/dbname?charset=utf8&parseTime=true

Mysql資料型態

  • 大于varchar(255)变为 tinytext
  • 大于varchar(500)变为 text
  • 大于varchar(20000)变为 mediumtext