Go and the Google Cloud Platform Integration

tudip-logo

Tudip

09 July 2019

Golang-300x199

Go is a statically typed, compiled programming language designed at Google by Robert Griesemer, Rob Pike, and Ken Thompson. Go is syntactically similar to C, but with memory safety, garbage collection, structural typing, and CSP-style concurrency.

Go is expressive, concise, clean, and efficient. Its concurrency mechanisms make it easy to write programs that get the most out of multicore and networked machines, while its novel type system enables flexible and modular program construction. Go compiles quickly to machine code yet has the convenience of garbage collection and the power of run-time reflection. It’s a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language.

Installation of Golang

Download official release binary from the official site https://golang.org/dl/

Debian/Ubuntu/linux

Step-1

Download the appropriate binary release for your Debian/Ubuntu/linux OS.
This is the compressed file for Go binary.

go1.12.1.linux-am

Step-2

Extract it to /usr/local directory.
Apply following command to directly extract to /usr/local directory.

tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz

Step-3

Add /usr/local/go/bin to the PATH environment variable. You can do this by adding this line to your /etc/profile (for a system-wide installation) or $HOME/.profile
Apply command $ sudo nano $HOME/.profile
Add below line at end of the file and save it.

Note: changes made to a profile file may not apply until the next time you log into your computer. To apply the changes immediately, just run the shell commands directly or execute them from the profile using a command such as source $HOME/.profile.

Now you have successfully installed golang in your linux platform, use the command below to verify Golang is successfully installed or not.

go –version

it will print go version.

Step-4

Create a directory in /home/go to set default GOPATH.
All the libraries will be installed to this directory.

macOS package installer

Download the package file, open it, and follow the prompts to install the Go tools. The package installs the Go distribution to /usr/local/go.

The package should put the /usr/local/go/bin directory in your PATH environment variable. You may need to restart any open Terminal sessions for the change to take effect.

Microsoft Windows

go1.12.1.windows-amd64.msi

Download the above MSI file and follow the prompt to install the Go tools.

This is the complete process to install Golang in local machine.
Please find the sample program of Go as below. Please create one test.go file and use following code:

package main
import "fmt"
func main(){
fmt.Println("Welcome to Tudip’s Go blog!")
}

Now, let’s run this project:

c:\hello> go run test.go
Welcome to Tudip’s Go blog!

As above simple code we can create big application in GoLang.

Google Cloud Platform

Google-Cloud-300x207

Google cloud platform is a system providing developers and IT professionals quality cloud services. You can select from several Google Cloud Platform diagram templates to create your own Google Cloud Platform diagrams quickly. No advanced skills are required for drawing these diagrams. Feel free to go even if you are just a beginner.

image2

Google App Engine

Google App Engine (often referred to as GAE or simply App Engine) is a web framework and cloud computing platform for developing and hosting web applications in Google-managed data centres. Applications are sandboxed and run across multiple servers. App Engine offers automatic scaling for web applications as the number of requests increases for an application, App Engine automatically allocates more resources for the web application to handle the additional demand.

Google App engine provides an SDK to run App Engine in local environment.

Download and Install the SDK for App Engine

Step-1

Create an environment variable for the correct distribution:

export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"

Step-2

Add the Cloud SDK distribution URI as a package source:

echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

Step-3

Import the Google Cloud public key:

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add –

Step-4

Update and install the Cloud SDK:

sudo apt-get update
sudo apt-get install google-cloud-sdk

You have successfully installed App engine SDK
To test type gcloud — it will display all the description of google cloud.

Step-5

To initialize a project to App engine type

gcloud init --

it will initialize the project to google cloud.

Request a quote