Skip to content

Confused in the below code lines #1

@anpolychrono

Description

@anpolychrono

I am bit confused with the lines under the comment "wake up the function ?", why you are calling the newRequest() again and then you are calling the http.Do() twice ?

file : petstore.go

func (c *Client) do(ctx context.Context, req *http.Request, v interface{}) error {
	// Add the context to the request.
	req = req.WithContext(ctx)
	log.Printf("[DEBUG] go-petstore request: %v", req)
	
	// wake up the function?
	tempReq, _ := c.newRequest("GET","pets",nil)
	c.http.Do(tempReq)
		  
	// Execute the request and check the response.
	resp, err := c.http.Do(req)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions