types

package module
v0.0.0-...-a04e50b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TotalArea

func TotalArea(shapes ...Shape) float64

TotalArea calculates the total area of multiple shapes.

Types

type Celsius

type Celsius float64

Define a custom type representing a temperature in Celsius.

type Circle

type Circle struct {
	Radius float64
}

Circle is a type that implements the Shape interface.

func (Circle) Area

func (c Circle) Area() float64

Area method for Circle calculates the area of the circle.

func (Circle) Close

func (c Circle) Close() error

Close method for Circle satisfies the Close method of ReadWriteCloser.

type Fahrenheit

type Fahrenheit float64

Define a custom type representing a temperature in Fahrenheit.

type Location

type Location struct {
	Latitude  float64
	Longitude float64
}

Nested struct example

type MyType

type MyType int

MyType is an example type that satisfies the Stringer interface.

func (MyType) String

func (mt MyType) String() string

String method for MyType converts it to a string.

type Person

type Person struct {
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Age       int    `json:"age"`
}

Person struct definition

type Place

type Place struct {
	Name     string
	Location Location
}

type ReadWriteCloser

type ReadWriteCloser interface {
	Shape
	Close() error
}

type Rectangle

type Rectangle struct {
	Width  float64
	Height float64
}

Rectangle is a type that implements the Shape interface.

func (Rectangle) Area

func (r Rectangle) Area() float64

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

func (Rectangle) Close

func (r Rectangle) Close() error

Close method for Rectangle satisfies the Close method of ReadWriteCloser.

type Shape

type Shape interface {
	Area() float64
}

Shape is an interface representing a geometric shape.

type Stringer

type Stringer interface {
	String() string
}

Stringer is an interface representing types that can be converted to a string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL