<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                > swagger可以很好的為Api提供文檔,并且加強代碼的注釋能力 [TOC] ## 安裝 swag ~~~ go get -u github.com/swaggo/swag/cmd/swag ~~~ > 若 `$GOROOT/bin` 沒有加入`$PATH`中,你需要執行將其可執行文件移動到`$GOBIN`下 ~~~ swag -v # 安裝成功返回 swag version v1.7.0 ~~~ ## 編寫swagger注解 ~~~ package main import ( _ "ginw/docs" "github.com/gin-gonic/gin" "github.com/swaggo/gin-swagger" "github.com/swaggo/gin-swagger/swaggerFiles" "net/http" ) // @Summary 打印測試功能 // @title Swagger Example API // @version 0.0.1 // @description This is a sample server Petstore server. // @BasePath /api/v1 // @Host 127.0.0.1:8080 // @Produce json // @Param name query string true "Name" // @Success 200 {string} json "{"code":200,"data":"name","msg":"ok"}" // @Router /api/v1/haha [get] func Print(context *gin.Context) { var ( name string ) name = context.Query("name") context.JSON(http.StatusOK, gin.H{ "code": http.StatusOK, "msg": "success", "data": name, }) } func main() { var ( route *gin.Engine v1 *gin.RouterGroup ) route = gin.Default() route.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) //gin.SetMode(gin.ReleaseMode) v1 = route.Group("/api/v1") { v1.GET("haha", Print) } route.Run() } ~~~ ## 生成注解文檔 > 在項目根目錄中執行 ~~~ swag init ~~~ > 訪問 http://localhost:8080/swagger/index.html **參考文獻** > https://www.bbsmax.com/A/lk5amD4451/ > https://blog.csdn.net/eddycjy/article/details/106740800
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看