循环动态获取多个结构的信息

I need to fetch collection list and each collection's keys from Mongodb and compare those key in loop with struct which has same name as collection name

Struct in dettails.go

type Chats struct {
    Id  string
    Value string
}

//Controller.go Fetched collection list from Mongodb

names, err := db.CollectionNames()

Loop over collection list and fetched each collection's key list Example collection chats has key Id and Value Now in the same loop I tried to fetch fields of struct (collection name is similar to struct name)

for _, name := range names {
     clKeyList := keylist(name)

     a := &models.name{} // here calling struct dynamically for every iteration but name gives error
     fmt.Println(name)

}

Please suggest some solution, working since last two days to resolve.