about summary refs log tree commit diff
path: root/src/seed.go
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-10-09 18:34:23 +0200
committerEmile <hanemile@protonmail.com>2019-10-09 18:34:23 +0200
commit0d2fe61af698a0e1d1f650d80f296bd88fc3cb6e (patch)
tree9f7eef8cd93a8a87ee143c98eb3e51e65eed94e1 /src/seed.go
parent8aebf1c287dc308a027f975557472af0f8998986 (diff)
gofmt and added user to stats struct
Diffstat (limited to 'src/seed.go')
-rw-r--r--src/seed.go23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/seed.go b/src/seed.go
index dd836ff..805ab20 100644
--- a/src/seed.go
+++ b/src/seed.go
@@ -4,15 +4,17 @@ import (
 	"encoding/json"
 	"flag"
 	"fmt"
-	"github.com/pkg/errors"
 	"io/ioutil"
 	"log"
 	"time"
+
+	"github.com/pkg/errors"
 )
 
 var (
-	challenges = []Challenge{}
-	seedFilePath* string
+	challenges   = []Challenge{}
+	seedFilePath *string
+	user         string
 )
 
 func registerSeedFlags() {
@@ -52,13 +54,13 @@ func readSeedFile(path string) ([]Challenge, error) {
 
 		if nameOK && descOK && flagOK && contOK && categoryOK {
 			tmpChallenges = append(tmpChallenges, Challenge{
-				Name: name,
+				Name:        name,
 				Description: desc,
-				Flag: flag,
-				FoundFlag: time.Unix(0, 0),
-				FlagTries: 0,
-				Container: cont,
-				Category: category,
+				Flag:        flag,
+				FoundFlag:   time.Unix(0, 0),
+				FlagTries:   0,
+				Container:   cont,
+				Category:    category,
 			})
 		} else {
 			log.Printf("Ignoring challenge at position %d: Not all values are parseable (name: %b, desc: %b, flag: %b, container: %b, category: %b", index, nameOK, descOK, flagOK, contOK, categoryOK)
@@ -69,7 +71,7 @@ func readSeedFile(path string) ([]Challenge, error) {
 }
 
 // Read the file we set up using flags and store the returned challenge array
-func getChallengesFromSeedFile() (error) {
+func getChallengesFromSeedFile() error {
 	tmpChallenges, error := readSeedFile(*seedFilePath)
 
 	if error != nil {
@@ -124,6 +126,7 @@ func generateJSONFromChallengesForStats() (string, error) {
 	}
 
 	marshalled, marshalError := json.Marshal(map[string]interface{}{
+		"user":       user,
 		"challenges": strippedChallenges,
 	})
 	return string(marshalled), marshalError