My question is split into two: (1) what's the best way to store the data for taskList below, and (2) what's the best way to iterate over such a structure?
I want the task1
named because they are unique tasks and there shouldn't be an ID collision. I want individually named subtask0
because they are unique tasks with different requirements.
Below is a pseudo-Go representation of my intention:
package main
import "fmt"
fn main() {
const taskList := {
"task1": {
"subtask0": "api.example.com/stuff/"
"subtask1": "api.example.com/stuff/"
"subtask2": "api.example.com/stuff/"
}
"task2": {
"subtask0": "api.example.com/stuff/"
"subtask1": "api.example.com/stuff/"
"subtask2": "api.example.com/stuff/"
}
}
for i := range taskList {
for j := range taskList[i] {
fmt.Printf("%s
", taskList[i][j])
}
}
}
I've tried struct, but I had difficulty iterating over the struct. I wanted to avoid map
because Go wouldn't let me store it in a const
.