From 8d1c6219f7d5f4328047bce57cd7f5129be95fec Mon Sep 17 00:00:00 2001 From: altaf-creator Date: Mon, 21 Oct 2024 07:57:29 +0700 Subject: init --- modules/subject/lesson/lesson.go | 7 +++++++ modules/subject/subject.go | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 modules/subject/lesson/lesson.go create mode 100644 modules/subject/subject.go (limited to 'modules') diff --git a/modules/subject/lesson/lesson.go b/modules/subject/lesson/lesson.go new file mode 100644 index 0000000..9a847f8 --- /dev/null +++ b/modules/subject/lesson/lesson.go @@ -0,0 +1,7 @@ +package lesson + +import "fmt" + +func Test() { + fmt.Println("lesson") +} 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 +} -- cgit v1.2.3