Configuration

Night mode

Common 'Basic' Types

A$AP Learn Go (GoLang) 🚀 Course

Engineers From These Top Companies and Universities Trust EXLskills

1M+ Professionals | 100+ Institutions

This is the EXLskills free and open-source A$AP Learn GoLang Course! It's a highly-accelerated open course that's best-suited for people with a bit of background in software engineering to quickly pick up Go, learn the essential best practices, and hit the ground running!
After this course, you'll be able to build basic Go applications in addition to lightweight webservers, highly-concurrent programs, and reusable libraries in Go that you can share with other developers!
For further practice, we recommend checking out our Go Guided Projects that will give you access to a professional Go developer, detailed documentation, and real-world tasks that you can work on to go from the basics of Go, into building production apps.

Is this course FREE?

Yes, this a 100% free course that you can contribute to on GitHub here!

Have more questions?

Core Datatypes

Common 'Basic' Types

Most Commonly Used Basic Datatypes

This section covers some of Go's most common 'basic' types that are natively included in the language

package main
import (
"fmt"
)
func main() {
// In Go, the bool type is used for storing true/false data
myBool := true // Go infers the type as bool
// Can also define explicitly, `var myBool bool = true`, which would be equivalent in this case
fmt.Println("myBool:", myBool)
// Despite the fact that Go offers non-nil defaults for most datatypes, pointers most notably, may
// frequently be `nil` which is a specially state like null or None in many other languages
// that implies the variable has no value. Variables with a non-nil default, may never be nil!
var err error = nil
fmt.Println("error?:", err)
// NB: Since int has a non-nil default, then `var myInt int = nil` would not even compile
// Strings in Go are very flexible, UTF-8 compatible, and they are stored as byte slices
// NB: We use the \ for escaping " and for special characters, such as newlines
var helloWorldStr = "Hello, 世界.\nThat means, \"Hello, World.\""
fmt.Println(helloWorldStr)
// We can also use backticks to create raw multi-line strings
helloWorldStr = `Hello, 世界.
That means, "Hello, World."`
fmt.Println("We created this with `` syntax:", helloWorldStr)
// Integers are usually defined like this (Go infers the `int` type)
myInt := 42
fmt.Println("myInt:", myInt)
// For specifying 64-bit integers specifically, we can use this notation
var myInt64 int64 = 21
fmt.Println("myInt64:", myInt64)
// Similar terms go for floating point numbers
myFloat := 42.42
fmt.Println("myFloat:", myFloat)
// For specifying 64-bit floats specifically, we can use this notation
var myFloat64 float64 = 21.21
fmt.Println("myFloat64:", myFloat64)
}