×

Go Tutorial

Go Basics

Go Variables

Go Literals

Go Type Handling

Go Operators

Go Decision Making

Go Loops

Go Functions

Go String

Go Arrays

Go Slices

Go Maps

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

What is the default value of a structure in Go language?

Here, we will learn about the structure variable and the default value of the structure variable in Golang.
Submitted by IncludeHelp, on October 03, 2021

A structure is a collection of primitive data types or even other structures and they inherit the default values of the types they are made out of. The default value of a structure (struct) in the Go programming language is the default value of its members.

Example:

// Golang program to demonstrate the
// default value of a structure variable

package main

import "fmt"

type Person struct {
	Name string
	Age  int
	Perc float32
}

func main() {
	var P Person

	fmt.Printf("Default value: %v\n", P)
}

Output:

Default value: { 0 0}

Golang FAQ »

Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.