From 6ef8eccbef4f6d49b8bba3e898a3a0293e1a2230 Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Fri, 15 Sep 2023 17:10:57 -0400 Subject: [PATCH] Refondre noms de package selon bonnes pratiques --- apiclient/apiclient.go | 2 ++ apihandler/apihandler.go | 2 ++ apiresponse/apiresponse.go | 2 ++ cmd/api.go | 2 +- cmd/root.go | 4 +--- cmd/web.go | 2 +- config/config.go | 6 +++++- data/data.go | 0 dbclient/dbclient.go | 2 ++ handlers/handlers.go | 0 main.go | 1 + models/models.go | 0 responses/responses.go | 0 templates/templates.go | 0 {templates => webcontent}/html/index.html | 0 webcontent/webcontent.go | 5 +++++ webhandler/webhandler.go | 2 ++ 17 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 apiclient/apiclient.go create mode 100644 apihandler/apihandler.go create mode 100644 apiresponse/apiresponse.go delete mode 100644 data/data.go create mode 100644 dbclient/dbclient.go delete mode 100644 handlers/handlers.go delete mode 100644 models/models.go delete mode 100644 responses/responses.go delete mode 100644 templates/templates.go rename {templates => webcontent}/html/index.html (100%) create mode 100644 webcontent/webcontent.go create mode 100644 webhandler/webhandler.go diff --git a/apiclient/apiclient.go b/apiclient/apiclient.go new file mode 100644 index 0000000..2a74a7e --- /dev/null +++ b/apiclient/apiclient.go @@ -0,0 +1,2 @@ +// Package apiclient provides the API client used by the web app +package apiclient diff --git a/apihandler/apihandler.go b/apihandler/apihandler.go new file mode 100644 index 0000000..f96f1fc --- /dev/null +++ b/apihandler/apihandler.go @@ -0,0 +1,2 @@ +// Package apihandler provides handlers for API routes +package apihandler diff --git a/apiresponse/apiresponse.go b/apiresponse/apiresponse.go new file mode 100644 index 0000000..5b2b319 --- /dev/null +++ b/apiresponse/apiresponse.go @@ -0,0 +1,2 @@ +// Package apiresponse provides response types for API routes +package apiresponse diff --git a/cmd/api.go b/cmd/api.go index d75979d..c305bf1 100644 --- a/cmd/api.go +++ b/cmd/api.go @@ -18,7 +18,7 @@ var apiCmd = &cobra.Command{ Use: "api", Short: "Start the API server", Run: func(cmd *cobra.Command, args []string) { - cfg, err := config.GetConfig() + cfg, err := config.UnmarshalConfig() if err != nil { log.Fatal(err) } diff --git a/cmd/root.go b/cmd/root.go index d73c696..478df63 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,6 +1,4 @@ -/* -Copyright © 2023 AGECEM & Victor Lacasse-Beaudoin -*/ +// Package cmd provides the cobra command and subcommands for the application package cmd import ( diff --git a/cmd/web.go b/cmd/web.go index 2a1fe01..08c1286 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -18,7 +18,7 @@ var webCmd = &cobra.Command{ Use: "web", Short: "Start the webserver", Run: func(cmd *cobra.Command, args []string) { - cfg, err := config.GetConfig() + cfg, err := config.UnmarshalConfig() if err != nil { log.Fatal(err) } diff --git a/config/config.go b/config/config.go index e7698ea..3e80868 100644 --- a/config/config.go +++ b/config/config.go @@ -1,3 +1,7 @@ +/* +Package config provides types and methods for managing this application's +config options and flags +*/ package config import ( @@ -18,7 +22,7 @@ type WebConfig struct { Port int } -func GetConfig() (cfg Config, err error) { +func UnmarshalConfig() (cfg Config, err error) { return cfg, viper.Unmarshal(&cfg) } diff --git a/data/data.go b/data/data.go deleted file mode 100644 index e69de29..0000000 diff --git a/dbclient/dbclient.go b/dbclient/dbclient.go new file mode 100644 index 0000000..61c4d69 --- /dev/null +++ b/dbclient/dbclient.go @@ -0,0 +1,2 @@ +// Package dbclient provides the database client used by the API server +package dbclient diff --git a/handlers/handlers.go b/handlers/handlers.go deleted file mode 100644 index e69de29..0000000 diff --git a/main.go b/main.go index e63f34c..e56c64d 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ /* Copyright © 2023 AGECEM & Victor Lacasse-Beaudoin +Application de registre de présences en Assemblée Générale de l'AGECEM */ package main diff --git a/models/models.go b/models/models.go deleted file mode 100644 index e69de29..0000000 diff --git a/responses/responses.go b/responses/responses.go deleted file mode 100644 index e69de29..0000000 diff --git a/templates/templates.go b/templates/templates.go deleted file mode 100644 index e69de29..0000000 diff --git a/templates/html/index.html b/webcontent/html/index.html similarity index 100% rename from templates/html/index.html rename to webcontent/html/index.html diff --git a/webcontent/webcontent.go b/webcontent/webcontent.go new file mode 100644 index 0000000..462e56d --- /dev/null +++ b/webcontent/webcontent.go @@ -0,0 +1,5 @@ +/* +Package webcontent provides the content to be embedded in the binary executable +for the web app +*/ +package webcontent diff --git a/webhandler/webhandler.go b/webhandler/webhandler.go new file mode 100644 index 0000000..56f4475 --- /dev/null +++ b/webhandler/webhandler.go @@ -0,0 +1,2 @@ +// Package webhandler provides handlers for the web app routes +package webhandler