Go程序编译通过,但在运行时返回奇怪的错误。

huangapple go评论142阅读模式
英文:

Go program compiles but returns wierd error when is run

问题

我是你的中文翻译助手,以下是你要翻译的内容:

我刚开始学习Golang(今天开始学的),并且我一直在编写一个URL缩短器。但是在运行go install之后,从命令行界面运行编译后的程序时,出现了以下错误:

2014/04/05 19:05:27 invalid character '<' looking for beginning of value
exit status 1

代码参考:https://github.com/hullswitch/urlshortnr

英文:

So i am new to Golang (started learning it today) and i have been writing a URL shortener however after running go install and then running the compiled program from the CLI it returns this error:

2014/04/05 19:05:27 invalid character &#39;&lt;&#39; looking for beginning of value
exit status 1

code refrence: https://github.com/hullswitch/urlshortnr

答案1

得分: 1

你的问题是由于对Google URL缩短器的请求引起的。它返回一个带有HTML正文而不是JSON的404错误。你可以通过在Unmarshal后处理errif语句中添加log.Println(string(output))来进行调试。

英文:

You problem is caused by your request to Google URL Shortner. It returns a 404 Error with HTML body instead of JSON. You could debug it adding log.Println(string(output)) to if handling err after the Unmarshal.

huangapple
  • 本文由 发表于 2014年4月5日 16:10:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/22878298.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定