-3

I have a nested struct as below

type TaskList struct {
    Entries []struct {
        Values struct {
            TaskID  string      `json:"Task ID"`
            Summary string      `json:"Summary"`
            Notes   interface{} `json:"Notes"`
        } `json:"values"`
        Links struct {
            Self []struct {
                Href string `json:"href"`
            } `json:"self"`
        } `json:"_links"`
    } `json:"entries"`
    Links struct {
        Self []struct {
            Href string `json:"href"`
        } `json:"self"`
    } `json:"_links"`
}

And I want to access 1 Entries struct and append that to another TaskList struct. I'm not really sure how I would be able to do that.

I want to do something along the lines of :


firstList.Entries = append(firstList.Entries,secondList.Entries)

But I get incompatible types, any help on this would be great.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
hliangpd
  • 33
  • 2
  • 2
    Just put `...` at the end of the second argument. https://stackoverflow.com/questions/16248241/concatenate-two-slices-in-go – jamieguinan Jan 21 '20 at 16:51

1 Answers1

2

try this way:

firstList.Entries = append(firstList.Entries, secondList.Entries...)
Prakash Kumar
  • 2,554
  • 2
  • 18
  • 28