草庐IT

invalid-url

全部标签

url - 从 URL 中提取不区分大小写的查询参数

我正在尝试从URL中提取不区分大小写的查询参数/staging/ec/23463/front-view-72768.jpg?angle=90&or=0x0&wd=400&ht=200。当我尝试将整个URL转换为小写时,它会抛出以下异常:cannotuser.URL(type*url.URL)astypestringinargumenttostrings.ToLower我打印了URL的值,它表示底层将所有查询字符串存储为map,即map[angle:[90]or:[0x0]wd:[400]ht:[200]]。因此,我将使用此r.URL.Query().Get("or")获得正确的值,但是

go - 再次出现运行时错误 : invalid memory address or nil pointer dereference,

这个问题在这里已经有了答案:Runtimeerror:invalidmemoryaddressornilpointerdereference(1个回答)关闭3年前。我正在尝试将mysqlstore后端包用于GolangWeb应用程序中的gorillasession。我正在关注thisexample我的代码是相同的。代码构建并运行良好,但是当我在浏览器中转到localhost:8080/时出现此错误runtimeerror:invalidmemoryaddressornilpointerdereference这是我的代码:packagemainimport("fmt""github.co

validation - URL 验证似乎已损坏

我正在尝试使用Go的标准库验证URL。这就是我的代码目前的样子。import("fmt""net/url")funcisValidURL(tocheckstring)bool{_,err:=url.ParseRequestURI(tocheck)returnerr==nil}funcmain(){fmt.Println(isValidURL("google.com"))//returnsfalse,expectedtruefmt.Println(isValidURL("www.google.com"))//returnsfalse,expectedtruefmt.Println(isV

amazon-web-services - 创建预签名 url 时出现紧急错误

我正在尝试使用aws-sdk-go创建一个预签名的url,但它失败了,输出如下:panic:runtimeerror:invalidmemoryaddressornilpointerdereference[signalSIGSEGV:segmentationviolationcode=0x1addr=0x18pc=0x138d40a]goroutine1[running]:github.com/aws/aws-sdk-go/service/s3.New(0x0,0x0,0x0,0x0,0x0,0x0)/Users/me/go/src/github.com/aws/aws-sdk-go/

go - 类型 *url.URL 没有字段或方法 ParseRequestURI

这是我的代码:director:=func(req*http.Request){fmt.Println(req.URL)regex,_:=regexp.Compile(`^/([a-zA-Z0-9_-]+)/(\S+)$`)match:=regex.FindStringSubmatch(req.URL.Path)bucket,filename:=match[1],match[2]method:="GET"expires:=time.Now().Add(time.Second*60)signedUrl,err:=storage.SignedURL(bucket,filename,&sto

postgresql - pq : invalid input syntax for type double precision: "$1" with Golang

我正在尝试在我的GO程序中将一个简单的INSERT插入到postgresql数据库中。我的数字0是一个float64,我的数据库中有一列需要doubleprecision。我不知道我需要将数字转换成什么才能让数据库接受该值。 最佳答案 PostgreSQL驱动程序可以很好地处理将float64插入到double列中:tmp=#\dtestTable"public.test"Column|Type|Modifiers--------+------------------+-----------v|doubleprecision|和代码

json - 无法使用 Golang 从 App Engine 将有效的 JSON 数据成功发布到远程 URL

更新:请参阅下面Alexey的评论以了解解决方案我正在尝试一个我认为很简单的函数来获取一些有效的Json数据并将其发布到远程url我已经尝试了在StackOverflow上可以找到的所有与此接近的示例,并且接收方始终有一个空负载。由于能够做到这一点,我排除了接收方:curl-XPOST'http://supersecreturl/mypost'-d'[{"iswaretoritchie":"thisjsonis100%valid"},{"icaneven":"copyand将其粘贴到curlPOST请求中并在远程端完美接收它"}]'请帮忙,我在这里失去理智..///Hereisappr

url - Golang 如何将 punycode 转换为 unicode?

我想转换urlf.e.:xn--h1aaebtrh5b.xn--p1ai-->кисточки.рф当然还有反过来:kremlin.ru--->xn--d1abbgf6aiiy.xn--p1ai我尝试使用idna包,但我无法导入vendor包idnaLink在文档上:https://godoc.org/golang.org/x/net/idna#Profile.ToUnicode尝试导入:import"golang_org/x/net/idna"获取错误:main.go:18:8:cannotfindpackage"golang_org/x/net/idna"inanyof:/usr/

go - 为什么我的 URL.Path 语句没有被命中

下面是我展示html模板的函数。我最近开始在我的博客页面上工作,由于某种原因,我的第一个和第二个“elseif”语句没有被击中。:funchandleRequest(whttp.ResponseWriter,r*http.Request){templates:=populateTemplates()//presenthome.htmliftherequesturlis"/"ifr.URL.Path=="/"{t:=templates.Lookup("home.html")t.Execute(w,nil)}elseifr.URL.Path=="blog/"{posts:=getPosts

go - 在 Go 中解码 URL

我调用的API返回UTF-8编码的XML文档中的URL。解析返回类似http://www.test.com的内容,我想将其转换为http://www.test.com.我正在努力寻找正确的方法来做到这一点。任何帮助将不胜感激!编辑:这段代码可以满足我的需要,但本以为会有一个预构建的函数来做类似于这个网站的事情:https://www.url-encode-decode.com/for_,user:=rangex.Users{a:=strings.Replace(user.Username,":",":",-1)b:=strings.Replace(a,"/","/"