日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

go语言基础到提高(3)-变量

發(fā)布時(shí)間:2025/3/12 编程问答 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 go语言基础到提高(3)-变量 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
package main import("fmt" ) func main(){var x intx=100var y int =100z:=100.11// z:=102.12 //error :=只能用于新變量,自動(dòng)推斷變量類型z=102.11var z2 float32 =99.99z2=100var z3 int =12//z3=13.55 //error:整數(shù)不能轉(zhuǎn)變成浮點(diǎn)數(shù),強(qiáng)類型語(yǔ)言fmt.Println("x:",x,"y:",y,"z:",z,"z2:",z2,"z3:",z3) }

x: 100 y: 100 z: 102.11 z2: 100 z3: 12

go語(yǔ)言數(shù)據(jù)類型
復(fù)數(shù)
type ComplexType
ComplexType is here for the purposes of documentation only. It is a stand-in for either complex type: complex64 or complex128.
浮點(diǎn)數(shù)

type FloatType
FloatType is here for the purposes of documentation only. It is a stand-in for either float type: float32 or float64.

整數(shù)
type IntegerType
IntegerType is here for the purposes of documentation only. It is a stand-in for any integer type: int, uint, int8 etc.

Type類型,任何go類型,但對(duì)于任何給定的函數(shù)調(diào)用,都代表相同的類型
type Type
Type is here for the purposes of documentation only. It is a stand-in for any Go type, but represents the same type for any given function invocation.

布爾
type bool
bool is the set of boolean values, true and false.

字節(jié)
type byte
byte is an alias for uint8 and is equivalent to uint8 in all ways. It is used, by convention, to distinguish byte values from 8-bit unsigned integer values.

type complex128
complex128 is the set of all complex numbers with float64 real and imaginary parts.

type complex64
complex64 is the set of all complex numbers with float32 real and imaginary parts.

錯(cuò)誤
type error
The error built-in interface type is the conventional interface for representing an error condition, with the nil value representing no error.

type error interface {
Error() string
}

type float32
float32 is the set of all IEEE-754 32-bit floating-point numbers.

type float64
float64 is the set of all IEEE-754 64-bit floating-point numbers.

type int
int is a signed integer type that is at least 32 bits in size. It is a distinct type, however, and not an alias for, say, int32.

type int16
int16 is the set of all signed 16-bit integers. Range: -32768 through 32767.

type int32
int32 is the set of all signed 32-bit integers. Range: -2147483648 through 2147483647.

type int64
int64 is the set of all signed 64-bit integers. Range: -9223372036854775808 through 9223372036854775807.

type int8
int8 is the set of all signed 8-bit integers. Range: -128 through 127.

rune是int32的別名,在所有方面都等同于int32。按照慣例,它用于區(qū)分字符值和整數(shù)值。
type rune
rune is an alias for int32 and is equivalent to int32 in all ways. It is used, by convention, to distinguish character values from integer values.

字符串
type string
string is the set of all strings of 8-bit bytes, conventionally but not necessarily representing UTF-8-encoded text. A string may be empty, but not nil. Values of string type are immutable.

無(wú)符號(hào)整數(shù)
type uint
uint is an unsigned integer type that is at least 32 bits in size. It is a distinct type, however, and not an alias for, say, uint32.

type uint16
uint16 is the set of all unsigned 16-bit integers. Range: 0 through 65535.

type uint32
uint32 is the set of all unsigned 32-bit integers. Range: 0 through 4294967295.

type uint64
uint64 is the set of all unsigned 64-bit integers. Range: 0 through 18446744073709551615.

type uint8
uint8 is the set of all unsigned 8-bit integers. Range: 0 through 255.

uintptr是一個(gè)整數(shù)類型,其大小足以容納任何指針的位模式。
type uintptr
uintptr is an integer type that is large enough to hold the bit pattern of any pointer.

package main import("fmt" ) func main(){x,y:=100,50var x1 int var x2 intx1,x2=100,11 fmt.Println("x1:",x1,"x2:",x2,"x:",x,"y:",y) } package main import("fmt" ) func main(){var (x1 boolx2 intx3 float32)x1=truex2=12x3=12.05fmt.Println(x1,x2,x3)}

true 12 12.05

package main import("fmt" ) func main(){ var y1,y2,y3 inty1=1y2=2y3=3fmt.Println(y1,y2,y3)} package main import("fmt" ) func main(){ var a1,a2,a3 inta1,a2,a3=11,22,33fmt.Println(a1,a2,a3)} 與50位技術(shù)專家面對(duì)面20年技術(shù)見(jiàn)證,附贈(zèng)技術(shù)全景圖

總結(jié)

以上是生活随笔為你收集整理的go语言基础到提高(3)-变量的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。