Files
learn-golang/go-gin-demo/main.go
2025-12-26 17:56:02 +08:00

21 lines
341 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import (
"github.com/gin-gonic/gin"
)
func main() {
// 创建 Gin 引擎(类似 Spring 的 ApplicationContext
r := gin.Default()
// 注册路由和处理器
r.GET("/hello", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "Hello, Gin!",
})
})
// 启动服务器,监听 8080 端口
r.Run(":8080")
}