M
M
Michael2017-03-13 17:01:02
go
Michael, 2017-03-13 17:01:02

How to create an object by the name of the structure?

There are several structures and there is a function that takes the name of the structure as input, how to create an object by the name of the structure

type CurrentStatus struct {
  CURENTSTID int
  NAME       string 
}

type EstateStatus struct {
  ESTSTATID int  
  NAME      string
  SHORTNAME 
}
func Create(path string) {
var i :=new(path)
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Trakhimenok, 2017-03-13
@Slider_vm

Get a map with a string key, and as a value, a function that creates an instance of the desired type.
Or good old switch/case.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question