Skip to content

Commit

Permalink
style: golint (casdoor#988)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirname authored Aug 9, 2022
1 parent 4dd67a8 commit 7911976
Show file tree
Hide file tree
Showing 60 changed files with 237 additions and 164 deletions.
4 changes: 2 additions & 2 deletions captcha/aliyun.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"sort"
Expand Down Expand Up @@ -80,7 +80,7 @@ func (captcha *AliyunCaptchaProvider) VerifyCaptcha(token, clientSecret string)
}

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return false, err
}
Expand Down
4 changes: 2 additions & 2 deletions captcha/geetest.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"time"
Expand Down Expand Up @@ -58,7 +58,7 @@ func (captcha *GEETESTCaptchaProvider) VerifyCaptcha(token, clientSecret string)
}

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return false, err
}
Expand Down
4 changes: 2 additions & 2 deletions captcha/hcaptcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package captcha
import (
"encoding/json"
"errors"
"io/ioutil"
"io"
"net/http"
"net/url"
"strings"
Expand All @@ -43,7 +43,7 @@ func (captcha *HCaptchaProvider) VerifyCaptcha(token, clientSecret string) (bool
}

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return false, err
}
Expand Down
4 changes: 2 additions & 2 deletions captcha/recaptcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package captcha
import (
"encoding/json"
"errors"
"io/ioutil"
"io"
"net/http"
"net/url"
"strings"
Expand All @@ -43,7 +43,7 @@ func (captcha *ReCaptchaProvider) VerifyCaptcha(token, clientSecret string) (boo
}

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return false, err
}
Expand Down
1 change: 1 addition & 0 deletions controllers/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ func (c *ApiController) GetAccount() {
c.ServeJSON()
}

// GetUserinfo
// UserInfo
// @Title UserInfo
// @Tag Account API
Expand Down
2 changes: 1 addition & 1 deletion controllers/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (c *ApiController) HandleLoggedIn(application *object.Application, user *ob
}

} else {
resp = wrapErrorResponse(fmt.Errorf("Unknown response type: %s", form.Type))
resp = wrapErrorResponse(fmt.Errorf("unknown response type: %s", form.Type))
}

// if user did not check auto signin
Expand Down
2 changes: 2 additions & 0 deletions controllers/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ import (
"github.com/casdoor/casdoor/util"
)

// ApiController
// controller for handlers under /api uri
type ApiController struct {
beego.Controller
}

// RootController
// controller for handlers directly under / (root)
type RootController struct {
ApiController
Expand Down
16 changes: 8 additions & 8 deletions controllers/cas.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
InvalidProxyCallback string = "INVALID_PROXY_CALLBACK"
InvalidTicket string = "INVALID_TICKET"
InvalidService string = "INVALID_SERVICE"
InteralError string = "INTERNAL_ERROR"
InternalError string = "INTERNAL_ERROR"
UnauthorizedService string = "UNAUTHORIZED_SERVICE"
)

