跳到主要内容

Hello World 示例

Github StackBlitz

本项目演示了一个使用 Go 语言中的 Fiber 框架构建的简单“Hello, World!”应用。

先决条件

请确保已安装以下软件

设置

  1. 克隆仓库

    git clone https://github.com/gofiber/recipes.git
    cd recipes/hello-world
  2. 安装依赖

    go get

运行应用

  1. 启动应用

    go run main.go
  2. 通过 http://localhost:3000 访问应用。

示例

以下是 Fiber 应用的 main.go 示例文件

package main

import (
"log"
"github.com/gofiber/fiber/v2"
)

func main() {
app := fiber.New()

app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello, World!")
})

log.Fatal(app.Listen(":3000"))
}

参考