From 3559ca9ec114db102540ca5ce301539e87d108dc Mon Sep 17 00:00:00 2001 From: Ray Miller Date: Sun, 8 Oct 2023 15:05:12 +0100 Subject: [PATCH] Refactor to move cloud fn to top level --- README.md | 3 ++- anagram/anagram.go | 2 +- cloudfn/cloudfn.go => cloudfn.go | 6 +++--- {fix-wordlist => cmd/fix-wordlist}/main.go | 0 cmd/{ => fn-framework-test}/main.go | 2 +- go.mod | 2 +- match/match.go | 2 +- {assets => standalone/assets}/custom.css | 0 {assets => standalone/assets}/htmx.min.js | 0 {assets => standalone/assets}/simple.css | 0 main.go => standalone/main.go | 6 +++--- {server => standalone/server}/server.go | 4 ++-- {server => standalone/server}/templates.go | 0 wordlist.txt => standalone/wordlist.txt | 0 14 files changed, 14 insertions(+), 13 deletions(-) rename cloudfn/cloudfn.go => cloudfn.go (97%) rename {fix-wordlist => cmd/fix-wordlist}/main.go (100%) rename cmd/{ => fn-framework-test}/main.go (94%) rename {assets => standalone/assets}/custom.css (100%) rename {assets => standalone/assets}/htmx.min.js (100%) rename {assets => standalone/assets}/simple.css (100%) rename main.go => standalone/main.go (83%) rename {server => standalone/server}/server.go (96%) rename {server => standalone/server}/templates.go (100%) rename wordlist.txt => standalone/wordlist.txt (100%) diff --git a/README.md b/README.md index e6de563..1d85e85 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Match patterns and solve anagrams - handy for crossword fanatics. ## Standalone Server ```bash +cd standalone go run main.go ``` @@ -14,7 +15,7 @@ To test using the Cloud Functions Framework: ```bash env FUNCTION_TARGET=WordSearch WORDLIST_BUCKET=word-search-1729-assets \ - WORDLIST_PATH=data/wordlist.txt LOCAL_ONLY=true go run cmd/main.go + WORDLIST_PATH=data/wordlist.txt LOCAL_ONLY=true go run ./cmd/fn-framework-test/main.go curl 'http://localhost:8080?mode=anagrams&pattern=idea' ``` diff --git a/anagram/anagram.go b/anagram/anagram.go index 7c29e76..227165f 100644 --- a/anagram/anagram.go +++ b/anagram/anagram.go @@ -5,7 +5,7 @@ import ( "io" "sort" - "github.com/ray1729/puzzle-solver/util" + "github.com/ray1729/wordsearch/util" ) type DB interface { diff --git a/cloudfn/cloudfn.go b/cloudfn.go similarity index 97% rename from cloudfn/cloudfn.go rename to cloudfn.go index 6b1419d..75534f1 100644 --- a/cloudfn/cloudfn.go +++ b/cloudfn.go @@ -1,4 +1,4 @@ -package cloudfn +package wordsearch import ( "bufio" @@ -12,8 +12,8 @@ import ( "cloud.google.com/go/storage" "github.com/GoogleCloudPlatform/functions-framework-go/functions" - "github.com/ray1729/puzzle-solver/anagram" - "github.com/ray1729/puzzle-solver/match" + "github.com/ray1729/wordsearch/anagram" + "github.com/ray1729/wordsearch/match" "github.com/rs/cors" ) diff --git a/fix-wordlist/main.go b/cmd/fix-wordlist/main.go similarity index 100% rename from fix-wordlist/main.go rename to cmd/fix-wordlist/main.go diff --git a/cmd/main.go b/cmd/fn-framework-test/main.go similarity index 94% rename from cmd/main.go rename to cmd/fn-framework-test/main.go index d47df5b..e02e774 100644 --- a/cmd/main.go +++ b/cmd/fn-framework-test/main.go @@ -6,7 +6,7 @@ import ( // Blank-import the function package so the init() runs "github.com/GoogleCloudPlatform/functions-framework-go/funcframework" - _ "github.com/ray1729/puzzle-solver/cloudfn" + _ "github.com/ray1729/wordsearch" ) func main() { diff --git a/go.mod b/go.mod index 8303040..7b8b9f4 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/ray1729/puzzle-solver +module github.com/ray1729/wordsearch go 1.21.1 diff --git a/match/match.go b/match/match.go index 3081b86..7179e17 100644 --- a/match/match.go +++ b/match/match.go @@ -4,7 +4,7 @@ import ( "bufio" "io" - "github.com/ray1729/puzzle-solver/util" + "github.com/ray1729/wordsearch/util" ) type DB interface { diff --git a/assets/custom.css b/standalone/assets/custom.css similarity index 100% rename from assets/custom.css rename to standalone/assets/custom.css diff --git a/assets/htmx.min.js b/standalone/assets/htmx.min.js similarity index 100% rename from assets/htmx.min.js rename to standalone/assets/htmx.min.js diff --git a/assets/simple.css b/standalone/assets/simple.css similarity index 100% rename from assets/simple.css rename to standalone/assets/simple.css diff --git a/main.go b/standalone/main.go similarity index 83% rename from main.go rename to standalone/main.go index b36db24..3d4e031 100644 --- a/main.go +++ b/standalone/main.go @@ -6,9 +6,9 @@ import ( "net/http" "os" - "github.com/ray1729/puzzle-solver/anagram" - "github.com/ray1729/puzzle-solver/match" - "github.com/ray1729/puzzle-solver/server" + "github.com/ray1729/wordsearch/anagram" + "github.com/ray1729/wordsearch/match" + "github.com/ray1729/wordsearch/standalone/server" ) var matchDB match.DB diff --git a/server/server.go b/standalone/server/server.go similarity index 96% rename from server/server.go rename to standalone/server/server.go index e937595..7752f6d 100644 --- a/server/server.go +++ b/standalone/server/server.go @@ -7,8 +7,8 @@ import ( "net/http" "sort" - "github.com/ray1729/puzzle-solver/anagram" - "github.com/ray1729/puzzle-solver/match" + "github.com/ray1729/wordsearch/anagram" + "github.com/ray1729/wordsearch/match" ) func New(assetsPath string, matchDB match.DB, anagramDB anagram.DB) http.Handler { diff --git a/server/templates.go b/standalone/server/templates.go similarity index 100% rename from server/templates.go rename to standalone/server/templates.go diff --git a/wordlist.txt b/standalone/wordlist.txt similarity index 100% rename from wordlist.txt rename to standalone/wordlist.txt