Skip to content

Commit

Permalink
fix go lint error (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
pei0804 authored and easonlin404 committed Mar 21, 2019
1 parent 622e072 commit 889705a
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 3 deletions.
1 change: 0 additions & 1 deletion .golint_exclude

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GOGET:=$(GOCMD) get
GOLIST:=$(GOCMD) list

BINARY_NAME:=swag
PACKAGES:=$(shell $(GOLIST) ./... | grep -v /example)
PACKAGES:=$(shell $(GOLIST) ./...)
GOFILES:=$(shell find . -name "*.go" -type f)

all: test build
Expand Down
5 changes: 5 additions & 0 deletions example/basic/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/gin-gonic/gin"
)

// GetStringByInt example
// @Summary Add a new pet to the store
// @Description get string by ID
// @ID get-string-by-int
Expand All @@ -19,6 +20,7 @@ func GetStringByInt(c *gin.Context) {
//write your code
}

// GetStructArrayByString example
// @Description get struct array by ID
// @ID get-struct-array-by-string
// @Accept json
Expand All @@ -34,6 +36,7 @@ func GetStructArrayByString(c *gin.Context) {
//write your code
}

// Upload example
// @Summary Upload file
// @Description Upload file
// @ID file.upload
Expand All @@ -48,12 +51,14 @@ func Upload(ctx *gin.Context) {
//write your code
}

// AnonymousField example
// @Summary use Anonymous field
// @Success 200 {object} web.RevValue "ok"
func AnonymousField() {

}

// Pet3 example
type Pet3 struct {
ID int `json:"id"`
}
7 changes: 7 additions & 0 deletions example/basic/web/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"time"
)

// Pet example
type Pet struct {
ID int `json:"id"`
Category struct {
Expand All @@ -16,26 +17,32 @@ type Pet struct {
Status string `json:"status"`
}

// Tag example
type Tag struct {
ID int `json:"id"`
Name string `json:"name"`
}

// Pet2 example
type Pet2 struct {
ID int `json:"id"`
}

// APIError example
type APIError struct {
ErrorCode int
ErrorMessage string
CreatedAt time.Time
}

// RevValueBase example
type RevValueBase struct {
Status bool `json:"Status"`

Err int32 `json:"Err"`
}

// RevValue example
type RevValue struct {
RevValueBase

Expand Down
3 changes: 3 additions & 0 deletions example/celler/controller/controller.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package controller

// Controller example
type Controller struct {
}

// NewController example
func NewController() *Controller {
return &Controller{}
}

// Message example
type Message struct {
Message string `json:"message" example:"message"`
}
2 changes: 2 additions & 0 deletions example/celler/httputil/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package httputil

import "github.com/gin-gonic/gin"

// NewError example
func NewError(ctx *gin.Context, status int, err error) {
er := HTTPError{
Code: status,
Expand All @@ -10,6 +11,7 @@ func NewError(ctx *gin.Context, status int, err error) {
ctx.JSON(status, er)
}

// HTTPError example
type HTTPError struct {
Code int `json:"code" example:"400"`
Message string `json:"message" example:"status bad request"`
Expand Down
13 changes: 12 additions & 1 deletion example/celler/model/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@ import (
"errors"
"fmt"

"github.com/satori/go.uuid"
uuid "github.com/satori/go.uuid"
)

// Account example
type Account struct {
ID int `json:"id" example:"1" format:"int64"`
Name string `json:"name" example:"account name"`
UUID uuid.UUID `json:"uuid" example:"550e8400-e29b-41d4-a716-446655440000" format:"uuid"`
}

// example
var (
ErrNameInvalid = errors.New("name is empty")
)

// AddAccount example
type AddAccount struct {
Name string `json:"name" example:"account name"`
}

// Validation example
func (a AddAccount) Validation() error {
switch {
case len(a.Name) == 0:
Expand All @@ -30,10 +34,12 @@ func (a AddAccount) Validation() error {
}
}

// UpdateAccount example
type UpdateAccount struct {
Name string `json:"name" example:"account name"`
}

// Validation example
func (a UpdateAccount) Validation() error {
switch {
case len(a.Name) == 0:
Expand All @@ -43,6 +49,7 @@ func (a UpdateAccount) Validation() error {
}
}

// AccountsAll example
func AccountsAll(q string) ([]Account, error) {
if q == "" {
return accounts, nil
Expand All @@ -56,6 +63,7 @@ func AccountsAll(q string) ([]Account, error) {
return as, nil
}

// AccountOne example
func AccountOne(id int) (Account, error) {
for _, v := range accounts {
if id == v.ID {
Expand All @@ -65,6 +73,7 @@ func AccountOne(id int) (Account, error) {
return Account{}, ErrNoRow
}

// Insert example
func (a Account) Insert() (int, error) {
accountMaxID++
a.ID = accountMaxID
Expand All @@ -73,6 +82,7 @@ func (a Account) Insert() (int, error) {
return accountMaxID, nil
}

// Delete example
func Delete(id int) error {
for k, v := range accounts {
if id == v.ID {
Expand All @@ -83,6 +93,7 @@ func Delete(id int) error {
return fmt.Errorf("account id=%d is not found", id)
}

// Update example
func (a Account) Update() error {
for k, v := range accounts {
if a.ID == v.ID {
Expand Down
1 change: 1 addition & 0 deletions example/celler/model/admin.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package model

// Admin example
type Admin struct {
ID int `json:"id" example:"1"`
Name string `json:"name" example:"admin name"`
Expand Down
3 changes: 3 additions & 0 deletions example/celler/model/bottle.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package model

// Bottle example
type Bottle struct {
ID int `json:"id" example:"1"`
Name string `json:"name" example:"bottle_name"`
Account Account `json:"account"`
}

// BottlesAll example
func BottlesAll() ([]Bottle, error) {
return bottles, nil
}

// BottleOne example
func BottleOne(id int) (*Bottle, error) {
for _, v := range bottles {
if id == v.ID {
Expand Down
1 change: 1 addition & 0 deletions example/celler/model/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package model
import "errors"

var (
// ErrNoRow example
ErrNoRow = errors.New("no rows in result set")
)

0 comments on commit 889705a

Please sign in to comment.