提交 3f15fdd5 编写于 作者: _Fighter's avatar _Fighter

add

上级 b2707399
package main
import "fmt"
/*此处不能使用 := 来定义变量
go 语言都中包内变量,go 没有全局变量
函数包变量可以不使用,
*/
var xx =3
var ss =100
/*统一定义变量*/
var(
x1=23
x2=true
x3=323.23
)
func variableZeroValue() {
/*函数内部变量必须被使用*/
var a int
var s string
fmt.Printf("%d %q\n", a, s)
}
func variableInitialValue() {
var a ,b int = 3,4
var s string = "abc"
fmt.Println(a,b, s)
}
func variableTypeDeduction() {
var x ,b ,c,e,f = 3.23,4,"abdad",true, 4.54
fmt.Println(x,b,f+1, c,e)
}
func variableShorter() {
/*
不使用 var
第一次定义变量可以使用:=,但是只能在函数内部使用,外部不能使用
*/
x ,b ,c,e,f := 3.23,4,"abdad",true, 4.54
fmt.Println(x,b,f+1, c,e)
}
func main() {
variableZeroValue()
variableInitialValue()
variableTypeDeduction()
variableShorter()
fmt.Println(x1,x2,x3)
}
package main
import (
"fmt"
"runtime"
)
func main() {
fmt.Println("hello world!")
fmt.Println(runtime.GOARCH)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册