摘要: package main import ( "errors" "fmt" ) type Queue struct { maxSize int array [5]int front int rear int } //添加队列 func (q *Queue) AddQueue(val int) (err 阅读全文
posted @ 2022-06-13 10:52 司砚章 阅读(34) 评论(0) 推荐(0) 编辑
摘要: login.go package main import "fmt" func login(userId int, userPwd string) (err error) { fmt.Printf("userId=%d userPwd=%s\n", userId, userPwd) return n 阅读全文
posted @ 2022-06-13 10:49 司砚章 阅读(267) 评论(0) 推荐(0) 编辑
摘要: ![image](https://img2022.cnblogs.com/blog/2140721/202203/2140721-20220306095256181-1145825589.png) 阅读全文
posted @ 2022-06-13 10:48 司砚章 阅读(52) 评论(0) 推荐(0) 编辑
摘要: Redis 命令参考 Redis 命令参考 — Redis 命令参考 Set Get 字符串 package main import ( "fmt" "github.com/garyburd/redigo/redis" ) func main() { conn, err := redis.Dial( 阅读全文
posted @ 2022-06-13 10:48 司砚章 阅读(57) 评论(0) 推荐(0) 编辑
摘要: goroutine package main import ( "fmt" "strconv" "time" ) func test() { for i := 1; i <= 10; i++ { fmt.Println("test () hello world" + strconv.Itoa((i) 阅读全文
posted @ 2022-06-13 10:47 司砚章 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 测试之前一定要把360关闭 package demo func addUpper(n int) int { res := 0 for i := 1; i <= n-1; i++ { res += i } return res } package demo import "testing" func 阅读全文
posted @ 2022-06-13 10:47 司砚章 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 综合案例 package main import ( "encoding/json" "fmt" "io/ioutil" ) type Monster struct { Name string Age int Skill string } func (m *Monster) Store() bool 阅读全文
posted @ 2022-06-13 10:47 司砚章 阅读(53) 评论(0) 推荐(0) 编辑
摘要: 命令行参数基本使用 package main import ( "fmt" "os" ) func main() { fmt.Println("命令行的参数有", len(os.Args)) for i, v := range os.Args { fmt.Printf("args[%v]=%v\n" 阅读全文
posted @ 2022-06-13 10:36 司砚章 阅读(148) 评论(0) 推荐(0) 编辑
摘要: JSon json数据在线解析 https://www.json.cn/ 结构体 map 切片 序列化 结构体序列化 package main import ( "encoding/json" "fmt" ) type Monster struct { Name string Age int Bir 阅读全文
posted @ 2022-06-13 10:36 司砚章 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 指定结构体的tag标签 package main import ( "encoding/json" "fmt" ) type Monster struct { Name string `json:"moster_name"` Age int `json:"moster_age"` Birthday 阅读全文
posted @ 2022-06-13 10:36 司砚章 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 将一个文件内容写入到另一个文件 package main import ( "fmt" "io/ioutil" ) func main() { file1Path := "C:/Users/pc/Desktop/1.txt" file2Path := "C:/Users/pc/Desktop/2.t 阅读全文
posted @ 2022-06-13 10:32 司砚章 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 协程求素数 package main import ( "fmt" "time" ) func putNum(intChan chan int) { for i := 1; i <= 8000; i++ { intChan <- i //fmt.Println("写入数据", i) } close( 阅读全文
posted @ 2022-06-13 10:32 司砚章 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 前言 Go 是一门简单有趣的编程语言,与其他语言一样,在使用时不免会遇到很多坑,不过它们大多不是 Go 本身的设计缺陷。如果你刚从其他语言转到 Go,那这篇文章里的坑多半会踩到。 如果花时间学习官方 doc、wiki、讨论邮件列表、 Rob Pike 的大量文章以及 Go 的源码,会发现这篇文章中的 阅读全文
posted @ 2022-06-13 10:32 司砚章 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 打开文件 关闭文件 package main import ( "fmt" "os" ) func main() { file, err := os.Open("C:/Users/pc/Desktop/1.txt") if err != nil { fmt.Println("err=", err) 阅读全文
posted @ 2022-06-13 10:31 司砚章 阅读(23) 评论(0) 推荐(0) 编辑
摘要: ![image](https://img2022.cnblogs.com/blog/2140721/202201/2140721-20220126212628398-1107615227.png) 阅读全文
posted @ 2022-06-13 10:31 司砚章 阅读(22) 评论(0) 推荐(0) 编辑