Declaration of a struct type
A struct type rectangle is declared that has three data fields of different data-types. Here, struct used without instantiate a new instance of that type.
Example
package main
import "fmt"
type rectangle struct {
length float64
breadth float64
color string
}
func main() {
fmt.Println(rectangle{10.5, 25.10, "red"})
}
The rectangle struct and its fields are not exported to other packages because identifiers are started with an lowercase letter. In Golang, identifiers are exported to other packages if the name starts with an uppercase letter, otherwise the accessibility will be limited within the package only.
Most Helpful This Week
Golang Program to print Triangle of Numbers
Go program to find MX records record of a domain
How do you handle HTTP client server security in Go?
What is Struct
GO Program to Check Whether a Number is Palindrome or Not
Golang program to generate number of slices permutations of number entered by user
Defining a type that satisfies an interface in Go Programming Language
This sample program demonstrates how to decode a JSON string.
How to add items to Slice using append function in Golang?
Find Type of Struct in Go Programming Language