Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aquilax/nutriscore
Go library for calculating the Nutri-Score of foods and beverages.
https://github.com/aquilax/nutriscore
go golang library nutriscore nutrition
Last synced: 25 days ago
JSON representation
Go library for calculating the Nutri-Score of foods and beverages.
- Host: GitHub
- URL: https://github.com/aquilax/nutriscore
- Owner: aquilax
- License: mit
- Created: 2021-12-22T16:26:27.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2021-12-23T12:15:09.000Z (about 3 years ago)
- Last Synced: 2024-10-22T15:15:12.765Z (2 months ago)
- Topics: go, golang, library, nutriscore, nutrition
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nutriscore [![Go Reference](https://pkg.go.dev/badge/github.com/aquilax/nutriscore.svg)](https://pkg.go.dev/github.com/aquilax/nutriscore)
Go library for calculating the Nutri-Score
Based on https://www.santepubliquefrance.fr/content/download/150263/file/2021_07_21_QR_scientifique_et_technique_V41_EN.pdf
## Usage
```go
package nutriscore_testimport (
"fmt"ns "github.com/aquilax/nutriscore"
)func ExampleGetNutritionalScore() {
ns := ns.GetNutritionalScore(ns.NutritionalData{
Energy: ns.EnergyFromKcal(0),
Sugars: ns.SugarGram(10),
SaturatedFattyAcids: ns.SaturatedFattyAcidsGram(2),
Sodium: ns.SodiumMilligram(500),
Fruits: ns.FruitsPercent(60),
Fibre: ns.FibreGram(4),
Protein: ns.ProteinGram(2),
}, ns.Food)
fmt.Printf("Nutritional score: %d\n", ns.Value)
fmt.Printf("NutriScore: %s\n", ns.GetNutriScore())
// Output:
// Nutritional score: 2
// NutriScore: B
}
```