Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/loshz/tempconv

Golang package for converting temperatures.
https://github.com/loshz/tempconv

conversion golang temperature

Last synced: 25 days ago
JSON representation

Golang package for converting temperatures.

Awesome Lists containing this project

README

        

# tempconv [![Build Status](https://github.com/syscll/tempconv/workflows/build/badge.svg)](https://github.com/syscll/tempconv/actions)

A simple package that performs the conversion of different temperature scales: `Celsius`, `Fahrenheit` and `Kelvin`.

## Usage

Simply call a specific conversion function and pass the correct scale:

```
CelsiusToFahrenheit(20) // 68
CelsiusToKelvin(30) // 303.2
FahrenheitToCelsius(55) // 12.8
FahrenheitToKelvin(50) // 283.2
KelvinToCelsius(300) // 26.9
KelvinToFahrenheit(300) // 80.3
```

Each type also implements the `String()` method which returns a formatted temperature:

```
fmt.Sprint(Celsius(12)) // 12°C
fmt.Sprint(Fahrenheit(55)) // 55°F
fmt.Sprint(Kelvin(300)) // 300K
```