Analyzing the open source code of the project, I met this entry

args := map[string]interface{}{}

I can not understand what this map is and what kind of values ​​it should be stored in it.

The entire context in which the record is used as the request is passed to the route of the type controller / action as the Params as I understood json:

 func (connect *Connect) Request(request string, params string) (interface{}, error) { req, err := connect.factory.NewRequest(Host) if err != nil { return nil, err } args := map[string]interface{}{} json.Unmarshal([]byte(params), &args) resp, err := req.Do(request, args) if err != nil { return nil, err } result, err := resp.GetMethodResult() if err != nil { return nil, err } return result, nil } 

Please give an example.

    1 answer 1

    map [string] interface {} is the map where the key is string and the value matches the type interface {}

    interface {} is an empty interface; any object satisfies it (analogous to void * of C)

    and the last "{}" is the initialization of the map without values ​​(such as map[int]int{1:2, 3:4} )

    can be rewritten as

     args := make(map[string]interface{}) 

    or in more detail

     type any interface{} var args map[string]any args = make(map[string]any,0) // или просто args = make(map[string]any) 
    • Thank you, exhaustively ... just embarrassed the second brackets, did not know that this could be initialized. - user199588