CategoriesVue.js

A VueJS hello world

Why vue.js? It is extremely lean and small! The file size is approx 16kb minified and gzipped without the router framework. It is also very fast at runtime.

In this example, we will use a CDN from https://vuejs.org/v2/guide/ and import the library to get access to the VueJS library. We will add a simple div that contains an input text and will display the text as a paragraph on input change event.

Let’s create a vue instance in the JavaScript section. The ‘el’ property is a reserved property for VueJS which takes a string value; with this string value we’re saying which part of our HTML code should be under control using this instance. ‘data’ and ‘methods’ are reserved properties and accept object values. The v-on:input in html section will call the changeTitle method created in the vue instance.

Hit Ctrl + Enter and voila… 🙂

CategoriesGolang

APIs/HTTP microservices helper packages

The list below are helper packages that one should look into before start implementing Golang APIs/microservices. Understanding how they work, building APIs and HTTP microservices should be relatively easy.

CategoriesAWSGolang

Convert Go Code to AWS Lambda function

Import lambda package by running go get -u github.com/aws/aws-lambda-go/lambda. Make the handler available for remote procedure call by AWS lambda and utilizing lambda.start method as depicted in the image below:

Building – For Windows 10 users

  1. set GO111MODULE=on
  2. RUN go get -u github.com/aws/aws-lambda-go/cmd/build-lambda-zip
  3. set GOOS=linux
  4. set GOARCH=amd64
  5. set CGO_ENABLED=0
  6. RUN go build -o main main.go
  7. COPY main and PASTE in build-lambda-zip directory
  8. RUN build-lambda-zip.exe -o main.zip main

Assuming that the above steps were followed one should end up with a main.zip file. Browse to AWS lambda from AWS console, create function and upload the new zip file. Make sure that the code does not require any permissions that needs access to other AWS services.

Give it a try

Configure the test events and run a test.

The below shows a successful attempt where “finished” is returned from the code that we built above.

Elastic Search installation on Windows 10

Hi all, Good Morning 🙂

Download elastic search .zip file from the following link https://www.elastic.co/guide/en/elasticsearch/reference/current/zip-windows.html and extract to a desired location.

At this point, current version is 7.7.1. Please note, all installation instructions can be found in the link provided above.

Upon running the elasticsearch.bat the below should be shown. Please take note of the IP Address and port that elasticsearch is using – find AbstractHttpServerTransport. In this case, the following is being used: 127.0.0.1:9200

Let’s test it via a Postman HTTPGET request.

That’s it, you can now connect to elastic search for development. At this time of writing, preferred GoLang elastic search client is https://github.com/olivere/elastic. Let’s GO! 🙂

CategoriesGolang

Go dep installation on Windows 10

Install Chocolatey from the following link https://chocolatey.org/docs/installation#non-administrative-install – Head to Install with cmd.exe, copy command text, open cmd.exe with administrator rights and paste the command text and hit enter.

After a successful installation, paste the following command “choco install dep” and hit enter. “Do you want to run script?” will be prompted, with options to proceed. Typing ‘A’ (Yes to all) will run the script successfully.

After successful installation, type ‘dep version’. If the version is returned then it means that dep has installed successfully. Let’s go dep! 😉

CategoriesGolang

Let’s GO

Install and download GO by following the link https://golang.org/dl/

Install and download VS Code ( lightweight and free ) or Goland ( requires a licence ) I used both – Goland is a winner as it makes our life much easier.

Let’s write our first boring hello world:

How do we run the code in our project? Navigate to the project directory and type go run filenamewewanttoexecute in this case the file is main.go

What does package main in line 1 mean? A package is a collection of common source code files. There are two types of packages – executable or reusable. In this case, package main creates an executable file when we ran go run main.go. func main() is required with package main.

What does import “fmt” in line 3 mean? https://golang.org/pkg/fmt/ is the name of a standard library package that it is included in the GO programming language by default. By importing means give the package main access for all the code and all the functionality that is contained into the “fmt” package.

What is func main()? func tells GO that we are going to declare a function whereas main is the name of the function. Parameters to a function are passed in ().