-
Golang error: “scannable dest type ptr with >1 columns (4) in result”
项目中的dao层,我们用来查询数据库,获取想要数据。有时我们会需要查询数据给结构体赋值,并返回一个结构体指针,如下 func GetCommunityDetailByID(id int64……
Ne-21 2022-12-17
197 0 0 -
Golang 中 Fscanf读取二维数组的坑
二维数组 6 5 0 1 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 1 0 0 0 1 0 0 1 0 1 0 0 0 问题代码 func TestReadFile(t *testing.T) { file, err := os.Open("m……
Ne-21 2022-12-14
186 0 0 -
Golang中的反射
前言 反射在很多语言中都有其妙用。在计算机科学领域,反射是指一类应用,它们能够自描述和自控制。 反射的简介 Golang提供了一种机制,在编译时不知道类型的……
Ne-21 2022-03-29
467 0 0 -
如何将Go程序编译至OpenWRT
前言 通常而言,OpenWRT 对应的都是一个路由器,先不考虑在上面安装常用的脚本语言(如 Python)的复杂度,即使能够安装,也需要占据大量的空间,并且由于其性……
Ne-21 2022-03-21
554 0 0 -
Golang获取网络图片并返回给前端二进制流
获取网络图片并返回给前端二进制流,前端通过axios下载该图片二进制流,实现下载图片功能 后端: func Download(c *gin.Context) { picName := c.Default……
Ne-21 2022-01-28
893 0 0 -
Golang 框架 Gin 踩坑笔记-跨域问题
前后端分离,后端使用Gin,POST的接口老是OPTIONS返回404,用postman测试接口正常,最后发现,跨域中间键一定要在你路由组(group)之前全局使用,最好在gin.D……
Ne-21 2022-01-27
355 0 0 -
Golang – 反射的最佳实践
/** * @Author: Ne-21 * @Description: 反射的最佳实践 * @File: example1 * @Version: 1.0.0 * @Date: 2022/1/7 14:38 */ package main import ( ……
Ne-21 2022-01-07
374 0 0 -
Golang – 管道与协程求素数
/** * @Author: Ne-21 * @Description: 求1-8000素数 * @File: case2 * @Version: 1.0.0 * @Date: 2022/1/6 15:56 */ package main import ( &qu……
Ne-21 2022-01-06
402 0 0 -
Golang – 接口编程的最佳实践
func Sort(data Interface) type Interface interface { // Len is the number of elements in the collection. Len() int // Less reports whet……
Ne-21 2022-01-03
424 0 0 -
Go的时间格式化为什么是2006-01-02 15:04:05?
今天看了golang的时间和日期函数,发现了一个奇葩的问题,Golang的时间格式化的参考时间是2006-01-02 15:04:05 官方文档给的说明是这样的(说了又好像没说): ……
Ne-21 2021-12-29
481 0 0