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
GO Program to Generate Fibonacci Sequence Up to a Certain Number
GO Program to Check Whether a Number is Even or Odd
Program to print pyramid using numbers
Golang program for implementation of Interpolation Search
Comparing Structs with the Different Values Assigned to Data Fields
Creating a Struct Instance Using a Struct Literal