123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- // Basic Types
- package examples
- import (
- "fmt"
- "math"
- "math/cmplx"
- )
- var (
- ToBe bool = false
- Word string = "A Word"
- MaximumInt int = math.MaxInt32
- MinimumInt int = math.MinInt32
- MaximumInt8 int8 = math.MaxInt8
- MinimumInt8 int8 = math.MinInt8
- MaximumInt16 int16 = math.MaxInt16
- MinimumInt16 int16 = math.MinInt16
- MaximumInt64 int64 = math.MaxInt64
- MinimumInt64 int64 = math.MinInt64
- Uint8 uint8 = math.MaxUint8
- Uint16 uint16 = math.MaxUint16
- Uint32 uint32 = math.MaxUint32
- Uint64 uint64 = math.MaxUint64
- Byte byte = math.MaxUint8
- Rune rune = math.MaxInt32
- MaximumFloat32 float32 = math.MaxFloat32
- MinimumFloat32 float32 = math.SmallestNonzeroFloat32
- MaximumFloat64 float64 = math.MaxFloat64
- MinimumFloat64 float64 = math.SmallestNonzeroFloat64
- UintPtr uintptr = 0
- Z complex128 = cmplx.Sqrt(-5 + 12i)
- )
- func printTypeInfo(i interface{}) {
- fmt.Printf("Type: %T Value: %v\n", i, i)
- }
- func BasicTypes() {
- printTypeInfo(ToBe)
- printTypeInfo(Word)
- printTypeInfo(MaximumInt)
- printTypeInfo(MinimumInt)
- printTypeInfo(MaximumInt8)
- printTypeInfo(MinimumInt8)
- printTypeInfo(MaximumInt16)
- printTypeInfo(MinimumInt16)
- printTypeInfo(MaximumInt64)
- printTypeInfo(MinimumInt64)
- printTypeInfo(Uint8)
- printTypeInfo(Uint16)
- printTypeInfo(Uint32)
- printTypeInfo(Uint64)
- printTypeInfo(Byte)
- printTypeInfo(Rune)
- printTypeInfo(MaximumFloat32)
- printTypeInfo(MinimumFloat32)
- printTypeInfo(MaximumFloat64)
- printTypeInfo(MinimumFloat64)
- printTypeInfo(UintPtr)
- printTypeInfo(Z)
- }
|