随笔分类 -  GO

摘要: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 司砚章 阅读(40) 评论(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 司砚章 阅读(309) 评论(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 司砚章 阅读(62) 评论(0) 推荐(0) 编辑
摘要:![image](https://img2022.cnblogs.com/blog/2140721/202203/2140721-20220306095256181-1145825589.png) 阅读全文
posted @ 2022-06-13 10:48 司砚章 阅读(53) 评论(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 司砚章 阅读(23) 评论(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 司砚章 阅读(21) 评论(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 司砚章 阅读(63) 评论(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 司砚章 阅读(152) 评论(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 司砚章 阅读(26) 评论(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 司砚章 阅读(131) 评论(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 司砚章 阅读(16) 评论(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 司砚章 阅读(31) 评论(0) 推荐(0) 编辑
摘要:前言 Go 是一门简单有趣的编程语言,与其他语言一样,在使用时不免会遇到很多坑,不过它们大多不是 Go 本身的设计缺陷。如果你刚从其他语言转到 Go,那这篇文章里的坑多半会踩到。 如果花时间学习官方 doc、wiki、讨论邮件列表、 Rob Pike 的大量文章以及 Go 的源码,会发现这篇文章中的 阅读全文
posted @ 2022-06-13 10:32 司砚章 阅读(170) 评论(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 司砚章 阅读(24) 评论(0) 推荐(0) 编辑
摘要:![image](https://img2022.cnblogs.com/blog/2140721/202201/2140721-20220126212628398-1107615227.png) 阅读全文
posted @ 2022-06-13 10:31 司砚章 阅读(27) 评论(0) 推荐(0) 编辑
摘要:![image](https://img2022.cnblogs.com/blog/2140721/202201/2140721-20220124195653227-524878986.png) 阅读全文
posted @ 2022-06-11 10:27 司砚章 阅读(43) 评论(0) 推荐(0) 编辑
摘要:记账软件 面向对象 main.go package main import ( "fmt" "go_code/family/utils" ) func main() { fmt.Println("这个是面向对象的方式完成~") utils.NewFamilyAccount().MainMenu() 阅读全文
posted @ 2022-06-11 10:25 司砚章 阅读(38) 评论(0) 推荐(0) 编辑
摘要:程序框架 服务器server.go package main import ( "fmt" "net" ) func process(conn net.Conn) { defer conn.Close() for { buf := make([]byte, 1024) fmt.Printf("服务器 阅读全文
posted @ 2022-06-11 10:24 司砚章 阅读(142) 评论(0) 推荐(0) 编辑
摘要:channel管道 package main import "fmt" func main() { intChan := make(chan int, 3) fmt.Printf("intChan的值%v intChan本身的地址%p\n", intChan, &intChan) intChan < 阅读全文
posted @ 2022-06-11 10:24 司砚章 阅读(19) 评论(0) 推荐(0) 编辑
摘要:反射的示意图 案例1 package main import ( "fmt" "reflect" ) func reflectTest01(b interface{}) { //通过反射获取传入变量的type kind value rTyp := reflect.TypeOf(b) fmt.Prin 阅读全文
posted @ 2022-06-11 10:23 司砚章 阅读(29) 评论(0) 推荐(0) 编辑

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