Gaaker Go

Golang Basic Types

Go has various value types including string, numeric, boolean, etc.

The string is wrapped in double quotes. It has the form: “hello go”.

Numbers include integer and float, depending on the storage size.

  • Integers have types such as int, int8, int16, int32, int64, etc.
  • Floats have types such as float32, float64, etc.

Boolean (bool) has two possible values, true and false.

The following is a complete code example.

package main

import "fmt"

func main() {

    // %T is the type placeholder
    fmt.Printf("type: %T\n", "golang")
    fmt.Printf("type: %T\n", 1)
    fmt.Printf("type: %T\n", 1.1)
    fmt.Printf("type: %T\n", true)

Below is the program output:

type: string
type: int
type: float64
type: bool
< Basic Types Basic Types >