【发布时间】:2020-11-04 07:57:24
【问题描述】:
我正在使用这个 web 框架进行 go:https://github.com/gofiber/fiber
我想运行他们给出的名为"hello world"的基本示例
我复制了代码并将其放入名为main.go的文件中
// ⚡️ Fiber is an Express inspired web framework written in Go with ☕️
// ???? Github Repository: https://github.com/gofiber/fiber
// ???? API Documentation: https://docs.gofiber.io
package main
import (
"log"
"github.com/gofiber/fiber"
)
func main() {
// Fiber instance
app := fiber.New()
// Routes
app.Get("/", hello)
// Start server
log.Fatal(app.Listen(3000))
}
// Handler
func hello(c *fiber.Ctx) {
c.Send("Hello, World ????!")
}
在我运行脚本之前,我还确保使用 go get -u github.com/gofiber/fiber 安装框架。
然后运行 go run main.go 文件运行但它没有在我的本地主机上运行并告诉我它在 HOST[::] 上运行
我怎样才能使它在localhost 而不是HOST[::] 上运行。我试图查看它是否在我的本地主机上,但它根本不存在。
【问题讨论】: