初始化Go学习项目
This commit is contained in:
20
go-gin-demo/main.go
Normal file
20
go-gin-demo/main.go
Normal file
@@ -0,0 +1,20 @@
|
||||
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")
|
||||
}
|
||||
Reference in New Issue
Block a user