编译报错jiankonggo4986 goproxyNewProxyHttpServerNewRequest undefined type goproxyProxyHttpServer has no field or method NewRequestpackage mainimport bufio fmt ioioutil 添加该行 nethttp netur
报错原因:goproxy.ProxyHttpServer 类型没有 NewRequest 方法。
解决方法:使用 goproxy.Request 类型的 New 方法创建请求对象。
修改代码:
将
_, err := goproxy.NewProxyHttpServer().Tr.RoundTrip(goproxy.NewProxyHttpServer().NewRequest("GET", apiUrl, nil))
修改为
req := goproxy.NewRequest(ctx.Req.Method, apiUrl, nil) _, err := goproxy.NewProxyHttpServer().Tr.RoundTrip(req)
原文地址: https://www.cveoy.top/t/topic/eDrW 著作权归作者所有。请勿转载和采集!