go 初使用

时间:2023-03-10 05:55:49
go 初使用
hello.go

package main
import "fmt"
func main(){
fmt.Println("hello world")
直接运行

shiyanlou:~/ $ go run hello.go 
hello world


生成二进制文件运行
shiyanlou:~/ $ go build hello.go
shiyanlou:~/ $ ./hello.go
hello world
  // Go 将自动推断已经初始化的变量类型。//初始化用=,类型自动判断为bool
1. var d = true
fmt.Println(d)
->true
2. 新变量申明 :=
e:=false
fmt.Println(d)
3. 标准形式
var f string=“this is a test"
fmt.Println(f)