From 33020b8aabe2983800e5cd91cba9fff4b7cebebe Mon Sep 17 00:00:00 2001 From: cbrgm Date: Mon, 17 Feb 2025 21:38:24 +0100 Subject: [PATCH] refactor: use any instead of interface --- cmd/structuresmith/app.go | 12 ++++++------ cmd/structuresmith/config.go | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/structuresmith/app.go b/cmd/structuresmith/app.go index beebb80..21db9ab 100644 --- a/cmd/structuresmith/app.go +++ b/cmd/structuresmith/app.go @@ -139,7 +139,7 @@ func (app *Structuresmith) renderFileStructure(file FileStructure) error { } // handleFileCreation creates or copies a file based on provided content or source. -func handleFileCreation(fullPath, content string, values map[string]interface{}) error { +func handleFileCreation(fullPath, content string, values map[string]any) error { // Attempt to create a templated file err := createTemplatedFile(fullPath, content, values) if err != nil { @@ -221,8 +221,8 @@ func (app *Structuresmith) processProject(p Project, globalGroups map[string][]F // mergeValues merges group-level values with file-level. // For slices and non-map values, the value from src will overwrite the one in dst. -func mergeValues(dst, src map[string]interface{}) map[string]interface{} { - merged := make(map[string]interface{}) +func mergeValues(dst, src map[string]any) map[string]any { + merged := make(map[string]any) // Copy values from dst into the new map for key, val := range dst { @@ -233,8 +233,8 @@ func mergeValues(dst, src map[string]interface{}) map[string]interface{} { for key, srcVal := range src { if dstVal, exists := merged[key]; exists { // If both values are maps, merge them recursively - if srcMap, srcOk := srcVal.(map[string]interface{}); srcOk { - if dstMap, dstOk := dstVal.(map[string]interface{}); dstOk { + if srcMap, srcOk := srcVal.(map[string]any); srcOk { + if dstMap, dstOk := dstVal.(map[string]any); dstOk { merged[key] = mergeValues(dstMap, srcMap) continue } @@ -315,7 +315,7 @@ func downloadFileContent(fileURL string) (string, error) { } // createTemplatedFile creates a file from a template content and values. -func createTemplatedFile(path, content string, values map[string]interface{}) error { +func createTemplatedFile(path, content string, values map[string]any) error { f, err := os.Create(path) if err != nil { return fmt.Errorf("creating file: %w", err) diff --git a/cmd/structuresmith/config.go b/cmd/structuresmith/config.go index 81d9605..dcb2922 100644 --- a/cmd/structuresmith/config.go +++ b/cmd/structuresmith/config.go @@ -25,8 +25,8 @@ type ProjectConfig struct { // TemplateGroupRef links a template group with specific values. type TemplateGroupRef struct { - GroupName string `yaml:"groupName"` - Values map[string]interface{} `yaml:"values"` + GroupName string `yaml:"groupName"` + Values map[string]any `yaml:"values"` } // FileStructure describes a file to be created from a template or URL. @@ -35,7 +35,7 @@ type FileStructure struct { Source string `yaml:"source"` SourceURL string `yaml:"sourceUrl"` Content string `yaml:"content"` - Values map[string]interface{} + Values map[string]any } // Template represents a template consisting of multiple files.