Skip to content

Instantly share code, notes, and snippets.

@Agilulfe
Last active August 21, 2020 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Agilulfe/cfe81a5695c06e8bd767958d3c11022a to your computer and use it in GitHub Desktop.
Save Agilulfe/cfe81a5695c06e8bd767958d3c11022a to your computer and use it in GitHub Desktop.
Basic types in go
package main
import (
"fmt"
"reflect"
)
func main() {
fmt.Println(1.51-1.50 == 0.01)
fmt.Println(1 + 1)
fmt.Println(1 - 1)
fmt.Println(2 * 2)
fmt.Println(2 / 2)
fmt.Println(3 % 2)
fmt.Println(len(""))
fmt.Println(len(" "))
fmt.Println(len("Go is an amazing language"))
fmt.Println("Learning Go is a good investment"[1])
fmt.Println("Hello, " + "World!")
fmt.Println(true && true)
fmt.Println(true && false)
fmt.Println(false && false)
fmt.Println(true || true)
fmt.Println(true || false)
fmt.Println(false || false)
fmt.Println(!true)
fmt.Println(!false)
fmt.Println(reflect.TypeOf(5))
fmt.Println(reflect.TypeOf(5.0))
fmt.Println(reflect.TypeOf(5 + 5.0))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment