Panic in Package "net/http/httptest"

Hi all!
I had got Panic when I passed separated string like this “foo boo” to target.

You pass an illigal argument to NewRequest. It requires this:

The target is the RFC 7230 “request-target”: it may be either a path or an absolute URL.


" boo"

is neither a path nor an absolute URL. If you want the blank to be part of the path, use url.PathEscape to escape it:

url.PathEscape(" boo")

see Go Playground - The Go Programming Language

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.