
2 min read
Architecture-specific Numeric Types
In addition to the architecture-independent numeric types, Go provides three architecture-specific numeric types. Although there are far fewer of them, they often get a lot more usage. Numeric Types … There is also a set of predeclared integer types with implementation-specific sizes: uint either 32 or 64 bits int same size as uint uintptr an unsigned integer large enough to store the uninterpreted bits of a pointer value What does it mean for a type’s size to be architecture-dependent?

2 min read
Architecture-independent Numeric Types
Go provides several predeclared numeric types. Most of them have a fixed size, regardless of the architecture the program is compiled for or running on. Numeric Types An integer, floating-point, or complex type represents the set of integer, floating-point, or complex values, respectively. They are collectively called numeric types. The predeclared architecture-independent numeric types are: uint8 the set of all unsigned 8-bit integers (0 to 255) uint16 the set of all unsigned 16-bit integers (0 to 65535) uint32 the set of all unsigned 32-bit integers (0 to 4294967295) uint64 the set of all unsigned 64-bit integers (0 to 18446744073709551615) int8 the set of all signed 8-bit integers (-128 to 127) int16 the set of all signed 16-bit integers (-32768 to 32767) int32 the set of all signed 32-bit integers (-2147483648 to 2147483647) int64 the set of all signed 64-bit integers (-9223372036854775808 to 9223372036854775807) float32 the set of all IEEE-754 32-bit floating-point numbers float64 the set of all IEEE-754 64-bit floating-point numbers complex64 the set of all complex numbers with float32 real and imaginary parts complex128 the set of all complex numbers with float64 real and imaginary parts byte alias for uint8 rune alias for int32 The value of an n-bit integer is n bits wide and represented using two’s complement arithmetic.

1 min read
Boolean types
Boolean types A boolean type represents the set of Boolean truth values denoted by the predeclared constants true and false. The predeclared boolean type is bool; it is a defined type. No real surprises here. Go supports Boolean types. You can use the pre-declared Boolean type bool, or you can create your own types, backed by this type: type SpanishBool bool For an example why this might be useful, see my previous example.

2 min read
Predeclared types
Types The language predeclares certain type names. Others are introduced with type declarations or type parameter lists. Composite types—array, struct, pointer, function, interface, slice, map, and channel types—may be constructed using type literals. Type declarations, type parameter lists, and type aliases are coming up later, so today we’re focused on the predeclared types. The list of predclared types would appear near the beginning of most intro to Go books (I would know, I just read and reviewed 11 of them!

1 min read
Type literals
After a long-winded post yesterday, here’s a shorter one to breeze through… Types … A type may also be specified using a type literal, which composes a type from existing types. Type = TypeName [ TypeArgs ] | TypeLit | "(" Type ")" . TypeName = identifier | QualifiedIdent . TypeArgs = "[" TypeList [ "," ] "]" . TypeList = Type { "," Type } . TypeLit = ArrayType | StructType | PointerType | FunctionType | InterfaceType | SliceType | MapType | ChannelType .
6 min read
Book Review: For the Love of Go
For the absolute beginner to programming, this book will get you started on the right foot.

2 min read
Types, named and unnamed
Types A type determines a set of values together with operations and methods specific to those values. A type may be denoted by a type name, if it has one, which must be followed by type arguments if the type is generic. (and jumping ahead a bit) Predeclared types, defined types, and type parameters are called named types. An alias denotes a named type if the type given in the alias declaration is a named type.
Subscribe to Boldly Go: Daily
Every day I'll send you advice to improve your understanding of Go. Don't miss out! I will respect your inbox, and honor my privacy policy.
Unsure? Browse the archive.
6 min read
Book Review: Get Programming with Go
Written for the absolute beginner, this book will leave most wanting much more.

3 min read
Reader Question: Understanding (*T)(nil) syntax
I got a great email from a reader (I didn’t ask their permission to share, so keeping it anonymous) in response to last week’s message Interface variables, pointing out the somewhat essoteric syntax mentioned at the end of the example section: x = v // x has value (*T)(nil) and dynamic type *T The (*T)(nil) syntax is easily confusing. It has been for me, too. So let’s dig into that, and hopefully quell that confusion, once and for all!

2 min read
Variables and zero values
Variables A variable’s value is retrieved by referring to the variable in an expression; it is the most recent value assigned to the variable. If a variable has not yet been assigned a value, its value is the zero value for its type. The zero value is covered in greater detail near the end of the spec, but it’s an important concept, so let’s discuss it a bit here.