refactor: upgrade to Go 1.26 and modernize code idioms
- Replace `interface{}` with `any` type alias across all packages
- Use built-in `min()`/`max()` for parameter clamping
- Use `slices.SortFunc`, `slices.Min`, `slices.Max` for cleaner code
- Use `strings.Cut()` for simpler string parsing in auth middleware
- Use `errors.Is()` for proper error comparison in handlers
- Update dependencies: golang.org/x/image 0.37.0 -> 0.38.0
- Add Wire code generation guidelines to ARCHITECTURE.md
- Disable Go cache in CI build workflow
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -81,11 +82,11 @@ func (h *StickerHandler) AddSticker(c *gin.Context) {
|
||||
|
||||
sticker, err := h.stickerService.AddSticker(userID, req.URL, req.Width, req.Height)
|
||||
if err != nil {
|
||||
if err == service.ErrStickerAlreadyExists {
|
||||
if errors.Is(err, service.ErrStickerAlreadyExists) {
|
||||
response.Error(c, http.StatusConflict, "sticker already exists")
|
||||
return
|
||||
}
|
||||
if err == service.ErrInvalidStickerURL {
|
||||
if errors.Is(err, service.ErrInvalidStickerURL) {
|
||||
response.BadRequest(c, "invalid sticker url, only http/https is allowed")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user