From 852c4cc11a191c5da1f1f5fb41ee8a981c707e56 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Thu, 12 Dec 2024 10:45:34 +0300 Subject: [PATCH] chore: migraet to standard layout See: https://github.com/golang-standards/project-layout --- main.go => cmd/aides-repo-api/main.go | 9 +++++---- go.mod | 11 ++++++----- {models => internal/models}/models.go | 0 {router => internal/router}/router.go | 3 ++- 4 files changed, 13 insertions(+), 10 deletions(-) rename main.go => cmd/aides-repo-api/main.go (78%) rename {models => internal/models}/models.go (100%) rename {router => internal/router}/router.go (97%) diff --git a/main.go b/cmd/aides-repo-api/main.go similarity index 78% rename from main.go rename to cmd/aides-repo-api/main.go index 3ca8355..94f63f5 100644 --- a/main.go +++ b/cmd/aides-repo-api/main.go @@ -1,11 +1,13 @@ package main import ( - "github.com/caarlos0/env/v11" "log" "net/http" - "rest_api/models" - "rest_api/router" + + "code.alt-gnome.ru/aides-infra/aides-repo-api/internal/models" + "code.alt-gnome.ru/aides-infra/aides-repo-api/internal/router" + + "github.com/caarlos0/env/v11" ) func main() { @@ -18,5 +20,4 @@ func main() { log.Printf("Сервер запущен на порту: %s", config.Port) http.ListenAndServe(":"+config.Port, router) - } diff --git a/go.mod b/go.mod index e31edba..fc13160 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,11 @@ -module rest_api +module code.alt-gnome.ru/aides-infra/aides-repo-api go 1.23.3 require ( - github.com/ajg/form v1.5.1 // indirect - github.com/caarlos0/env/v11 v11.2.2 // indirect - github.com/go-chi/chi/v5 v5.1.0 // indirect - github.com/go-chi/render v1.0.3 // indirect + github.com/caarlos0/env/v11 v11.2.2 + github.com/go-chi/chi/v5 v5.1.0 + github.com/go-chi/render v1.0.3 ) + +require github.com/ajg/form v1.5.1 // indirect diff --git a/models/models.go b/internal/models/models.go similarity index 100% rename from models/models.go rename to internal/models/models.go diff --git a/router/router.go b/internal/router/router.go similarity index 97% rename from router/router.go rename to internal/router/router.go index 9068e86..42c5c1c 100644 --- a/router/router.go +++ b/internal/router/router.go @@ -7,9 +7,10 @@ import ( "net/http" "os" "path" - "rest_api/models" // Импорт пакета с моделями, где определены структуры конфигурации "strconv" + "code.alt-gnome.ru/aides-infra/aides-repo-api/internal/models" + "github.com/go-chi/render" "github.com/go-chi/chi/v5" //Импорт пакета chi для маршрутизации -- 2.45.2