Expand Down Expand Up @@ -116,7 +116,7 @@ func (c *RootController) CasP3ServiceAndProxyValidate() {
}
// make a request to pgturl passing pgt and pgtiou
if err != nil {
c.sendCasAuthenticationResponseErr(InteralError, err.Error(), format)
c.sendCasAuthenticationResponseErr(InternalError, err.Error(), format)
return
}
param := pgtUrlObj.Query()
Expand All @@ -126,7 +126,7 @@ func (c *RootController) CasP3ServiceAndProxyValidate() {

request, err := http.NewRequest("GET", pgtUrlObj.String(), nil)
if err != nil {
c.sendCasAuthenticationResponseErr(InteralError, err.Error(), format)
c.sendCasAuthenticationResponseErr(InternalError, err.Error(), format)
return
}

Expand Down Expand Up @@ -214,23 +214,23 @@ func (c *RootController) SamlValidate() {
return
}

envelopReponse := struct {
envelopResponse := struct {
XMLName xml.Name `xml:"SOAP-ENV:Envelope"`
Xmlns string `xml:"xmlns:SOAP-ENV"`
Body struct {
XMLName xml.Name `xml:"SOAP-ENV:Body"`
Content string `xml:",innerxml"`
}
}{}
envelopReponse.Xmlns = "http://schemas.xmlsoap.org/soap/envelope/"
envelopReponse.Body.Content = response
envelopResponse.Xmlns = "http://schemas.xmlsoap.org/soap/envelope/"
envelopResponse.Body.Content = response

data, err := xml.Marshal(envelopReponse)
data, err := xml.Marshal(envelopResponse)
if err != nil {
c.ResponseError(err.Error())
return
}
c.Ctx.Output.Body([]byte(data))
c.Ctx.Output.Body(data)
}

func (c *RootController) sendCasProxyResponseErr(code, msg, format string) {
Expand Down
4 changes: 4 additions & 0 deletions controllers/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (c *ApiController) GetCerts() {
}
}

// GetCert
// @Title GetCert
// @Tag Cert API
// @Description get cert
Expand All @@ -61,6 +62,7 @@ func (c *ApiController) GetCert() {
c.ServeJSON()
}

// UpdateCert
// @Title UpdateCert
// @Tag Cert API
// @Description update cert
Expand All @@ -81,6 +83,7 @@ func (c *ApiController) UpdateCert() {
c.ServeJSON()
}

// AddCert
// @Title AddCert
// @Tag Cert API
// @Description add cert
Expand All @@ -98,6 +101,7 @@ func (c *ApiController) AddCert() {
c.ServeJSON()
}

// DeleteCert
// @Title DeleteCert
// @Tag Cert API
// @Description delete cert
Expand Down
8 changes: 8 additions & 0 deletions controllers/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type LdapSyncResp struct {
Failed []object.LdapRespUser `json:"failed"`
}

// GetLdapUser
// @Tag Account API
// @Title GetLdapser
// @router /get-ldap-user [post]
Expand Down Expand Up @@ -100,6 +101,7 @@ func (c *ApiController) GetLdapUser() {
c.ServeJSON()
}

// GetLdaps
// @Tag Account API
// @Title GetLdaps
// @router /get-ldaps [post]
Expand All @@ -110,6 +112,7 @@ func (c *ApiController) GetLdaps() {
c.ServeJSON()
}

// GetLdap
// @Tag Account API
// @Title GetLdap
// @router /get-ldap [post]
Expand All @@ -125,6 +128,7 @@ func (c *ApiController) GetLdap() {
c.ServeJSON()
}

// AddLdap
// @Tag Account API
// @Title AddLdap
// @router /add-ldap [post]
Expand Down Expand Up @@ -159,6 +163,7 @@ func (c *ApiController) AddLdap() {
c.ServeJSON()
}

// UpdateLdap
// @Tag Account API
// @Title UpdateLdap
// @router /update-ldap [post]
Expand Down Expand Up @@ -186,6 +191,7 @@ func (c *ApiController) UpdateLdap() {
c.ServeJSON()
}

// DeleteLdap
// @Tag Account API
// @Title DeleteLdap
// @router /delete-ldap [post]
Expand All @@ -201,6 +207,7 @@ func (c *ApiController) DeleteLdap() {
c.ServeJSON()
}

// SyncLdapUsers
// @Tag Account API
// @Title SyncLdapUsers
// @router /sync-ldap-users [post]
Expand All @@ -223,6 +230,7 @@ func (c *ApiController) SyncLdapUsers() {
c.ServeJSON()
}

// CheckLdapUsersExist
// @Tag Account API
// @Title CheckLdapUserExist
// @router /check-ldap-users-exist [post]
Expand Down
2 changes: 2 additions & 0 deletions controllers/oidc_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package controllers

import "github.com/casdoor/casdoor/object"

// GetOidcDiscovery
// @Title GetOidcDiscovery
// @Tag OIDC API
// @Description Get Oidc Discovery
Expand All @@ -27,6 +28,7 @@ func (c *RootController) GetOidcDiscovery() {
c.ServeJSON()
}

// GetJwks
// @Title GetJwks
// @Tag OIDC API
// @Success 200 {object} jose.JSONWebKey
Expand Down
6 changes: 6 additions & 0 deletions controllers/payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func (c *ApiController) GetUserPayments() {
c.ResponseOk(payments)
}

// GetPayment
// @Title GetPayment
// @Tag Payment API
// @Description get payment
Expand All @@ -80,6 +81,7 @@ func (c *ApiController) GetPayment() {
c.ServeJSON()
}

// UpdatePayment
// @Title UpdatePayment
// @Tag Payment API
// @Description update payment
Expand All @@ -100,6 +102,7 @@ func (c *ApiController) UpdatePayment() {
c.ServeJSON()
}

// AddPayment
// @Title AddPayment
// @Tag Payment API
// @Description add payment
Expand All @@ -117,6 +120,7 @@ func (c *ApiController) AddPayment() {
c.ServeJSON()
}

// DeletePayment
// @Title DeletePayment
// @Tag Payment API
// @Description delete payment
Expand All @@ -134,6 +138,7 @@ func (c *ApiController) DeletePayment() {
c.ServeJSON()
}

// NotifyPayment
// @Title NotifyPayment
// @Tag Payment API
// @Description notify payment
Expand All @@ -159,6 +164,7 @@ func (c *ApiController) NotifyPayment() {
}
}

// InvoicePayment
// @Title InvoicePayment
// @Tag Payment API
// @Description invoice payment
Expand Down
4 changes: 4 additions & 0 deletions controllers/permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (c *ApiController) GetPermissions() {
}
}

// GetPermission
// @Title GetPermission
// @Tag Permission API
// @Description get permission
Expand All @@ -61,6 +62,7 @@ func (c *ApiController) GetPermission() {
c.ServeJSON()
}

// UpdatePermission
// @Title UpdatePermission
// @Tag Permission API
// @Description update permission
Expand All @@ -81,6 +83,7 @@ func (c *ApiController) UpdatePermission() {
c.ServeJSON()
}

// AddPermission
// @Title AddPermission
// @Tag Permission API
// @Description add permission
Expand All @@ -98,6 +101,7 @@ func (c *ApiController) AddPermission() {
c.ServeJSON()
}

// DeletePermission
// @Title DeletePermission
// @Tag Permission API
// @Description delete permission
Expand Down
5 changes: 5 additions & 0 deletions controllers/product.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (c *ApiController) GetProducts() {
}
}

// GetProduct
// @Title GetProduct
// @Tag Product API
// @Description get product
Expand All @@ -65,6 +66,7 @@ func (c *ApiController) GetProduct() {
c.ServeJSON()
}

// UpdateProduct
// @Title UpdateProduct
// @Tag Product API
// @Description update product
Expand All @@ -85,6 +87,7 @@ func (c *ApiController) UpdateProduct() {
c.ServeJSON()
}

// AddProduct
// @Title AddProduct
// @Tag Product API
// @Description add product
Expand All @@ -102,6 +105,7 @@ func (c *ApiController) AddProduct() {
c.ServeJSON()
}

// DeleteProduct
// @Title DeleteProduct
// @Tag Product API
// @Description delete product
Expand All @@ -119,6 +123,7 @@ func (c *ApiController) DeleteProduct() {
c.ServeJSON()
}

// BuyProduct
// @Title BuyProduct
// @Tag Product API
// @Description buy product
Expand Down
Loading

0 comments on commit 7911976

Please sign in to comment.