31 lines
668 B
Go
31 lines
668 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func loadTemplate(templatesPath string) (*DashboardTemplate, error) {
|
|
templateFile := filepath.Join(templatesPath, "dashboard_template.json")
|
|
|
|
data, err := os.ReadFile(templateFile)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to read template file: %w", err)
|
|
}
|
|
|
|
var template DashboardTemplate
|
|
if err := json.Unmarshal(data, &template); err != nil {
|
|
return nil, fmt.Errorf("failed to parse template JSON: %w", err)
|
|
}
|
|
|
|
return &template, nil
|
|
}
|
|
|
|
func deepCopy(src interface{}) interface{} {
|
|
data, _ := json.Marshal(src)
|
|
var dst interface{}
|
|
json.Unmarshal(data, &dst)
|
|
return dst
|
|
}
|