From a39a9a007c87338ce50646a995b4f8470548055c Mon Sep 17 00:00:00 2001 From: Timo Riegebauer Date: Wed, 23 Apr 2025 11:25:55 +0000 Subject: [PATCH] fixed error when migrating nothing --- Makefile | 5 ++++- app/app.go | 6 +++++- helper/token.go | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 0c300fa..5a050c1 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ -default: build run +default: clean run build: @CGO_ENABLED=0 GOOS=linux go build -o build/server main.go run: build @./build/server + +clean: + @rm -rf ./build \ No newline at end of file diff --git a/app/app.go b/app/app.go index 991d659..96468b3 100644 --- a/app/app.go +++ b/app/app.go @@ -41,7 +41,11 @@ func (a *App) Start() { log.Fatal(a.d.Start(listenAddr)) } -func (a *App) Migrate(dst ...interface{}) error { +func (a *App) Migrate(dst ...any) error { + if len(dst) == 0 { + return nil + } + db, err := a.d.DB() if err != nil { return err diff --git a/helper/token.go b/helper/token.go index ab1899e..6b9db39 100644 --- a/helper/token.go +++ b/helper/token.go @@ -48,7 +48,7 @@ func ValidateToken(tokenString string) (jwt.MapClaims, error) { return nil, errors.New("JWT_SECRET is not set") } - token, err := jwt.Parse(tokenString, func(t *jwt.Token) (interface{}, error) { + token, err := jwt.Parse(tokenString, func(t *jwt.Token) (any, error) { if _, ok := t.Method.(*jwt.SigningMethodHMAC); !ok { return nil, errors.New("unexpected signing method") }