比思論壇
標題:
GOlang基础入门01
[打印本頁]
作者:
scterl
時間:
2022-12-21 21:09
標題:
GOlang基础入门01
[size=0.92857em]25个关键字
[size=0.92857em]
[size=0.92857em]break
[size=0.92857em]default
[size=0.92857em]func
[size=0.92857em]interface
[size=0.92857em]select
[size=0.92857em]
[size=0.92857em]case
[size=0.92857em]defer
[size=0.92857em]go
[size=0.92857em]map
[size=0.92857em]struct
[size=0.92857em]
[size=0.92857em]chan
[size=0.92857em]else
[size=0.92857em]goto
[size=0.92857em]package
[size=0.92857em]switch
[size=0.92857em]
[size=0.92857em]const
[size=0.92857em]fallthrough
[size=0.92857em]if
[size=0.92857em]range
[size=0.92857em]type
[size=0.92857em]
[size=0.92857em]continue
[size=0.92857em]for
[size=0.92857em]import
[size=0.92857em]return
[size=0.92857em]var
[size=0.92857em][size=0.92857em]
[size=0.92857em][size=0.92857em]37个保留字
[size=0.92857em]
[size=0.92857em]Constants
[size=0.92857em]:
[size=0.92857em]true
[size=0.92857em]false
[size=0.92857em]iota
[size=0.92857em]nil
[size=0.92857em]
[size=0.92857em]Types
[size=0.92857em]:
[size=0.92857em]int
[size=0.92857em]int8
[size=0.92857em]int16
[size=0.92857em]int32
[size=0.92857em]int64
[size=0.92857em]
[size=0.92857em]uint
[size=0.92857em]uint8
[size=0.92857em]uint16
[size=0.92857em]uint32
[size=0.92857em]uint64
[size=0.92857em]uintptr
[size=0.92857em]
[size=0.92857em]float32
[size=0.92857em]float64
[size=0.92857em]complex128
[size=0.92857em]complex64
[size=0.92857em]
[size=0.92857em]bool
[size=0.92857em]byte
[size=0.92857em]rune
[size=0.92857em]string
[size=0.92857em]error
[size=0.92857em]
[size=0.92857em]Functions
[size=0.92857em]:
[size=0.92857em]make
[size=0.92857em]len
[size=0.92857em]cap
[size=0.92857em]new
[size=0.92857em]append
[size=0.92857em]copy
[size=0.92857em]close
[size=0.92857em]delete
[size=0.92857em]
[size=0.92857em]complex
[size=0.92857em]real
[size=0.92857em]imag
[size=0.92857em]
[size=0.92857em]panic recover
[size=0.92857em]函数体外必须使用关键字开头
[size=0.92857em]标准声明
[size=0.92857em]var 变量名 变量类型
[size=0.92857em]var name string
[size=0.92857em]批量声明
[size=0.92857em]var (
[size=0.92857em] name string
[size=0.92857em])
[size=0.92857em]声明并赋值
[size=0.92857em]var name string = "niekx"
[size=0.92857em]类型推导
[size=0.92857em]var name = "niex"
[size=0.92857em]短变量声明(只能用在函数体中)
[size=0.92857em]m := 10
[size=0.92857em]匿名变量,短下划线去接收
[size=0.92857em]
[size=0.92857em]func
[size=0.92857em]foo
[size=0.92857em](
[size=0.92857em])
[size=0.92857em](
[size=0.92857em]int
[size=0.92857em],
[size=0.92857em]string
[size=0.92857em])
[size=0.92857em]{
[size=0.92857em]
[size=0.92857em]return
[size=0.92857em]10
[size=0.92857em],
[size=0.92857em]"Q1mi"
[size=0.92857em]}
[size=0.92857em]
[size=0.92857em]func
[size=0.92857em]main
[size=0.92857em](
[size=0.92857em])
[size=0.92857em]{
[size=0.92857em]
[size=0.92857em]x
[size=0.92857em],
[size=0.92857em]_
[size=0.92857em]:=
[size=0.92857em]foo
[size=0.92857em](
[size=0.92857em])
[size=0.92857em]
[size=0.92857em]_
[size=0.92857em],
[size=0.92857em]y
[size=0.92857em]:=
[size=0.92857em]foo
[size=0.92857em](
[size=0.92857em])
[size=0.92857em]
[size=0.92857em]fmt
[size=0.92857em].
[size=0.92857em]Println
[size=0.92857em](
[size=0.92857em]"x="
[size=0.92857em],
[size=0.92857em]x
[size=0.92857em])
[size=0.92857em]
[size=0.92857em]fmt.Println("y=", y)
[size=0.92857em][size=0.92857em]}
[size=0.92857em]常量:const,常量定义的时候必须赋值
[size=0.92857em]iota
[size=0.92857em]iota
是go语言的常量计数器,只能在常量的表达式中使用。
[size=0.92857em]
[size=0.92857em]iota
在const关键字出现时将被重置为0。const中每新增一行常量声明将使
[size=0.92857em]iota
计数一次(iota可理解为const语句块中的行索引)。 使用iota能简化定义,在定义枚举时很有用。
[size=0.92857em]
[size=0.92857em]
[size=0.92857em]const
[size=0.92857em](
[size=0.92857em]
[size=0.92857em]n1
[size=0.92857em]=
[size=0.92857em]iota
[size=0.92857em]//0
[size=0.92857em]
[size=0.92857em]n2
[size=0.92857em]//1
[size=0.92857em]
[size=0.92857em]n3
[size=0.92857em]//2
[size=0.92857em]
[size=0.92857em]n4
[size=0.92857em]//3
[size=0.92857em][size=0.92857em])
作者:
zhoukun813
時間:
2023-11-7 20:15
提示:
作者被禁止或刪除 內容自動屏蔽
作者:
penny0594
時間:
2023-11-10 20:20
提示:
作者被禁止或刪除 內容自動屏蔽
作者:
15535308335
時間:
2023-11-12 04:53
提示:
作者被禁止或刪除 內容自動屏蔽
作者:
b44297689
時間:
2023-11-12 23:36
提示:
作者被禁止或刪除 內容自動屏蔽
作者:
xzx7788
時間:
2023-11-15 00:52
提示:
作者被禁止或刪除 內容自動屏蔽
作者:
305819816
時間:
2024-3-18 05:02
逼逼还是很嫩的!
歡迎光臨 比思論壇 (http://108.170.5.101/)
Powered by Discuz! X2.5