From 16e5df26d6e23f51648a0cd05eb55ab2a6c67045 Mon Sep 17 00:00:00 2001 From: Drew Bednar Date: Sun, 23 Jun 2024 10:09:50 -0400 Subject: [PATCH] Refactor project to more conventional layout --- go-web-app/gowiki/Makefile | 5 +++++ go-web-app/gowiki/{wiki.go => cmd/gowiki/main.go} | 5 +++-- go-web-app/gowiki/{ => common}/common.go | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 go-web-app/gowiki/Makefile rename go-web-app/gowiki/{wiki.go => cmd/gowiki/main.go} (96%) rename go-web-app/gowiki/{ => common}/common.go (93%) diff --git a/go-web-app/gowiki/Makefile b/go-web-app/gowiki/Makefile new file mode 100644 index 0000000..2ff8074 --- /dev/null +++ b/go-web-app/gowiki/Makefile @@ -0,0 +1,5 @@ +build: + go build -o ./bin/gowiki ./cmd/gowiki/main.go + +clean: + rm -rf ./bin/gowiki \ No newline at end of file diff --git a/go-web-app/gowiki/wiki.go b/go-web-app/gowiki/cmd/gowiki/main.go similarity index 96% rename from go-web-app/gowiki/wiki.go rename to go-web-app/gowiki/cmd/gowiki/main.go index 5e89307..d5b8e19 100644 --- a/go-web-app/gowiki/wiki.go +++ b/go-web-app/gowiki/cmd/gowiki/main.go @@ -1,6 +1,7 @@ package main import ( + "gowiki/common" "log" "net/http" "os" @@ -8,8 +9,8 @@ import ( "text/template" ) -var template_dir string = GetDefaultEnv("GOWIKI_TEMPLATE_DIR", "./tmpl") -var data_dir string = GetDefaultEnv("GOWIKI_DATA_DIR", "./data") +var template_dir string = common.GetDefaultEnv("GOWIKI_TEMPLATE_DIR", "./tmpl") +var data_dir string = common.GetDefaultEnv("GOWIKI_DATA_DIR", "./data") // Template caching // var templates = template.Must(template.ParseFiles("edit.html", "view.html")) diff --git a/go-web-app/gowiki/common.go b/go-web-app/gowiki/common/common.go similarity index 93% rename from go-web-app/gowiki/common.go rename to go-web-app/gowiki/common/common.go index 833574e..718169f 100644 --- a/go-web-app/gowiki/common.go +++ b/go-web-app/gowiki/common/common.go @@ -1,4 +1,4 @@ -package main +package common import "os"