summaryrefslogtreecommitdiff
path: root/modules/subject/subject.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/subject/subject.go')
-rw-r--r--modules/subject/subject.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/modules/subject/subject.go b/modules/subject/subject.go
new file mode 100644
index 0000000..f9586cc
--- /dev/null
+++ b/modules/subject/subject.go
@@ -0,0 +1,38 @@
+package subject
+
+import (
+ "encoding/json"
+ "os"
+ "io"
+ "log"
+)
+
+type subjects struct {
+ Subjects []subject `json:"subjects"`
+}
+
+type subject struct {
+ Name string `json:"name"`
+ Description string `json:"description"`
+}
+
+func GetSubjectList() subjects {
+ content, err := os.Open("/data/subjects/subjects.json")
+ if err != nil {
+ log.Fatal("Error when opening file: ", err)
+ }
+
+ content.Close()
+
+ var subjects subjects
+
+ bytevalue, _ := io.ReadAll(content)
+
+ json.Unmarshal(bytevalue, &subjects)
+
+ for i := 0; i < len(subjects.Subjects); i++ {
+
+ }
+
+ return subjects
+}