From 77b720f8d21504aa76556e292d39bf79fe33792e Mon Sep 17 00:00:00 2001 From: Robert Janetzko Date: Thu, 14 Apr 2022 13:58:28 +0000 Subject: [PATCH] restructure --- analyze/go.mod | 5 ++ analyze/go.sum | 2 + analyze/{analyze.go => main.go} | 4 +- {df => backend/df}/model.go | 0 {df => backend/df}/parse.go | 0 go.mod => backend/go.mod | 2 +- go.sum => backend/go.sum | 0 main.go => backend/main.go | 19 ++++--- {model => backend/model}/analyze.go | 0 {model => backend/model}/events.go | 0 {model => backend/model}/model.go | 0 {model => backend/model}/util.go | 0 {model => backend/model}/world.go | 0 {server => backend/server}/resource.go | 0 {server => backend/server}/servestatic.go | 0 {util => backend/util}/cp473.go | 0 {util => backend/util}/util.go | 0 generate/model.go | 64 ----------------------- 18 files changed, 19 insertions(+), 77 deletions(-) create mode 100644 analyze/go.mod create mode 100644 analyze/go.sum rename analyze/{analyze.go => main.go} (99%) rename {df => backend/df}/model.go (100%) rename {df => backend/df}/parse.go (100%) rename go.mod => backend/go.mod (68%) rename go.sum => backend/go.sum (100%) rename main.go => backend/main.go (92%) rename {model => backend/model}/analyze.go (100%) rename {model => backend/model}/events.go (100%) rename {model => backend/model}/model.go (100%) rename {model => backend/model}/util.go (100%) rename {model => backend/model}/world.go (100%) rename {server => backend/server}/resource.go (100%) rename {server => backend/server}/servestatic.go (100%) rename {util => backend/util}/cp473.go (100%) rename {util => backend/util}/util.go (100%) delete mode 100644 generate/model.go diff --git a/analyze/go.mod b/analyze/go.mod new file mode 100644 index 0000000..3e09372 --- /dev/null +++ b/analyze/go.mod @@ -0,0 +1,5 @@ +module github.com/robertjanetzko/LegendsBrowser2/analyze + +go 1.18 + +require github.com/iancoleman/strcase v0.2.0 diff --git a/analyze/go.sum b/analyze/go.sum new file mode 100644 index 0000000..52785b4 --- /dev/null +++ b/analyze/go.sum @@ -0,0 +1,2 @@ +github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= +github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= diff --git a/analyze/analyze.go b/analyze/main.go similarity index 99% rename from analyze/analyze.go rename to analyze/main.go index fb36bba..895fe88 100644 --- a/analyze/analyze.go +++ b/analyze/main.go @@ -1,4 +1,4 @@ -package analyze +package main import ( "encoding/json" @@ -6,7 +6,6 @@ import ( "fmt" "io" "io/ioutil" - "legendsbrowser/util" "log" "os" "path/filepath" @@ -16,6 +15,7 @@ import ( "text/template" "github.com/iancoleman/strcase" + "github.com/robertjanetzko/LegendsBrowser2/backend/util" ) func Analyze(filex string) { diff --git a/df/model.go b/backend/df/model.go similarity index 100% rename from df/model.go rename to backend/df/model.go diff --git a/df/parse.go b/backend/df/parse.go similarity index 100% rename from df/parse.go rename to backend/df/parse.go diff --git a/go.mod b/backend/go.mod similarity index 68% rename from go.mod rename to backend/go.mod index a1702bc..20eaaae 100644 --- a/go.mod +++ b/backend/go.mod @@ -1,4 +1,4 @@ -module legendsbrowser +module github.com/robertjanetzko/LegendsBrowser2/backend go 1.18 diff --git a/go.sum b/backend/go.sum similarity index 100% rename from go.sum rename to backend/go.sum diff --git a/main.go b/backend/main.go similarity index 92% rename from main.go rename to backend/main.go index f37f5d7..4800a22 100644 --- a/main.go +++ b/backend/main.go @@ -3,7 +3,6 @@ package main import ( "flag" "fmt" - "legendsbrowser/analyze" "legendsbrowser/df" "legendsbrowser/server" "net/http" @@ -18,18 +17,18 @@ import ( var world *df.DfWorld func main() { - a := flag.String("a", "", "analyze a file") - g := flag.Bool("g", false, "generate model") + // a := flag.String("a", "", "analyze a file") + // g := flag.Bool("g", false, "generate model") f := flag.String("f", "", "open a file") flag.Parse() - if len(*a) > 0 { - analyze.Analyze(*a) - } - if *g { - fmt.Println("Generating") - analyze.Generate() - } + // if len(*a) > 0 { + // analyze.Analyze(*a) + // } + // if *g { + // fmt.Println("Generating") + // analyze.Generate() + // } if len(*f) > 0 { defer profile.Start(profile.MemProfile).Stop() diff --git a/model/analyze.go b/backend/model/analyze.go similarity index 100% rename from model/analyze.go rename to backend/model/analyze.go diff --git a/model/events.go b/backend/model/events.go similarity index 100% rename from model/events.go rename to backend/model/events.go diff --git a/model/model.go b/backend/model/model.go similarity index 100% rename from model/model.go rename to backend/model/model.go diff --git a/model/util.go b/backend/model/util.go similarity index 100% rename from model/util.go rename to backend/model/util.go diff --git a/model/world.go b/backend/model/world.go similarity index 100% rename from model/world.go rename to backend/model/world.go diff --git a/server/resource.go b/backend/server/resource.go similarity index 100% rename from server/resource.go rename to backend/server/resource.go diff --git a/server/servestatic.go b/backend/server/servestatic.go similarity index 100% rename from server/servestatic.go rename to backend/server/servestatic.go diff --git a/util/cp473.go b/backend/util/cp473.go similarity index 100% rename from util/cp473.go rename to backend/util/cp473.go diff --git a/util/util.go b/backend/util/util.go similarity index 100% rename from util/util.go rename to backend/util/util.go diff --git a/generate/model.go b/generate/model.go deleted file mode 100644 index e20ae22..0000000 --- a/generate/model.go +++ /dev/null @@ -1,64 +0,0 @@ -package generate - -import ( - "bufio" - "log" - "net/http" - "os" - "strings" - "text/template" - "time" -) - -func Generate() { - const url = "https://github.com/golang/go/raw/master/CONTRIBUTORS" - - rsp, err := http.Get(url) - die(err) - defer rsp.Body.Close() - - sc := bufio.NewScanner(rsp.Body) - carls := []string{} - - for sc.Scan() { - if strings.Contains(sc.Text(), "Carl") { - carls = append(carls, sc.Text()) - } - } - - die(sc.Err()) - - f, err := os.Create("contributors.go") - die(err) - defer f.Close() - - packageTemplate.Execute(f, struct { - Timestamp time.Time - URL string - Carls []string - }{ - Timestamp: time.Now(), - URL: url, - Carls: carls, - }) -} - -func die(err error) { - if err != nil { - log.Fatal(err) - } -} - -var packageTemplate = template.Must(template.New("").Parse(`// Code generated by go generate; DO NOT EDIT. -// This file was generated by robots at -// {{ .Timestamp }} -// using data from -// {{ .URL }} -package project - -var Contributors = []string{ -{{- range .Carls }} - {{ printf "%q" . }}, -{{- end }} -} -`))