Golang: Variable declaration and how to Call


In this note I am talking about how to declare variables and call it using several different ways (links) :

package main

import "fmt"

var name string
var address string
var phone string

var gender = "male"

var (
   a string
   b int
   c string
)

// Another way to delare vars
var (
    d, f string
    e int
    g = 10
    h = "horray"
)

func main() {
    a, c := "domino", "pizza"
    b, e := 100, 200
    h := h + ", " + a + " " + c

    fmt.Println(h)
    fmt.Println(b + e)

    fmt.Printf("I love %s %s \n", a, c)
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s