N
N
nikita_chiru2019-08-09 12:54:32
go
nikita_chiru, 2019-08-09 12:54:32

How to use a ready-made structure in a structure?

I have a ready-made structure A
I want to place it as an element in another structure

type A struct {
  Id          string  `db:"id" json:"id" valid:"uuidv4"`
  Target      string  `db:"target" json:"target" valid:"uuidv4"`
}

type B struct {
  Id          string      `db:"id" json:"id" valid:"uuidv4"`
  Type      int         `db:"type" json:"type" valid:"-"`
  A           null.*A{}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pavlyuk, 2019-08-09
@nikita_chiru

type A struct {
  Id     string `db:"id" json:"id" valid:"uuidv4"`
  Target string `db:"target" json:"target" valid:"uuidv4"`
}

type B struct {
  Id            string `db:"id" json:"id" valid:"uuidv4"`
  Type          int    `db:"type" json:"type" valid:"-"`
  SomeFieldName A      `json:"A"`
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question