I've created a struct, that has the same shape, except the name of the struct:
type Response struct {
code int
body string
}
type Request struct {
code int
body string
}
The question is, does it exist a way to abstract the body of the struct?
For example:
type Response struct {
Payload
}
type Request struct {
Payload
}
type Payload struct {
code int
body string
}
When I create here a new struct, for example
a := Response{ Payload { code:200, body: "Hello world" } }
but I would like to omit to write Payload
every time as:
a := Response{ code:200, body: "Hello world" }
Is it possible to embed a struct to another struct and to omit the name of the struct?