英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论