Skip to main content

Posts

Showing posts from July, 2018

Variable declarations in Go language

Every programming language in this world provides options to declare and define variables and used by parts of the program. So Go does the same. The wiki states that a variable is a symbolic name associated with a value and whose associated value may be changed But in more technical way, a variable is a memory location with name which might hold values and may change later. Variables in memory Go provides different options to declare and define the variables. Let's see how we can declare variable in Golang. Variable declaration A variable in go could be declared as follows, package main import "fmt" var a = "has some value" func main() { fmt.Println(a) } Here the variable a is declared and initialized with the value "has some value" . The type of the variable is inferred from the value been assigned. Supported Types in Golang Go supports the following primitive types Base Types Description Numerics  

How to start with Go Language - A Google's Programming Language

It's been always fun to start programming with a brand new language. And, as a Programmer, it's absolutely worth to keep you updated with the new languages as you come across. Every programming language in this world is been designed to solve a problem in mind. So learning a new language would help you to solve your problem efficiently if the language offers flexibility to do so. I am going to share the knowledge on the new language; atleast for me 😉 (released on 10 November 2009) which i have explored on. The name of new language is Go . Yes it is Google's language; Golang. Source: sdtimes.com Will see what Google says about the new Language, Go is a statically typed, compiled language in the tradition of C, with memory safety, garbage collection, structural typing, and CSP-style concurrency. Yes, Go language is mainly designed to deal with morden days problems in the computing world. The Golang has the built-in feature of concurrency i.e deal with multiple

Escape HTML entities from HTML string with Whitelist tags and special characters

It's been a long time to keydown for a technical blog. This time, I am going to write about how we can escape HTML entities from given HTML string with the whitelist of tags and special characters given. Image Credit When I was working on a task for a project, we supposed to display a toast message with HTML mode enabled. For this, we used  Toastr by CodeSeven  to display the toaster message when we want to show some notification. The toaster messages which we display would have the HTML tags as well to display the content in the required formats as like  bold ,  strong  or  italic.  To do this, we have to enable the toastr library to display HTML content by setting  escapeHtml  property to true in toastr option. But the problem with this approach would be the  XSS attack . Because the  escapeHtml  property to show all the HTML tags including script tag. So to avoid the XSS, we tried to use some libraries but it contains more lines of code which we don't want. We