ref: fd938c57659714f5466e7c294cd5875e2778a41b a-tour-of-go/basics/packages-variables-functions/1.1.14_type-inference.go -rw-r--r-- 434 bytes View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
	Notes 1.1.14

	- In Go, if you don't specify a type explicitly when delcaring a variable,
	  the type will be inferred.
	- If the variable's initialization value is an untyped numeric constant,
	  the new variable may be an int, float64, or complex128 depending on the precision.
*/

package main

import "fmt"

func main() {
	v := 42 // change this (example values: 42, 3.142, 0.867 + 0.5i)
	fmt.Printf("v is of type %T\n", v)
}