An Introduction to Golang

All you need to get started

Image for post

It’s time to learn Golang. [Image source]

This post intends to be an introduction to the Go programming language, also known as Golang.

Disclaimer

I’m not an expert in Go. In fact, I’ve started learning about Go very recently. Therefore, take everything in this post with a pinch of salt.

Then… why am I writing a post about Go? It’s simple: I want to use this post as a tool to reinforce my learning process. I believe that working on a blog post and publishing it will force me to get every detail straight. Moreover, I’ll be crafting the guide that I would have liked to have found in the first place (and, therefore, it is likely that it will become the guide that you were looking for as well). This also means that this post will probably be evolving as I learn new aspects of Go.

Keep in mind, though, that despite of the fact that I’ll be working on every detail of the post, I may make mistakes. I encourage you to indicate in the comments section any errors that you may find, and I’ll gladly correct them.

If this disclaimer has let you down and you are not interested in reading this post anymore, here are some fantastic resources to get started with Go:

If you, however, decide to stay and keep reading… welcome!

A bit of history

Golang was born in Google, and it was created by Robert Griesemer, Rob Pike and Ken Thompson. It was discussed for the first time on September 21, 2007 and eventually became an open-source project on November 10, 2009.

As reported in Go’s site, this language was born due to the commonly necessary choice between an efficient compilation, efficient execution or ease of programming at the time of choosing a programming language to work with. Therefore, the main goal of Go was to create a language that would achieve the ease of an interpreted and dynamically typed language, while preserving the efficiency and safety of a statically typed, compiled language. Another one of the main goals was to take advantage of the growth of multicore CPUs, making concurrency one of the priorities of the language.

To get a deeper insight into the goals of Go, I’d recommend reading this article, written by Rob Pike. Some of the goals mentioned in this article include finding a solution for:

  • slow builds
  • uncontrolled dependencies
  • each programmer using a different subset of the language
  • poor program understanding (code hard to read, poorly documented, and so on)
  • duplication of effort
  • cost of updates
  • version skew
  • difficulty of writing automatic tools
  • cross-language builds

Considering that Google works with large-scale systems that have huge codebases, Go was primarily developed as a language “in the service of software engineering”, attempting to solve the most common issues in large systems.

Getting started with Go

Setting up our development environment

In order to follow through this post, you have two options:

  1. Set up a local development environment
  2. Use Go’s official online playground

I will not go into the installation details for each platform, but here are some guides:

If you, however, prefer not to commit for now and test out the language, option 2 is a perfectly valid option. In any case, I recommend you to go through this introduction executing the examples, instead of just reading the code: I’m sure you would get a better grasp of the language.

Hello world!

Well, first things first! Let’s get started writing our first program in Go. In the following sections I’ll be explaining in more detail each part of our program. We may print our “Hello world!” message with the following few lines of code:

package main

import "fmt"
func main() {
  fmt.Println("Hello world!")
}

We’ll save the above snippet in a file called Main.go and then run the following instruction in our CLI:

go run Main.go

Voilà! If everything worked correctly, you should see our message printed in the terminal. Congrats! You’ve written your first Go program!

Let’s make an initial explanation of the above snippet, so that we start getting our first building blocks. Go programs are organized into packages, and one special package is “main”, which must be used in executable commands. We may now move towards the import statement, which allows us to include packages in our program. It may be worth mentioning that we may import multiple packages with the following syntax:

import (
  "<package_1>"
  "<package_2>"
)

In our example, we can see the “fmt” package, which is commonly used to read from stdin or write to stdout. We’ll be discovering this package in more detail as this article develops.

Finally, we may find the “func main()” declaration which, unsurprisingly, declares the main function of our Go program.

#software-engineering #go #golang #programming #software-development

What is GEEK

Buddha Community

An Introduction to Golang

Hire Dedicated Golang Developers | Golang Web Development Company

Does your business need a robust system across large-scale network servers then developing your app with a Golang programming language is the way to go. Golang is generally used for the development of highly secured, High Speed and High Modularity apps such as a FinTech Industry.

Want to develop a Highly secured app for your business?

Then hire a dedicated Golang developer from WebClues Infotech that are highly skilled in carrying out the work in a timely and qualitative output. With WebClues Infotech you get the assurance that we know what are the customers’ expectations and how to deliver on them on time.

