Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- type mainStruct[Type any] struct {
- firstField string
- secondField bool
- slaveStruct slaveStruct
- Struct Type
- }
- type slaveStruct struct {
- firstField string
- secondField bool
- }
- type otherStruct struct {
- firstField string
- secondField bool
- }
- func makeStruct[Type any](source *Type) *mainStruct[Type] {
- return &mainStruct[Type]{
- firstField: "",
- secondField: false,
- slaveStruct: slaveStruct{},
- Struct: *source,
- }
- }
- func main() {
- fullStruct := makeStruct(&otherStruct{})
- fmt.Printf("%+v\n", *fullStruct)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement