https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/hello.go main调用 package main import ( "fmt" "gopkg.in/gin-gonic/gin.v1" "github.com/jinzhu/gorm" "github.com/wangzitian0/golang-gin-starter-kit/…
https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/common/unit_test.go 单元测试 package users import ( "testing" "github.com/stretchr/testify/assert" "bytes" "fmt" "github.com/jinzhu/gorm&q…
https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/users/validators.go 验证器 package users import ( "github.com/gin-gonic/gin" "github.com/wangzitian0/golang-gin-starter-kit/common" ) // 模型验证器包括2个方面: 1. 使用规则验证输入的…
https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/users/middlewares.go 中间件定义 package users import ( "net/http" "strings" "github.com/dgrijalva/jwt-go/request" "github.com/gin-gonic/gin" &qu…
https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/users/routers.go 路由定义 package users import ( "errors" "net/http" "github.com/gin-gonic/gin" "github.com/wangzitian0/golang-gin-starter-kit/commo…
https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/users/serializers.go 序列化定义 package users import ( "gopkg.in/gin-gonic/gin.v1" "github.com/wangzitian0/golang-gin-starter-kit/common" ) // 用户简介序列化结构体 type Profi…
https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/users/models.go 模型定义 users/models.go package users import ( "errors" "github.com/jinzhu/gorm" "github.com/wangzitian0/golang-gin-starter-kit/common"…
https://wangzitian0.github.io/2013/06/29/zero-to-one-1/ https://github.com/gothinkster/golang-gin-realworld-example-app 目录结构 golang-gin-realworld-example-app/ ├── articles │   ├── doc.go │   ├── models.go │   ├── routers.go │   ├── serializers.go │  …
Golang Gin 项目包依赖管理 godep 使用 标签(空格分隔): Go 在按照github.com/tools/godep文档go get完包以后,调整项目结构为$GOPATH/src/$PROJECT_NAME/,同时使项目编译没有问题.执行godep save命令,出现了一系列包缺失的问题: github.com/campoy/embedmd github.com/client9/misspell/cmd/misspell github.com/dustin/go-broadcas…
Golang Gin 项目使用 Swagger 标签(空格分隔): Go 首先需要github.com/swaggo/gin-swagger和github.com/swaggo/gin-swagger/swaggerFiles(参见gin-swagger). 然后根据 github.com/swaggo/swag/cmd/swag文档获取到swag工具:执行swag init在项目根目录下生成docs文件夹.然后在路由中import _ "/docs".这时候编译程序,打开http:/…