package main
import "fmt"
//int, uint, int8, uint8
//string
//float32, float64
//bool
//complex64, complex128
func main(){
fmt.Printf("Value: %v, Type: %T\n", "Hello", "Hello")
fmt.Printf("Value: %v, Type: %T\n", 8, 8)
fmt.Printf("Value: %v, Type: %T\n", uint(9), uint(9))
fmt.Printf("Value: %v, Type: %T\n", int8(6), int8(6))
fmt.Printf("Value: %v, Type: %T\n", true, true)
fmt.Printf("Value: %v, Type: %T\n", 4.1, 4.1)
fmt.Printf("Value: %v, Type: %T\n", (1 + 5i), (1 + 5i))
}
OutPut:
=========
$go run primitive_types.go
Value: Hello, Type: string
Value: 8, Type: int
Value: 9, Type: uint
Value: 6, Type: int8
Value: true, Type: bool
Value: 4.1, Type: float64
Value: (1+5i), Type: complex128
$
import "fmt"
//int, uint, int8, uint8
//string
//float32, float64
//bool
//complex64, complex128
func main(){
fmt.Printf("Value: %v, Type: %T\n", "Hello", "Hello")
fmt.Printf("Value: %v, Type: %T\n", 8, 8)
fmt.Printf("Value: %v, Type: %T\n", uint(9), uint(9))
fmt.Printf("Value: %v, Type: %T\n", int8(6), int8(6))
fmt.Printf("Value: %v, Type: %T\n", true, true)
fmt.Printf("Value: %v, Type: %T\n", 4.1, 4.1)
fmt.Printf("Value: %v, Type: %T\n", (1 + 5i), (1 + 5i))
}
OutPut:
=========
$go run primitive_types.go
Value: Hello, Type: string
Value: 8, Type: int
Value: 9, Type: uint
Value: 6, Type: int8
Value: true, Type: bool
Value: 4.1, Type: float64
Value: (1+5i), Type: complex128
$
No comments:
Post a Comment