在Cloud9 IDE上运行Go Web服务器

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

Running go webserver on Cloud9 IDE

问题

我有点困惑如何在Cloud9IDE上运行Go语言Web服务器。这是我尝试运行的简单Go服务器:
<br>
https://ide.c9.io/amanuel2/golangpractice

我尝试点击运行,然后访问它要求我去的URL,但是它告诉我404未找到...当我在Cloud9上点击运行时,我还在命令行中看到了以下输出:

Your code is running at https://golangpractice-amanuel2.c9users.io.
Important: use os.Getenv(PORT) as the port and os.Getenv(IP) as the host in your scripts!

2016/03/14 11:45:51 Listening on port 8080 ... 

请帮忙!

英文:

im kinda confused on how to run a go lang webserver on Cloud9IDE.. This is my simple go server i am attempting to run:
<br>
https://ide.c9.io/amanuel2/golangpractice

I tried to click run then went to the url it wants me to go but it told me 404 not found... And i also saw this is the output in the command line when i click run on cloud9:

Your code is running at https://golangpractice-amanuel2.c9users.io.
Important: use os.Getenv(PORT) as the port and os.Getenv(IP) as the host in your scripts!

2016/03/14 11:45:51 Listening on port 8080 ... 

Please help!

答案1

得分: 3

你看到的404错误来自webserver.go的第142行,所以你的应用实际上是正常运行的。根据你的代码,看起来你有一个用于/item/name的路由,所以尝试访问https://golangpractice-amanuel2.c9users.io/item/name,你会在那里得到一些内容。

其他所有的路由都会因为第142行的原因而返回404错误。

英文:

The 404 you're seeing is from line 142 of webserver.go so your app actually is running properly. From your code, it looks like you have a route for /item/name so try going to https://golangpractice-amanuel2.c9users.io/item/name and you'll get something there.

All other routes are giving 404's because of line 142.

huangapple
  • 本文由 发表于 2016年3月14日 19:58:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/35986940.html
匿名

发表评论

匿名网友

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

确定