Discover Packages
github.com/parandor/samples/tests/go/types
package
module
Version:
v0.0.0-...-a04e50b
Opens a new window with list of versions in this module.
Published: Aug 5, 2024
License: GPL-3.0
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
Documentation
¶
TotalArea calculates the total area of multiple shapes.
Define a custom type representing a temperature in Celsius.
type Circle struct {
Radius float64
}
Circle is a type that implements the Shape interface.
Area method for Circle calculates the area of the circle.
Close method for Circle satisfies the Close method of ReadWriteCloser.
Define a custom type representing a temperature in Fahrenheit.
MyType is an example type that satisfies the Stringer interface.
String method for MyType converts it to a string.
type Person struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Age int `json:"age"`
}
Person struct definition
type ReadWriteCloser interface {
Shape
Close() error
}
Rectangle is a type that implements the Shape interface.
Area method for Rectangle calculates the area of the rectangle.
When you define a method on a value receiver (as in func (r Rectangle) Area() float64),
you can call that method on both values and pointers to that type
Close method for Rectangle satisfies the Close method of ReadWriteCloser.
type Shape interface {
Area() float64
}
Shape is an interface representing a geometric shape.
type Stringer interface {
String() string
}
Stringer is an interface representing types that can be converted to a string.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.