use json files to store data/ get css to work

This commit is contained in:
2025-11-17 03:13:46 +07:00
parent c772904165
commit a4b3f8ce06
9 changed files with 131 additions and 55 deletions

View File

@@ -0,0 +1,41 @@
package store
import (
"encoding/json"
"fmt"
"io"
"os"
)
type ExperienceJSON struct {
ID int `json:"id"`
Company string `json:"company"`
EmployeeType string `json:"employeeType"`
Position string `json:"position"`
Tasks []string `json:"tasks"`
Tools string `json:"tools"`
Years int `json:"years"`
}
func GetAllExperiencesJSON() ([]ExperienceJSON, error) {
jsonFile, err := os.Open("data/experience.json")
if err != nil {
fmt.Println("File not found; Error: ", err.Error())
}
defer jsonFile.Close()
byteValue, err := io.ReadAll(jsonFile)
if err != nil {
fmt.Println("Unable to read json file; Error: ", err.Error())
}
var experience []ExperienceJSON
err = json.Unmarshal(byteValue, &experience)
if err != nil {
fmt.Println("Unable to unmarshal; Error: ", err.Error())
}
return experience, nil
}