在Go中存储和迭代命名嵌套数据结构的惯用方式?

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.

Based on what I saw in your pseudocode and based on what I heard from the comments, I would go with slice of slices of struct:

So I would define a struct:

type subtask struct {
    name string
    kind int
}

where name would be your api.example.com/stuff/ and kind would be a type of your subtask:

I will be treating them differently (some API's want different headers)

Then your list would look like this:

list := [][]subtask{
    []subtask{subtask{"example1", 1}, subtask{"example2", 1}},
    []subtask{subtask{"example3", 1}, subtask{"example4", 2}},
}

And fully working example is here Playground