D
D
denshash2016-05-21 20:05:49
go
denshash, 2016-05-21 20:05:49

Golang: What does map[string]interface{}{} mean?

While analyzing the open source code of the project, I came across this entry

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

I can't figure out what kind of map it is and what kind of values ​​it should store.
The entire context in which the record is used as a request is passed to the route of the form controller / action as 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.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Semchenko, 2016-05-21
@denshash

Plain: key:string value:interface{}

args := map[string]interface{}{"apple": 5, "lettuce": 7} так проще?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question