随笔分类 -  Go/Golang

摘要:一、读取小文件:ioutil.ReadFile() 读取文件的内容并显示在终端(使用ioutil一次将文件读取到内存中),这种方式适用于读取小文件: package main import ( "fmt" "io/ioutil" ) func main(){ content, error := io 阅读全文
posted @ 2022-11-20 22:01 ricnman 阅读(251) 评论(0) 推荐(0) 编辑
摘要:一、方法 1、方法是作用在指定的数据类型上,和指定的数据类型绑定,因此自定义类型都可以有方法,而不仅仅是struct; 2、方法的申明和格式调用: package main import ( "fmt" ) type Person struct{ Name string } func (p Pers 阅读全文
posted @ 2022-11-19 22:57 ricnman 阅读(187) 评论(0) 推荐(0) 编辑
摘要:fmt 包的介绍 fmt = format,是一种格式化输出函数汇总包,用于格式化输出 fmt.Print 原样输出 Print formats using the default formats for its operands and writes to standard output. 原样输 阅读全文
posted @ 2022-10-24 22:43 ricnman 阅读(290) 评论(0) 推荐(0) 编辑
摘要:数据类型: 值类型:int、float、bool、string、array、结构体 引用类型:slice、map、function、pointer 格式化字符串 Go 语言中使用 fmt.Sprintf 格式化字符串并赋值给新串: package main import ( "fmt" ) func 阅读全文
posted @ 2022-10-22 22:24 ricnman 阅读(36) 评论(0) 推荐(0) 编辑

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