Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Go Language: Default or zero value

Tags: string

Variables that are declared without initialization are assigned with zero values.

Zero value
a.   0 for numeric types,
b.   false for the boolean type, and
c.    "" (the empty string) for strings.

App.go
package main

import "fmt"

func main() {
var i int
var f float64

var b bool

var s string

fmt.Println("i = ", i)
fmt.Println("f = ", f)
fmt.Println("b = ", b)
fmt.Println("s = ", s)

}

Output
i =  0
f =  0
b =  false
s = 

Previous                                                 Next                                                 Home


This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

Go Language: Default or zero value

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×