tempConv

package
v0.0.0-...-1140a65 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package tempConv provides conversion among Celsius, Kelvin and Fahrenheit using methods.

Index

Examples

Constants

View Source
const (
	// AbsoluteZeroC in celsius
	AbsoluteZeroC Celsius = -273.15
	// FreezingPointC at which water freezes in celsius
	FreezingPointC Celsius = 0
	// BoilingPointC water boils in celsius
	BoilingPointC Celsius = 100
	// AbsoluteZeroF in fahrenheit
	AbsoluteZeroF Fahrenheit = -459.67
	// FreezingPointF in fahrenheit
	FreezingPointF Fahrenheit = 32
	// BoilingPointF water boils in fahrenheit
	BoilingPointF Fahrenheit = 212
	// AbsoluteZeroK in Kelvin
	AbsoluteZeroK Kelvin = -273.15
	// FreezingPointK in Kelvin
	FreezingPointK Kelvin = 273.15
	// BoilingPointK water boils in Kelvin
	BoilingPointK Kelvin = 373.15
)

Variables

This section is empty.

Functions

func InitCli

func InitCli()

InitCli for the "temp" command

eg: the-gpl temp -c=12 # Converts 12°C to °F

Types

type CLI

type CLI struct {
	// contains filtered or unexported fields
}

CLI wrapper for *flag.FlagSet

func (CLI) DisplayHelp

func (t CLI) DisplayHelp()

DisplayHelp prints help on command line for temperature module

func (CLI) ExecCmd

func (t CLI) ExecCmd(args []string)

ExecCmd run temp conversion command initiated from CLI

type Celsius

type Celsius float64

Celsius unit for temperature

func (Celsius) String

func (c Celsius) String() string

String prints in format 100°C value

Can use in %s fmt.Printf format

func (Celsius) ToF

func (c Celsius) ToF() Fahrenheit

ToF converts a Celsius to °F

func (Celsius) ToK

func (c Celsius) ToK() Kelvin

ToK converts a Celsius to °K

type Fahrenheit

type Fahrenheit float64

Fahrenheit unit for temperature

func (Fahrenheit) String

func (f Fahrenheit) String() string

String prints in format 100°F value

Can use to print value in %s fmt.Printf format

func (Fahrenheit) ToC

func (f Fahrenheit) ToC() Celsius

ToC converts a Fahrenheit to °C

Example

ExampleFahrenheit_ToC

boilingPointC := BoilingPointF.ToC().String()
absoluteZeroC := AbsoluteZeroF.ToC().String()
freezingC := FreezingPointF.ToC().String()
fmt.Println(boilingPointC)
fmt.Println(absoluteZeroC)
fmt.Println(freezingC)
Output:

100.00°C
-273.15°C
0.00°C

func (Fahrenheit) ToK

func (f Fahrenheit) ToK() Kelvin

ToK converts a Fahrenheit to °K

type Kelvin

type Kelvin float64

Kelvin unit for temperature

func (Kelvin) String

func (k Kelvin) String() string

String prints in format 100°K value

Can use in %s fmt.Printf format

func (Kelvin) ToC

func (k Kelvin) ToC() Celsius

ToC converts a Kelvin to °C

func (Kelvin) ToF

func (k Kelvin) ToF() Fahrenheit

ToF converts a Kelvin to °F

Jump to

Keyboard shortcuts

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