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

How to request a WeRide robotaxi through WeRide Go app?

How to Implement Kubernetes as Orchestrator?

RemoteHQ 2.0: Multiplayer cloud-based Chrome browser

Install SQL Server ODBC driver on Azure Databricks

Auth with JSON Web Tokens & BCrypt (Part I: Rails)

Machine learning model of simple linear regression on Docker

Spring Boot Cache Implementation for Database Operations

Google Dorks

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

Testing Web Server: Part 2

JSON Packages to Go

How I got “Hot reloading” to work with Golang and nodemon (UNIX)

Go — If/Else, Switch, and For loop