Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 PROGRAMMING


  Behavior of defer function in named return function

In Go, there is a special concept of named return value in function where a returned value can have name. For example, below is a named function in Go.func returnNamed() (i int) { i = 1 return}When the function returns, the return value i will have a value of 1. Also, Go has a concept of defer which will execute a function just before the calling function exits. This is similar to what finally block does in other languages such as Java. For example, a defer function can befunc deferFunc() { defer func() { fmt.Println("In defer") }() fmt.Println("Start")}Both return and defer can change th...

3,865 0       GOLANG DEFER NAMED RETURN DIFFERENCE


  Advantages and disadvantages of GoLang

GoLang is a strong typed language which means it is less flexible than interpreted languages by nature. But Go provides Any type(interface) and Reflect mechanism which make the language very close to interpreted languages on flexibility. More and more people start to learn GoLang.This post is mainly for listing down some of the advantages and disadvantages of GoLang.AdvantagesPerformance(Machine code)GoLang is a compilation language which can be compiled to machine code and the compiled binary can be directly deployed to target machine without extra dependency. The performance is better than t...

12,016 2       ADVANTAGE DISADVANTAGE GOLANG GOROUTINE GENERICS


  Use Delve to debug GoLang program

If you don't know how to debug program, you are not a real programmer.gdb can be used to debug go program, but according to golang website, delve is a better option. Note that Delve is a better alternative to GDB when debugging Go programs built with the standard toolchain. It understands the Go runtime, data structures, and expressions better than GDB.Below is a simple go program.package maintype Person struct { Name string Age int}func main() { var me Person me.Name = "Melvin" me.Age = 41 var wife Person wife.Name = "Raye" wife.Age = 36 var daughter Person daughter.Name = "Kat...

3,362 0       DELVE GOLANG DEBUG


  A strange behavior of printing struct with nested struct in GoLang

Normally when trying to print a struct , we would use %v to show all data of the struct. It will print the default format for each field in the struct.%v the value in a default format when printing structs, the plus flag (%+v) adds field namesBut recently we observed a strange behavior when printing a struct with nested struct which has a String() string implemented, the %v format prints an 'unexpected' output per our understanding.  Let's see the example snippet first.package mainimport ( "fmt")type Inner struct {}type A struct { Inner FieldA string}func (i Inner) String...

7,780 2       PROGRAMMING GOLANG


  Empty slice vs nil slice in GoLang

In Go, there is a type called slice which is built on top of array. It's a very convenient type when we want to handle a group of data. This post will explain a subtle but tricky difference between empty slice and nil slice.A nil slice is a slice has a length and capacity of zero and has no underlying array. The zero value of slice is nil. If a slice is declared like below, it is a nil slice.package mainimport "fmt"func main() { var a []string fmt.Println(a == nil)}The output will be true for above code snippet. An empty slice is a slice also has a length and capacity of zero but has unde...

33,515 0       JSON GOLANG EMPTY SLICE NIL SLICE


  Is Python all set to triumph over Java?

Python is one of the top programming languages of the present time. A variety of companies with different backgrounds and offerings have embraced the capabilities of Python to make wonderful tech products. As, Java is also known to be one of the most recognized languages, therefore, there is a constant battle that takes place between the two languages. Python wants to dethrone Java as the number one, whenever it is and vice versa. It is like the tussle between Android and iOS which is never ending. Both of the languages were introduced to the world in the 90’s.Shortly after the emergence...

1,760 0       JAVA DEVELOPMENT PYTHON DJANGO


  How to Set Spring profile With Example

Technology:  Spring Profiles provides a way to isolates the parts of application configuration, it will make available only in certain environments. It is mainly useful it wants to load spring beans based on environment configuration, for example if the operating system is windows we can load some specific spring beans, if it is other than load different spring beans. One more scenario where spring profiles widely used, like for QA environment we will use some database which is hosted locally, for UAT we will use some different host database, for production it will vary, in this scenario`...

16,585 0       SPRING APPLICATIONS PROFILE DEVELOPMENT JAVA


  The Most Effective Stretches and Yoga Poses for Programmers

Programming software takes a tremendous amount of focus and effort. Working hard to transform code into software is an exciting feeling. It’s easy to get lost in your work as the hours fly by. I’ve done this many times. However, writing code can also be frustrating in many cases. I’ve been a programmer for many years, and I still spend hours debugging. Most of the time this level of debugging requires sitting down and focusing. After many years of this, you will be a prime candidate for back pain and repetitive stress injuries. I’ve found a way to prevent this from happ...

15,102 2       YOGA FOR PROGRAMMERS STRETCHING GUIDE FOR PROGRAMMERS YOGA FOR DEVELOPERS