Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/loshz/tempconv
- Owner: loshz
- License: mit
- Created: 2016-07-19T12:39:48.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2022-02-17T18:38:17.000Z (over 2 years ago)
- Last Synced: 2024-06-19T11:16:53.165Z (5 months ago)
- Topics: conversion, golang, temperature
- Language: Go
- Homepage:
- Size: 17.6 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
```