I have this structure in golang:
type ScanView struct {
FileInput []ScanInput `json:"inputs"`
Report RegulaReport `json:"report"`
}
type FileInput struct {
Filepath string `json:"filepath"`
Resources map[string]map[string]interface{} `json:"resources"`
}
I need to assign values to the map depending on the key, I'm doing something like this:
for i, r := range output.Inputs {
if filepath.IsAbs(r.Filepath) {
relPath, err := filepath.Rel(inputDir, r.Filepath)
if err != nil {
return "", fmt.Errorf("some error log")
}
output.Inputs[i].Resources["_source_location"]["path"] = relPath -> here I need to assign the value for the _source_location key
output.Inputs[i].Resources["_filepath"][""] = relPath -> here I need to assign the value for the _filepath key
}
}
No pretty sure how can I achieve that for a map[string]map[string]interface{} in Golang. Thanks!