摘要: 01背包 01背包模板 func zeroOneKnapsack(weights []int, values []int, capacity int) int { n := len(weights) // dp[i][j] 表示:考虑前 i 个物品(索引从 0 到 i-1),容量为 j 时的最大价值 阅读全文
posted @ 2025-08-01 16:34 wushucan 阅读(3) 评论(0) 推荐(0)
摘要: go读取yaml文件配置 config.yaml文件如下 mysql: host: localhost port: 3306 username: myuser password: mypassword database: mydatabase 读取 package main import ( "gi 阅读全文
posted @ 2024-06-16 15:08 wushucan 阅读(21) 评论(0) 推荐(0)
摘要: gorm的使用 type User struct { gorm.Model Name string Age int Sex bool } func main() { db, err := gorm.Open("mysql", "root:password@/dbname?charset=utf8&p 阅读全文
posted @ 2024-05-03 17:00 wushucan 阅读(6) 评论(0) 推荐(0)
摘要: gorm 连接数据库和创建或更新表 type User struct { gorm.Model Name string Age int Sex bool } func main() { db, err := gorm.Open("mysql", "root:password@/dbname?char 阅读全文
posted @ 2024-05-03 16:43 wushucan 阅读(11) 评论(0) 推荐(0)
摘要: 路由分组 v1 := router.Group("/v1") { v1.POST("/login", loginEndpoint) v1.POST("/submit", submitEndpoint) v1.POST("/read", readEndpoint) } v2 := router.Gro 阅读全文
posted @ 2024-05-01 10:48 wushucan 阅读(14) 评论(0) 推荐(0)
摘要: get和post混合取参数 ginServer.POST("/post", func(c *gin.Context) { id := c.Query("id") page := c.DefaultQuery("page", "0") name := c.PostForm("name") messag 阅读全文
posted @ 2024-04-30 16:38 wushucan 阅读(14) 评论(0) 推荐(0)
摘要: 加载网页文件夹和加载静态资源 文件路径: <link rel="stylesheet" href="/static/css/style.css"> <script src="/static/js/common.js"></script> //加载网页文件夹 ginServer.LoadHTMLGlo 阅读全文
posted @ 2024-04-30 11:23 wushucan 阅读(8) 评论(0) 推荐(0)
摘要: 下载gin失败 解决办法: cmd输入 go env -w GO111MODULE=on go env -w GOPROXY=https://goproxy.io,direct 即可安装gin包 go get github.com/gin-gonic/gin goland中go.mod的requir 阅读全文
posted @ 2024-04-24 23:28 wushucan 阅读(11) 评论(0) 推荐(0)