06_go language foundation

 
 // more than 06 variables or constants defined 
package main
 
import (
	"fmt"
)
 
func main() {
 
	// define different types of variables 
	var a int
	where b float64 
	a, b = 10, 4.2
	fmt.Println("a=", a)
	fmt.Println("b=", b)
 
	// declare variables of different types (definitions) 
	// var A Int   
	// var b float64
	// the variable definition must be used 
	// was (  
	// 	c int
	// 	d float64
	// )
	// c = 90
	// fmt.Println("c=", c)
	// d = 100.1
	// fmt.Println("d=", d)
 
	// here automatically deduce the type of variables can not write: No. 
	was ( 
		c = 67
		d = 44
	)
 
	fmt.Println("c=", c)
	fmt.Println("d=", d)
 
	// defined constants 
	// After constant defines the back may not be used 
	// const (
	// i int = 100 	   
	// j int = 50 	   
	// )
 
	// can also be used to derive automatic type 
	const (
		i = 100
		j = 50
	)
	fmt.Println(j)
}

Guess you like

Origin www.cnblogs.com/YLlang/p/11005655.html