GO
文章平均质量分 76
Rantele
没有伞的孩子在雨中唯有奋力奔跑
展开
-
Go语言学习(3)
func函数是通过func关键字来声明的,基本结构如下:func funcName(input1 type1, input2 type2) (output1 type1, output2 type2) { //这里是处理逻辑代码 //返回多个值 return value1, value2}funcName是函数名如果有多个返回值,建议添加返回值变量名。变参:指定函数接收不定数量的参数。func funcName(arg ...int) {}arg ...in原创 2022-02-25 19:15:28 · 104 阅读 · 0 评论 -
Go语言学习(4)
type通过关键字type可以自定义类型package mainimport "fmt"//newint 是一个全新类型,但是它具有int类型的特性。type newint intfunc main() { var p newint fmt.Println(p)}输出:0Process finished with exit code 0类型别名:type rune = int32type byte = uint8struct通过关键字struct来定义一个结构体原创 2020-05-29 10:09:10 · 40 阅读 · 0 评论 -
Go语言学习(2)
ifif语句基本结构:if expre { //代码块} else if exper1 { //代码块} else { //代码块}先看个例子:package mainimport "fmt"func main() { x := 3 if x>5 { fmt.Printf("%d 大于 5",x) } else { fmt.Printf("%d 小于 5",x) }}输出:3 小于 5Process finished with exit code原创 2020-05-28 10:45:52 · 61 阅读 · 0 评论 -
Go语言学习(1)
Go语言起步——hello world1.创建项目,在项目入口(main函数中)package mainimport "fmt"func main() { fmt.Println("hello world!")}输出:hello world!Process finished with exit code 0字符串package mainimport "fmt"func main() { s := "hello" fmt.Println(s)}输出:hell原创 2020-05-26 14:34:41 · 67 阅读 · 0 评论