This commit is contained in:
vipg
2026-02-10 10:19:43 +08:00
parent 32584e25b2
commit 25e566450e
2 changed files with 5 additions and 8 deletions

View File

@@ -1,5 +1,3 @@
# syntax=docker/dockerfile:1
FROM golang:1.25.7-alpine3.23 AS builder FROM golang:1.25.7-alpine3.23 AS builder
WORKDIR /workspace WORKDIR /workspace
RUN apk add --no-cache git RUN apk add --no-cache git

View File

@@ -1,11 +1,10 @@
package service package service
import ( import (
"database/sql"
"errors" "errors"
"strings"
"common/auth" "common/auth"
"github.com/jackc/pgconn"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
"user/internal/repository" "user/internal/repository"
) )
@@ -93,9 +92,9 @@ func validPassword(p string) bool {
} }
func isUniqueViolation(err error) bool { func isUniqueViolation(err error) bool {
var pe *pgconn.PgError if err == nil {
if errors.As(err, &pe) { return false
return pe.Code == "23505"
} }
return false s := err.Error()
return strings.Contains(s, "duplicate key") || strings.Contains(s, "unique constraint") || strings.Contains(s, "23505")
} }