feat(deps): update golangci-lint to v2
This commit was merged in pull request #55.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
FROM golang:1.24.2@sha256:30baaea08c5d1e858329c50f29fe381e9b7d7bced11a0f5f1f69a1504cdfbf5e AS builder_go
|
||||
WORKDIR /spend-sparrow
|
||||
RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||
RUN go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
|
||||
RUN go install github.com/a-h/templ/cmd/templ@latest
|
||||
RUN go install github.com/vektra/mockery/v2@latest
|
||||
COPY go.mod go.sum ./
|
||||
|
||||
@@ -16,7 +16,10 @@ func setupDb(t *testing.T) *sqlx.DB {
|
||||
t.Fatalf("Error opening database: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
db.Close()
|
||||
err := db.Close()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
})
|
||||
|
||||
err = RunMigrations(db, "../")
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotFound = errors.New("The value does not exist.")
|
||||
ErrNotFound = errors.New("the value does not exist")
|
||||
ErrAlreadyExists = errors.New("row already exists")
|
||||
)
|
||||
|
||||
|
||||
@@ -7,14 +7,10 @@ import (
|
||||
|
||||
func CacheControl(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
path := r.URL.Path
|
||||
|
||||
cached := false
|
||||
if strings.HasPrefix(path, "/static") {
|
||||
cached = true
|
||||
}
|
||||
shouldCache := strings.HasPrefix(r.URL.Path, "/static")
|
||||
|
||||
if !cached {
|
||||
if !shouldCache {
|
||||
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||
}
|
||||
|
||||
|
||||
@@ -20,17 +20,17 @@ var (
|
||||
)
|
||||
|
||||
func Fatal(message string, args ...interface{}) {
|
||||
errorMetric.Inc()
|
||||
|
||||
s := format(message, args)
|
||||
log.Fatal(s)
|
||||
|
||||
errorMetric.Inc()
|
||||
}
|
||||
|
||||
func Error(message string, args ...interface{}) {
|
||||
errorMetric.Inc()
|
||||
|
||||
s := format(message, args)
|
||||
slog.Error(s)
|
||||
|
||||
errorMetric.Inc()
|
||||
}
|
||||
|
||||
func Warn(message string, args ...interface{}) {
|
||||
|
||||
5
main.go
5
main.go
@@ -32,7 +32,10 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal("Could not open Database data.db: %v", err)
|
||||
}
|
||||
defer db.Close()
|
||||
defer func() {
|
||||
err := db.Close()
|
||||
log.Fatal("Could not close Database data.db: %v", err)
|
||||
}()
|
||||
|
||||
run(context.Background(), db, os.Getenv)
|
||||
}
|
||||
|
||||
26
main_test.go
26
main_test.go
@@ -1634,7 +1634,10 @@ func setupIntegrationTest(t *testing.T) (db *sqlx.DB, basePath string, ctx conte
|
||||
t.Fatalf("Could not open Database data.db: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
db.Close()
|
||||
err := db.Close()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
})
|
||||
|
||||
testPort := port.Add(1)
|
||||
@@ -1652,17 +1655,18 @@ func setupIntegrationTest(t *testing.T) (db *sqlx.DB, basePath string, ctx conte
|
||||
|
||||
func getEnv(port int32) func(string) string {
|
||||
return func(key string) string {
|
||||
if key == "PORT" {
|
||||
switch key {
|
||||
case "PORT":
|
||||
return fmt.Sprint(port)
|
||||
} else if key == "SMTP_ENABLED" {
|
||||
case "SMTP_ENABLED":
|
||||
return "false"
|
||||
} else if key == "PROMETHEUS_ENABLED" {
|
||||
case "PROMETHEUS_ENABLED":
|
||||
return "false"
|
||||
} else if key == "BASE_URL" {
|
||||
case "BASE_URL":
|
||||
return "http://localhost:" + fmt.Sprint(port)
|
||||
} else if key == "ENVIRONMENT" {
|
||||
case "ENVIRONMENT":
|
||||
return "test"
|
||||
} else {
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
@@ -1685,10 +1689,12 @@ func waitForReady(
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err == nil && resp.StatusCode == http.StatusOK {
|
||||
resp.Body.Close()
|
||||
return nil
|
||||
return resp.Body.Close()
|
||||
} else if err == nil {
|
||||
resp.Body.Close()
|
||||
err := resp.Body.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
select {
|
||||
|
||||
@@ -149,9 +149,9 @@ func (service AccountImpl) Delete(user *types.User, id uuid.UUID) error {
|
||||
|
||||
func (service AccountImpl) validateAccount(name string) error {
|
||||
if name == "" {
|
||||
return errors.New("Please enter a value for the \"name\" field.")
|
||||
return errors.New("please enter a value for the \"name\" field")
|
||||
} else if !safeInputRegex.MatchString(name) {
|
||||
return errors.New("Please use only letters, dashes or numbers for \"name\".")
|
||||
return errors.New("please use only letters, dashes or numbers for \"name\"")
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
|
||||
var (
|
||||
ErrInvalidCredentials = errors.New("invalid email or password")
|
||||
ErrInvalidPassword = errors.New("The password needs to be 8 characters long, contain at least one number, one special, one uppercase and one lowercase character")
|
||||
ErrInvalidPassword = errors.New("the password needs to be 8 characters long, contain at least one number, one special, one uppercase and one lowercase character")
|
||||
ErrInvalidEmail = errors.New("invalid email")
|
||||
ErrAccountExists = errors.New("account already exists")
|
||||
ErrSessionIdInvalid = errors.New("session ID is invalid")
|
||||
|
||||
@@ -6,5 +6,5 @@ import (
|
||||
|
||||
var (
|
||||
ErrInternal = errors.New("internal server error")
|
||||
ErrUnauthorized = errors.New("You are not authorized to perform this action.")
|
||||
ErrUnauthorized = errors.New("you are not authorized to perform this action")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user