When it comes to creating a production-grade application, using the environment variable in the application is de facto.

Need of the environment variable?

Suppose you have an application with many features and each feature need to access the Database. You configured all the DB information like DBURL, DBNAME, USERNAME and PASSWORD in each feature

I will talk about the one of major disadvantages of this:

Security Issue:

  • You’re entering all the information in the code. Now, all the unauthorized person also have access to the DB.


When i first started my journey on golang, i could not found an easy way to setup auto reloading. So the issue was every time i make changes to my source code, i had to kill the existing server, restart server again and then test API with postman.

Definitely, this process is cumbersome and headache to do. Whenever we save the code changes, we want our old server process to be killed automatically and start new one with new code changes, so that we can test our changes immediately.

I referred quite a lot of articles but could find proper…


I was very confused at the beginning when I read an article that says “Go is object-oriented”. Sometimes another article claims that no object-oriented programming can be done with Go, only because it does not have any classes. So I am writing this article just to clarify this topic. Is Go object-oriented, or not?
For example, if you come from C, clearly Go has lots more object-oriented programming features. Coming from Java, Go code doesn’t look much object-oriented. …


What is actually a map in Golang?.

There’s no such specific data type in Golang called map; instead, we use the map keyword to create a map with keys of a certain type and values of another type (or the same type).

Golang map literals

The value assigned here is a map literal. It takes the form:

TYPE{
KEY: VALUE,
...
}

Var menuprice map[string]int

In this example, we declare a map that has string for its keys, and int for its values.

Golang map key types?? key vs values

What types of keys can a map have? Could we, for example, make…


An anti-pattern is an idea of how not to solve it because implementing that idea would result in bad design.

When you build a web-application, A common scenario is to display a list of items, might be a list of names, a list of products, and soon others.

“Let learn the concept of List Rendering First and issue about index as a key in React”

One of the best things about React is it lies heavily in JavaScript language itself and not required any new methods to manipulate and render a list of new data.

  1. List Rendering:

If you are…


SYNCHRONOUS CODE

  • Synchronous basically means that you can only execute one thing at a time.
Code executes step by step in order:

SYNCHRONOUS CODE: BLOCKING STATE AND SLOW PERFORMANCE

posts = loadpostsync();
// wait tills posts are fetched

dotheNextthing)(); // has to wait until posts are fetched
  • We simply have certain operations that cannot be finished immediately. It, not just the timer where we as a developer decides how long we take it.


Gin is a web framework written in Go (Golang). It features an API with much better performance, up to 40 times faster thanks to the HTTP router. If you need performance and good productivity, you will love to use Gin.

To install the Gin package, you need to install Go and set your Go workspace first.
Download and install it:

$ go get -u github.com/gin-gonic/gin
  1. Import it in your code:
import "github.com/gin-gonic/gin"

(Optional) Import net/http. This is required for example if using constants such as http.StatusOK.

2. Create your project folder and cd inside

$ mkdir -p $GOPATH/src/github.com/coderDenes/go-gin-api 

Dinesh Silwal

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