Variables and constant are totally different things. Work through https://tour.golang.org/basics/8 ff and https://tour.golang.org/basics/15 ff
Memory usage and copy behaviour are not interesting until you are comfortable with the basics of the language. V. On Wednesday, 23 August 2017 14:49:39 UTC+2, Alkesh Ghorpade wrote: > > Hi All, > > I am new to Go and trying to figure out difference between const vs var > variables memory usage and initialization. > > I have following go code > // way 1 > var a = []string{"abc", "def"} > > // way 2 > const ( > a = "abc" > b = "def" > ) > > var a1 = []string{a, b} > > my variables a and a1 are defined in a file and not inside any function. > Is there any difference in both ways. When I call variable a in any > function does it creates a copy everytime it is called? Can you please tell > me what happens when a or a1 is called and how they are referenced in > memory when called. > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.