上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 51 下一页
摘要: // 实际上它是interface类型,这个类型有一个返回错误信息的单一方法: type error interface{ Error() string } 创建一个error最简单的方法就是调用errors.New函数,它会根据传入的错误信息返回一个新的error。整个errors包仅只有4行: 阅读全文
posted @ 2022-03-01 14:03 我在路上回头看 阅读(111) 评论(0) 推荐(0)
摘要: // 示例 // net/http package http type Handler interface{ ServeHTTP(w ResponseWriter, r *Request) } func ListenAndServe(address string, h Handler) error 阅读全文
posted @ 2022-03-01 13:47 我在路上回头看 阅读(161) 评论(0) 推荐(0)
摘要: 一个内置的排序算法需要知道三个东西:序列的长度,表示两个元素比较的结果,一种交换两个元素的方式;这就是sort.Interface的三个方法: package sort type Interface interface{ Len() int Less(i, j int) bool Swap(i, j 阅读全文
posted @ 2022-03-01 10:53 我在路上回头看 阅读(68) 评论(0) 推荐(0)
摘要: 1. 不管你的method的receiver是指针类型还是非指针类型,都是可以通过指针/非指针类型进行调用的, 编译器会帮你做类型转换 2.在声明一个method的receiver该是指针还是非指针类型时,你需要考虑两方面的因素, 第一方面是这个对象本身是不是特别大,如果声明为非指针变量时,调用会产 阅读全文
posted @ 2022-02-28 16:02 我在路上回头看 阅读(42) 评论(0) 推荐(0)
摘要: 参考文档 Gin: https://gin-gonic.com/zh-cn/docs/quickstart/ net/http: https://pkg.go.dev/net/http 代码分析 package main import ( "fmt" "time" // 时间包 "net/http" 阅读全文
posted @ 2022-02-27 22:59 我在路上回头看 阅读(298) 评论(0) 推荐(0)
摘要: 文档 https://github.com/go-ini/ini https://ini.unknwon.io/docs/intro/getting_started go get -u gopkg.in/ini.v1 阅读全文
posted @ 2022-02-27 20:31 我在路上回头看 阅读(92) 评论(0) 推荐(0)
摘要: 文档 https://learnku.com/docs/gorm/v2/v2_release_note/9756 https://gorm.cn/zh_CN/docs/ 下载安装 go get -u gorm.io/gorm go get -u gorm.io/driver/mysql 简单示例 p 阅读全文
posted @ 2022-02-27 03:37 我在路上回头看 阅读(489) 评论(0) 推荐(0)
摘要: 问题 // 创建一些目录,再将目录删除 // 错误写法 var rmdirs []func() for _, dir := range tempDirs() { os.MkdirAll(dir, 0755) rmdirs = append(rmdirs, func(){ os.RemoveAll(d 阅读全文
posted @ 2022-02-25 17:54 我在路上回头看 阅读(62) 评论(0) 推荐(0)
摘要: 数据类型可分为四类 基础类型 数字、字符串和布尔型 复合类型 数组、结构体 引用类型 指针、切片、map、函数、通道channel 接口类型 interface 阅读全文
posted @ 2022-02-25 10:43 我在路上回头看 阅读(32) 评论(0) 推荐(0)
摘要: """参考文档 https://apptainer.org/user-docs/master/build_a_container.html """ # 通过文件构建容器,相当于docker的Dockerfile ## 创建一个Singularity文件 >>> vim Singularity Boo 阅读全文
posted @ 2022-02-16 12:03 我在路上回头看 阅读(555) 评论(0) 推荐(0)
上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 51 下一页