GO 二、類型跟變量
Type
- Gerenal Value Type
- bool
- int/unit
- int8/unit8
- byte/unit8
- int16/uint16
- int32/rune
- int64/uint64
- float32/float64
- complex64/complex128
- uintptr (保存指針)
- Others Value Type
- array
- struct
- string
- Reference Type
- slice
- map (key-value)
- chan (通道)
- interface Type
- func Type
Declarations
var a int
a= 123
var a int =321
var c = 321
d := 456
//忽略
a,_,c,d := 1,2,3,4
轉換
var a float32 =3.14
b:= int(a)
數字轉文字需要導入strconv
import (
"strconv"
)
var a int = 65
b := strconv.Itoa(a)
// <-->Atoi is int conveter to string.
enum
use itoa , 0,1,2,3
const {
Mon = itoa
Tue
Wed
Thu
}
const {
_ = itoa
KB float64 = 1 << (itoa*10)
MB
GB
TB
}