goreq | Minimal and simple request library for Go language | REST library

 by   franela Go Version: Current License: MIT

kandi X-RAY | goreq Summary

goreq is a Go library typically used in Web Services, REST, Nodejs applications. goreq has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.
Minimal and simple request library for Go language
    Support
      Quality
        Security
          License
            Reuse
            Support
              Quality
                Security
                  License
                    Reuse

                      kandi-support Support

                        summary
                        goreq has a low active ecosystem.
                        summary
                        It has 702 star(s) with 105 fork(s). There are 21 watchers for this library.
                        summary
                        It had no major release in the last 6 months.
                        summary
                        There are 19 open issues and 50 have been closed. On average issues are closed in 2 days. There are 7 open pull requests and 0 closed requests.
                        summary
                        It has a neutral sentiment in the developer community.
                        summary
                        The latest version of goreq is current.
                        goreq Support
                          Best in #REST
                            Average in #REST
                            goreq Support
                              Best in #REST
                                Average in #REST

                                  kandi-Quality Quality

                                    summary
                                    goreq has 0 bugs and 0 code smells.
                                    goreq Quality
                                      Best in #REST
                                        Average in #REST
                                        goreq Quality
                                          Best in #REST
                                            Average in #REST

                                              kandi-Security Security

                                                summary
                                                goreq has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
                                                summary
                                                goreq code analysis shows 0 unresolved vulnerabilities.
                                                summary
                                                There are 0 security hotspots that need review.
                                                goreq Security
                                                  Best in #REST
                                                    Average in #REST
                                                    goreq Security
                                                      Best in #REST
                                                        Average in #REST

                                                          kandi-License License

                                                            summary
                                                            goreq is licensed under the MIT License. This license is Permissive.
                                                            summary
                                                            Permissive licenses have the least restrictions, and you can use them in most projects.
                                                            goreq License
                                                              Best in #REST
                                                                Average in #REST
                                                                goreq License
                                                                  Best in #REST
                                                                    Average in #REST

                                                                      kandi-Reuse Reuse

                                                                        summary
                                                                        goreq releases are not available. You will need to build from source code and install.
                                                                        summary
                                                                        Installation instructions are not available. Examples and code snippets are available.
                                                                        goreq Reuse
                                                                          Best in #REST
                                                                            Average in #REST
                                                                            goreq Reuse
                                                                              Best in #REST
                                                                                Average in #REST
                                                                                  Top functions reviewed by kandi - BETA
                                                                                  kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
                                                                                  Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here
                                                                                  Get all kandi verified functions for this library.
                                                                                  Get all kandi verified functions for this library.

                                                                                  goreq Key Features

                                                                                  [Why GoReq?](#user-content-why-goreq)
                                                                                  [How do I install it?](#user-content-how-do-i-install-it)
                                                                                  [What can I do with it?](#user-content-what-can-i-do-with-it)
                                                                                  [Making requests with different methods](#user-content-making-requests-with-different-methods)
                                                                                  [GET](#user-content-get)
                                                                                  [Tags](#user-content-tags)
                                                                                  [POST](#user-content-post)
                                                                                  [Sending payloads in the Body](#user-content-sending-payloads-in-the-body)
                                                                                  [Specifiying request headers](#user-content-specifiying-request-headers)
                                                                                  [Sending Cookies](#cookie-support)
                                                                                  [Setting timeouts](#user-content-setting-timeouts)
                                                                                  [Using the Response and Error](#user-content-using-the-response-and-error)
                                                                                  [Receiving JSON](#user-content-receiving-json)
                                                                                  [Sending/Receiving Compressed Payloads](#user-content-sendingreceiving-compressed-payloads)
                                                                                  [Using gzip compression:](#user-content-using-gzip-compression)
                                                                                  [Using deflate compression:](#user-content-using-deflate-compression)
                                                                                  [Using compressed responses:](#user-content-using-compressed-responses)
                                                                                  [Proxy](#proxy)
                                                                                  [Debugging requests](#debug)
                                                                                  [Getting raw Request & Response](#getting-raw-request—​response)
                                                                                  [TODO:](#user-content-todo)

                                                                                  goreq Examples and Code Snippets

                                                                                  No Code Snippets are available at this moment for goreq.
                                                                                  Community Discussions

                                                                                  Trending Discussions on goreq

                                                                                  How to "force" Golang func to take a new instance of a struct
                                                                                  chevron right

                                                                                  QUESTION

                                                                                  How to "force" Golang func to take a new instance of a struct
                                                                                  Asked 2020-Apr-03 at 17:43

                                                                                  So a struct holds data that could get mutated. Is there some trick or technique in Golang that can tell a func that it must accept a new instance of a struct? In other words, try to best avoid reusing data that may have been mutated before the fact or may get mutated during func lifecycle. (I could avoid mutating stuff, but other devs on my team might not get the memo).

                                                                                  To illustrate:

                                                                                  type CMRequest struct {
                                                                                    Endpoint    string
                                                                                    Method      string
                                                                                  }
                                                                                  
                                                                                  func (cmreq CMRequest) Run() (res *goreq.Response) {
                                                                                   /// this could mutate cmreq
                                                                                  }
                                                                                  

                                                                                  obviously Run() could mutate the data in cmreq, so I am wondering if there is a good pattern to force the creation of fresh data every time? The only thing I can think of is to keep the struct private, and do something like this:

                                                                                  type cmrequest struct {
                                                                                    Endpoint    string
                                                                                    Method      string
                                                                                  }
                                                                                  
                                                                                  func (cmreq cmrequest) Run() (res *goreq.Response) {
                                                                                   /// this could mutate cmreq
                                                                                  }
                                                                                  

                                                                                  and then expose a helper func:

                                                                                  func MakeRequestAndUnmarshalBody(d CMRequestNoReuse) (*goreq.Response) {
                                                                                  
                                                                                    // check that d has a unique memory location?
                                                                                  
                                                                                    cmreq := NewCPRequest(d)
                                                                                    res := cmreq.Run()
                                                                                  
                                                                                    return res
                                                                                  }
                                                                                  

                                                                                  so the helper func would be public, and it would create a new instance of the struct every time? is there any other way to go about it? I still can't force the user to pass in new data every time, although I could check to see if the memory location of d CMRequestNoReuse is unique?

                                                                                  ANSWER

                                                                                  Answered 2020-Apr-03 at 17:43

                                                                                  Actually, no, in your example, this doesn't mutate data in CMRequest instance:

                                                                                  func (cmreq CMRequest) Run() (res *goreq.Response) {
                                                                                   /// this could mutate cmreq
                                                                                  }
                                                                                  

                                                                                  When you pass object by value, you actually get copy of it, not reference to it.

                                                                                  To mutate, you need to pass by pointer. I.e. Run method would look like:

                                                                                  func (cmreq *CMRequest) Run() (res *goreq.Response) {
                                                                                   /// this actually can mutate cmreq
                                                                                  }
                                                                                  

                                                                                  Then you actually have access to original object via pointer and can mutate it.

                                                                                  Here is example in go playground. But note, if one of the fields of struct is pointer -- you still can mutate it.

                                                                                  Source https://stackoverflow.com/questions/61017246

                                                                                  Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                                                                                  Vulnerabilities

                                                                                  No vulnerabilities reported

                                                                                  Install goreq

                                                                                  You can download it from GitHub.

                                                                                  Support

                                                                                  For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
                                                                                  Find more information at:
                                                                                  Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                  Find more libraries
                                                                                  Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                  Save this library and start creating your kit
                                                                                  CLONE
                                                                                • HTTPS

                                                                                  https://github.com/franela/goreq.git

                                                                                • CLI

                                                                                  gh repo clone franela/goreq

                                                                                • sshUrl

                                                                                  git@github.com:franela/goreq.git

                                                                                • Share this Page

                                                                                  share link

                                                                                  Explore Related Topics

                                                                                  Reuse Pre-built Kits with goreq

                                                                                  Consider Popular REST Libraries

                                                                                  public-apis

                                                                                  by public-apis

                                                                                  json-server

                                                                                  by typicode

                                                                                  iptv

                                                                                  by iptv-org

                                                                                  fastapi

                                                                                  by tiangolo

                                                                                  beego

                                                                                  by beego

                                                                                  Try Top Libraries by franela

                                                                                  goblin

                                                                                  by franelaGo

                                                                                  vault

                                                                                  by franelaGo

                                                                                  go-supertest

                                                                                  by franelaGo

                                                                                  play-with-nomad

                                                                                  by franelaCSS

                                                                                  watch-docker

                                                                                  by franelaCSS

                                                                                  Compare REST Libraries with Highest Support

                                                                                  fastapi

                                                                                  by tiangolo

                                                                                  dropwizard

                                                                                  by dropwizard

                                                                                  python

                                                                                  by kubernetes-client

                                                                                  Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                  Find more libraries
                                                                                  Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                  Save this library and start creating your kit