Go for Beginners — Part 2

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

// 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 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

--

--

--

Backend Developer, Probably listening to music and drinking coffee

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Kotlin: Best practices of Code — Part 1

Useful Linux Commands — Network and Compression

A Week In the Code of a Full Stacker

Lambdas (Java 8)

A blueprint for Scandiweb Support

Getting Started with Filament on Android

Ruby Singleton Pattern to Read File Content From Various Type of File

Community Spotlight Series — Carly Cohen

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
Kodey Thomas

Kodey Thomas

Backend Developer, Probably listening to music and drinking coffee

More from Medium

Programming Languages of Pintu’s Backend

Asgardeo authentication with Golang and Goth

Securing gRPC connection with SSL/TLS Certificate using Go

Debugging AWS Lambda Functions in Go with VSCode