上一页 1 2 3 4 5 6 ··· 96 下一页
摘要: func PathExists(path string)(bool,error){ _,err := os.Stat(path) if err ==nil{ return true,nil } if os.IsNotExist(err){ return false,nil } return fals 阅读全文
posted @ 2021-01-29 16:53 超级学渣渣 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 常用的几种模式: O_RDONLY int = syscall.O_RDONLY // 只读模式 O_WRONLY int = syscall.O_WRONLY // 只写模式 O_RDWR int = syscall.O_RDWR // 读写模式 O_APPEND int = syscall.O_ 阅读全文
posted @ 2021-01-29 11:25 超级学渣渣 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 文件的读入 1 使用bufio.NewReader( *File) 2 使用 ioutile.readFile(fileName)一次性的读入整个文件 阅读全文
posted @ 2021-01-29 11:22 超级学渣渣 阅读(1151) 评论(0) 推荐(0) 编辑
摘要: 不是很明白类型断言干嘛用的,现在看来的话,可以用来做类型判断,先做个笔记 来一个小例子 package main import "fmt" type Usb interface{ start() stop() } type Phone struct { } type Caramera struct 阅读全文
posted @ 2021-01-27 21:25 超级学渣渣 阅读(361) 评论(0) 推荐(0) 编辑
摘要: 利用接口实现多态。因为实现了接口的类型,可以被接口指向 例如,我们有 Phone和Camera两个类型,都实现了Usb接口。如上可以实现多态 另一种实现多态的方式是通过多态数组 阅读全文
posted @ 2021-01-27 14:55 超级学渣渣 阅读(139) 评论(0) 推荐(0) 编辑
摘要: go可以利用切片,实现自定义的排序 1 声明一个切片类型 2 对切片类型绑定 Len Less Swap三个方法 3 调用sort.Sort方法 package main import ( "fmt" "math/rand" "sort" "strconv" "time" ) type Studen 阅读全文
posted @ 2021-01-27 11:17 超级学渣渣 阅读(366) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2021-01-26 20:03 超级学渣渣 阅读(75) 评论(0) 推荐(0) 编辑
摘要: 接口的定义 接口的基本语法 阅读全文
posted @ 2021-01-26 19:54 超级学渣渣 阅读(83) 评论(0) 推荐(0) 编辑
摘要: go的继承通过嵌套匿名结构体实现 结构体中的的字段如果是基本类型,那么有且只能有一个,如果有多个,就需要命名 阅读全文
posted @ 2021-01-26 17:00 超级学渣渣 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 封装的实现 这样person3 就可以在其他包访问,并且只有Name可以直接访问 阅读全文
posted @ 2021-01-25 22:29 超级学渣渣 阅读(92) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 96 下一页