diff --git a/handler/admin/application_password.go b/handler/admin/application_password.go index ab5c2d96..0b186dc5 100644 --- a/handler/admin/application_password.go +++ b/handler/admin/application_password.go @@ -2,6 +2,7 @@ package admin import ( "errors" + "github.com/gin-gonic/gin" "github.com/go-playground/validator/v10" "github.com/go-sonic/sonic/handler/trans" diff --git a/handler/content/wp/post.go b/handler/content/wp/post.go index e2027ce6..90024005 100644 --- a/handler/content/wp/post.go +++ b/handler/content/wp/post.go @@ -116,11 +116,10 @@ func parsePostParam(ctx *gin.Context) (*param.Post, error) { log.CtxInfo(ctx, "wpPost: "+string(bytes)) return convertToPostParam(&wpPost) - } func convertToPostParam(wpPost *param.WpPost) (*param.Post, error) { - var paramPostStatus = sonicconst.PostStatusPublished + paramPostStatus := sonicconst.PostStatusPublished if strings.ToLower(wpPost.Status) == "draft" { paramPostStatus = sonicconst.PostStatusDraft } @@ -168,9 +167,9 @@ func convertToPostParam(wpPost *param.WpPost) (*param.Post, error) { func convertToWpPost(postEntity *entity.Post) *wp.PostDTO { timeFormat := time.RFC3339 - var wpStatus = "publish" - var wpCommentStatus = "open" - var wpContent = make(map[string]interface{}) + wpStatus := "publish" + wpCommentStatus := "open" + wpContent := make(map[string]interface{}) if postEntity.Status == sonicconst.PostStatusDraft { wpStatus = "draft" @@ -183,7 +182,7 @@ func convertToWpPost(postEntity *entity.Post) *wp.PostDTO { wpContent["rendered"] = postEntity.OriginalContent wpContent["protected"] = false - var postDTO = &wp.PostDTO{ + postDTO := &wp.PostDTO{ Date: postEntity.CreateTime.Format(timeFormat), DateGmt: postEntity.CreateTime.UTC().Format(timeFormat), GUID: nil, diff --git a/handler/content/wp/tag.go b/handler/content/wp/tag.go index 3de6fd58..e81ed507 100644 --- a/handler/content/wp/tag.go +++ b/handler/content/wp/tag.go @@ -1,13 +1,14 @@ package wp import ( + "strings" + "github.com/gin-gonic/gin" "github.com/go-sonic/sonic/model/dto/wp" "github.com/go-sonic/sonic/model/entity" "github.com/go-sonic/sonic/model/param" "github.com/go-sonic/sonic/service" "github.com/go-sonic/sonic/util/xerr" - "strings" ) type TagHandler struct { diff --git a/handler/middleware/application_password.go b/handler/middleware/application_password.go index c8e504f3..0ef3c190 100644 --- a/handler/middleware/application_password.go +++ b/handler/middleware/application_password.go @@ -14,9 +14,7 @@ import ( "github.com/go-sonic/sonic/service" ) -var ( - basicAuthRegexp = regexp.MustCompile(`^Basic [a-z\\d/+]*={0,2}`) -) +var basicAuthRegexp = regexp.MustCompile(`^Basic [a-z\\d/+]*={0,2}`) type ApplicationPasswordMiddleware struct { PasswordService service.ApplicationPasswordService diff --git a/service/application_password.go b/service/application_password.go index 57346043..aec45f64 100644 --- a/service/application_password.go +++ b/service/application_password.go @@ -2,6 +2,7 @@ package service import ( "context" + "github.com/go-sonic/sonic/model/dto" "github.com/go-sonic/sonic/model/entity" "github.com/go-sonic/sonic/model/param" diff --git a/service/impl/application_password.go b/service/impl/application_password.go index 0d206c1b..8572c4ed 100644 --- a/service/impl/application_password.go +++ b/service/impl/application_password.go @@ -149,7 +149,6 @@ func (a *applicationPasswordServiceImpl) Update(ctx context.Context, entityID in LastActivateIP: ip, LastActivateTime: &now, }) - if err != nil { return WrapDBErr(err) }