Go for Beginners — Part 2

If you’re genuinely interested in this you can view all of my progress on my GitHub repo HERE

An Introduction to Go

Photo by Fotis Fotopoulos on Unsplash

Compiling

go build nameOfFile.go

Running Our Code

go run nameOfFile.go

Packages

Importing Packages

Libraries are referred to as Packages within GoLang

When importing Packages make sure to enclose them in double quotes "or else you'll get an error

// main.go
package main
import "fmt"

Functions

func nameOfFunction() {
// Write Code Here
}

Hello World

// main.gopackage mainimport "fmt"func main() {
fmt.Println("Hello World!")
}

Go uses Dot Syntax to refer to Methods / Functions

$ go run main.go
Hello World!
>

Importing Multiple Packages

import (
"package1"
"package2"
)
import (
package1Allias "package1"
package2Allias "package2"
)
package1Allias.someFunction()
p1.someFunction()

Comments

// Hello!
package main
// import "fmt" (This line won't be read)

Summary

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store