0

Im using the following struct

type Str struct {
    Info    string
    Command string
}

And to fill data inside of it Im doing the following which works.

    return []Str{
        {"info from source",
            "install && run"},
    }

Now I need to change the command to array

type Str struct {
    Info    string
    Command []string
}

And provide each of the commands("install" and "run") in new entry in the array, how can I do that

when I try with

return []Str{
    {"info from source",string[]{
        {"install},  {"run"}},
}

I got erorr of missing type literal, any idea what Im doing wrong

1
  • I also do that mistake, inserting [] after type (as I spell it as type array). Instead spelling as "slice of type" helps to write as []string. Commented Jul 29, 2018 at 12:51

1 Answer 1

3

The correct syntax is the following:

return []Str{
    {"info from source", []string{"install", "run"}},
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.