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
WORKDIR /workspace
RUN apk add --no-cache git

View File

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