通过另一个结构域的类型声明结构域的类型

Here is *s3.GetObjectOutput struct:

type GetObjectOutput struct {
    ...
    Metadata map[string]*string
    ...
}

I want to declare my struct with a struct field has type of Metadata field in GetObjectOutput struct like this

type MyObject struct {
    Metadata *s3.GetObjectOutput.Metadata
    ...
}

But it was not correct. How do I declare a struct with a field has type of another struct's field instead of explicitly write down:

type MyObject struct {
    Metadata map[string]*string
    ...
}

@William Poussier In that way I have to use a global variable just for use its type. As @zerkms suggested I copied Metadata type from *s3.GetObjectOutput

type Metadata map[string]*string 

and use:

type MyObject struct { 
    Metadata
}

As @zerkms said, you can't. Best idea is to probably create your own field of the same type in MyObject.

You can also embed the s3.GetObjectOutput in MyObject.

type MyObject struct {
    *s3.GetObjectOutput
    ...
}

Given myobj is an instance of MyObject, use myobj.Metadata.