Get your desired Golang Developer based on your project requirement!!

Share your requirements here https://www.webcluesinfotech.com/contact-us/

Book Free Interview with Golang developer: https://bit.ly/3dDShFg

#hire golang developer #hire go language developer #dedicated golang app developers #golang web development company #hire golang developers india #hire expert golang developers

Golang Web Development:Th Best Programming Language in 2020

https://www.mobinius.com/blogs/golang-web-development-company

#golang web development #golang-app-development-company #golang-development-solutions #hire-golang-developers #golang-development-services

Ajay Kapoor

1624960485

Golang vs. Node.JS: Who Trumps the Battle of Backend Frameworks?

Full blog here

The backend of your application is truly the essential part of your product. No matter how much you appreciate the design, the application’s success lies in its backend. A scalable backend that effectively implements the required business logic is the primary goal of programmers.

Therefore, it is crucial to choose the most powerful and scalable technology. There are plenty of languages ​​in the market that can form the backend of any application, Node.js and Golang are the two most popular technologies among them.

They are real and developed languages ​​that have recently been used in various outstanding projects. Golang is an open-source programming language, whereas Node.js is an open-source server framework. They both are gaining popularity for various reasons.

According to a development stat, it is observed that almost 50% out of 58,543 respondents use Node.js as their preferred app development tool.

Golang, on the other hand, has overtaken other programming languages in the application development market and has gained huge recognition over the past few years.

But, which backend framework is best for you? In this article, I’ll make a healthy comparison of two of Google’s most popular backend development tools based on several essential features and various other factors.

Golang developers for hire

#best backend frameworks #node or golang #golang or nodejs #nodejs vs golang #golang vs nodejs #top backend frameworks

Fannie  Zemlak

Fannie Zemlak

1599732000

“Go Has Indeed Become The Language Of Cloud Infrastructure“ - Rob Pike

Introduction

We spoke to Rob Pike, the co-author of the Go programming language, about a career spanning four decades, the evolution of Go over the last ten years, and into the future.

The Interview

Evrone: Unlike many developers today, you started your career decades ago at Bell Labs. What’s been the biggest change in the way we develop software that you can think of, given your rare perspective?

**Rob: **The scale is much bigger today. Not just of the computers and the network, but the programs themselves. All of Unix version 6 (circa 1975) fits comfortably on a single RK05 disk pack, which has just over 2MB of storage, with lots of room left over for user software. And that was a fine computing environment, or at least seemed like one at the time. Although I can, of course, explain much of the growth, it is astonishing and perhaps not all of it is justified.

#golang #golang-api #golang-tools #golang-website #rob-pike #interview-transcript-go #latest-tech-stories #cloud-infrastructure-and-go

Road to Golang pro — Pointer & Functions

A few words before we start. You can find the code used in this tutorial in this repository. You can find the full contents of Road to Go Pro here. If you missed the last one, you can find it via this link.

We talked about flow controls and loops in the last part of the tutorial. In this one, we will cover pointers and functions. After finishing the first 4 parts of Road to Go Pro, you are well equipped to start writing scripts or console applications using Go.

Pointers

Image for post

Photo by Nathalie SPEHNER on Unsplash

If you have used C or C++, you already know what’s a pointer. However, in the most popular programming languages like Java, C#, Javascript, Python, etc. there’s no explicit syntax to represent pointers. I had no idea what it is when I first heard of this name.

In short, a pointer holds the underlying memory address of a value. Whoa, hold on, memory address? Isn’t Go a high-level programming language?

When do we even need to know about the memory addresses of variables?

That’s a good question but before exploring the answer, we need to take a quick detour. Let’s see how to declare pointers and how to use them in functions. Once we have covered these, it will be easier for you to understand the reasoning and examples below. So hang in there.

Declaring pointers

Whenever we declare a variable in Go, the compiler allocates a segment of memory to store it. The value of that variable is stored there until it is recycled by the garbage collector.

Pointers are composite data types. We form a pointer type by adding an * in front of the data type it points to. For instance, *string represents the type of a pointer pointing to a string-type variable.

To get the pointer value of an existing variable, we need to add an & in front of the variable.

#golang #go #golang-tutorial #golang-development