crazyc4t's blog

Programming with go!

How to start programming with Go

Hello guys it’s crazyc4t once again, sorry for being a bit distant on my blog but prepare yourselves because there’s more content in the oven!

I disappeared but with a purpose, I was laser-locked focused learning go! And it is really fun, but first…

What is go?

Gopher

Go is an open-source programming language supported by Google, created by Ken Thompson and Rob Pike, the creators of the UNIX operating system, made for Google-sized problems, being Go a static fast-compiled language, that includes native concurrency, garbage collection and efficiency at scale.

Why go?

Go is a programming language easy to pick up and get started with (as we are going to do in this post!) and easier if you come from other programming languages, it’s syntax is similar to C, it has built-in concurrency and a robust standard library, the go community is growing as time passes and it features tons of modules, libraries, tools to play with and documentation to learn from like this one!

Go is used for Google-sized problems, making FAANG interested in go, these are companies that use go to power their software:

And so much more companies as well are joining the list since is really easy to pick up and the safety+speed concept that helps them right quality code, and make debugging really easy, since the compiler lints the errors you have in your code before you even compile it!

Go is used on different code purposes like:

Projects that were built with go are:

Getting started with go!

Gopher

We need to setup our coding environment to code with go, first we need to install it.

Installation of go

That’s it! Check if you have it installed by checking it’s version: go version

Setting up your text editor

You can use any type of text editor you want but my personal recommendation is:

Write some code!

Hello world!

 1// Print hello world!
 2
 3package main
 4// meaning that it should be compiled as a executable program, not as a shared libary
 5
 6import "fmt" // The format package from the standard libary for printing the string
 7
 8func main() {
 9  fmt.Println("Hello Gopher!")
10}

After coding you can run it by just doing so: go run main.go

Or you can compile it for your system! go build main.go

Let’s make a greeter!

 1package main
 2
 3import "fmt"
 4
 5func main() {
 6  fmt.Println("Hello! What's your name? ")
 7  var name string // creating a variable without a value of type string
 8  fmt.Scanf("%s", &name) // Scan the input text and format it determined by the type
 9  fmt.Println("Hello", name, "How are you doing?")
10}

After scratching the surface of go, this is the next step…

Keep learning!

Gopher

These are some resources that are awesome!

Webpages

Tutorials

Exercises

Books

Thank you for reading!

I’m learning go at the moment so expect more go content coming your way!

#Go