Go Gopher How to Go

Values in Go cover numbers, strings, booleans, and compound types. They are the building blocks you combine to model data.

💡 Key Points

  • Strings concatenate with +; numbers use arithmetic operators.
  • Booleans support the usual logical operators.
  • Literals default to untyped until used in context.
  • Go is statically typed - type conversions must be explicit.
package main

import "fmt"

func main() {
	fmt.Println("go" + "lang")
	fmt.Println("1+1 =", 1+1)
	fmt.Println("7.0/3.0 =", 7.0/3.0)
	fmt.Println(true && false)
	fmt.Println(true || false)
	fmt.Println(!true)
}
Output:
golang
1+1 = 2
7.0/3.0 = 2.3333333333333335
false
true
false

Value Types Reference

TypeExamplesOperationsNotes
string"hello", "go" + "lang"Concatenation with +Immutable UTF-8 encoded
int1, 42, -10+, -, *, /, %Platform dependent size (32 or 64-bit)
float643.14, 7.0/3.0+, -, *, /IEEE-754 64-bit floating point
booltrue, false&&, ||, !Logical operations only