I'm trying to create a custom function that passes the Request object back as a result:
func ConstructRequest(testParameters string, reqType string) Request {
req, err := http.NewRequest(reqType, testPath+testParameters, nil)
if err != nil {
log.Fatal(err)
return nil
} else {
return req
}
}
but I'm getting a "undefined: Request" error
I'm not sure what library I need to import to make it work?
undefined: Request
seems normal if you don't specify the package for the returned type:
func ConstructRequest(testParameters string, reqType string) http.Request
^^^^
Since http.NewRequest()
returns a pointer, this should be:
func ConstructRequest(testParameters string, reqType string) *http.Request