随笔分类 -  software engineering / Golang

摘要:Before we embark on our journey through the world of pointers in Go, we must fist grasp the significance of the & operator. func main() { var i int = 阅读全文
posted @ 2025-02-28 17:12 Ashe|||^_^ 阅读(1) 评论(0) 推荐(0) 编辑
摘要:Known for its speed and small memory footprint, Gin is one of the most popular and widely used Go web frameworks. It provides features like routing, m 阅读全文
posted @ 2025-02-27 22:07 Ashe|||^_^ 阅读(2) 评论(0) 推荐(0) 编辑
摘要:首先往数据库插入数据,就需要连接数据库(笔者此处使用的是PostgreSQL) 因此在项目中引入如下依赖(这两个依赖版本号不一致,可能会出现异常) gorm.io/driver/postgres // 依赖是用于连接和操作 PostgreSQL 数据库 gorm.io/gorm // 对象关系映射 阅读全文
posted @ 2024-01-21 20:49 Ashe|||^_^ 阅读(78) 评论(0) 推荐(0) 编辑
摘要:前提:搭建好Golang环境 首先新建project,Goland会自动生成go.mod文件。 GOPROXY=https://proxy.golang.com.cn,direct // 设置官方镜像代理,阿里镜像代理实测过程中遇到了一些问题 下载并安装Gin框架,并将其添加到你的项目的Go模块中( 阅读全文
posted @ 2024-01-07 21:34 Ashe|||^_^ 阅读(67) 评论(0) 推荐(0) 编辑
摘要:闭包是指一个函数值(function value),它可以引用其函数体之外的变量 闭包代码示例 func makeSuffix() func(str string) string { var suffix = ".jpg" return func(str string) string { if st 阅读全文
posted @ 2023-10-31 21:03 Ashe|||^_^ 阅读(6) 评论(0) 推荐(0) 编辑
摘要:递归函数的两个特征 函数自己调用自己 一定存在某个条件来终止递归,以避免无限递归 func main() { // result is : 2 2 3 recursion(4) } func recursion(num int) { if num > 2 { num-- recursion(num) 阅读全文
posted @ 2023-10-30 23:55 Ashe|||^_^ 阅读(9) 评论(0) 推荐(0) 编辑
摘要:* * * * * * * * * * * * * * * * * * * * * * * * 需求:在控制台打印如上图所示的效果图 解题思路: 首先简化问题,用嵌套for循环打印出实心金字塔,由题可观察得知,层数与star(星号)数量保持着一定关系(奇数队列),1、3、5、7……2n-1 然后,格 阅读全文
posted @ 2023-10-30 22:01 Ashe|||^_^ 阅读(28) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示