summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclsr <clsr@clsr.net>2016-11-15 20:01:01 +0100
committerclsr <clsr@clsr.net>2016-11-15 20:01:01 +0100
commit1dd9e1840cee0bdbca5e63a911151a0d530b8bcc (patch)
tree8e261adedf843258b97666ee7f06ac8b91baf768
parent905c45948959551242ddd801e3745df672b5cd55 (diff)
downloadgomf-modpanel-1dd9e1840cee0bdbca5e63a911151a0d530b8bcc.tar.gz
gomf-modpanel-1dd9e1840cee0bdbca5e63a911151a0d530b8bcc.zip
Reorder init
-rw-r--r--main.go23
1 files changed, 12 insertions, 11 deletions
diff --git a/main.go b/main.go
index 050bb0e..9d499ba 100644
--- a/main.go
+++ b/main.go
@@ -29,8 +29,7 @@ var (
deleted *json.Encoder
deletedLog *os.File
deletedLock sync.RWMutex
-
- templates = template.Must(template.ParseGlob("templates/*.html"))
+ templates *template.Template
)
func getLogNames() ([]string, error) {
@@ -62,8 +61,8 @@ func getLog(log string) ([]map[string]interface{}, error) {
if err == io.EOF {
err = nil
}
- for i := len(entries)/2-1; i >= 0; i-- {
- j := len(entries)-1-i
+ for i := len(entries)/2 - 1; i >= 0; i-- {
+ j := len(entries) - 1 - i
entries[i], entries[j] = entries[j], entries[i]
}
return entries, err
@@ -317,6 +316,15 @@ func main() {
flag.Parse()
+ templates = template.Must(template.ParseGlob("templates/*.html"))
+
+ for _, dir := range []string{"log/", "upload/ids/", "upload/files/"} {
+ if _, err := os.Stat(path.Join(gomfRoot, dir)); err != nil {
+ fmt.Fprintf(os.Stderr, "error: %s; is --gomf-root set correctly?\n", err)
+ os.Exit(1)
+ }
+ }
+
access = make(map[string]string)
for _, s := range strings.Split(*accessFlag, ",") {
up := strings.Split(s, ":")
@@ -344,13 +352,6 @@ func main() {
http.Handle(deletionPath, http.HandlerFunc(handleDeletionLog))
}
- for _, dir := range []string{"log/", "upload/ids/", "upload/files/"} {
- if _, err := os.Stat(path.Join(gomfRoot, dir)); err != nil {
- fmt.Fprintf(os.Stderr, "error: %s; is --gomf-root set correctly?\n", err)
- os.Exit(1)
- }
- }
-
exit := true
if *listenHttp != "" {
exit = false