https://github.com/pieterclaerhout/go-finance
Finance related Go functions (e.g. exchange rates, VAT number checking, …)
https://github.com/pieterclaerhout/go-finance
exchange-rate exchange-rates golang vat-number vat-validation vat-validator
Last synced: 8 days ago
JSON representation
Finance related Go functions (e.g. exchange rates, VAT number checking, …)
- Host: GitHub
- URL: https://github.com/pieterclaerhout/go-finance
- Owner: pieterclaerhout
- License: apache-2.0
- Created: 2019-09-30T06:49:07.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-24T06:13:27.000Z (10 months ago)
- Last Synced: 2024-07-30T20:43:02.245Z (9 months ago)
- Topics: exchange-rate, exchange-rates, golang, vat-number, vat-validation, vat-validator
- Language: Go
- Homepage: https://www.yellowduck.be
- Size: 3.48 MB
- Stars: 27
- Watchers: 5
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - go-finance - Module to fetch exchange rates, check VAT numbers via VIES and check IBAN bank account numbers. (Financial / Search and Analytic Databases)
- awesome-go-extra - go-finance - 09-30T06:49:07Z|2019-10-23T13:05:23Z| (Financial / Advanced Console UIs)
README
# go-finance
[](https://goreportcard.com/report/github.com/pieterclaerhout/go-finance)
[](http://godoc.org/github.com/pieterclaerhout/go-finance)
[](https://github.com/pieterclaerhout/go-finance/raw/master/LICENSE)
[](https://badge.fury.io/gh/pieterclaerhout%2Fgo-finance)
[](https://github.com/pieterclaerhout/go-finance/issues)This is a [Golang](https://golang.org) library which contains finance related functions.
## Exchange Rates
The following example explains how to use this package to retrieve the exchange rates from [ECB](https://www.ecb.europa.eu):
```go
package mainimport (
"fmt"
"os""github.com/pieterclaerhout/go-finance"
)func main() {
rates, err := finance.ExchangeRates()
if err != nil {
fmt.Println("ERROR:", err.Error())
os.Exit(1)
}for currency, rate := range rates {
fmt.Println(currency, "-> €1 =", rate)
}}
```## Checking VAT Numbers
You can also VAT numbers via the [VIES service](http://ec.europa.eu/taxation_customs/vies/vatRequest.html). The following sample code shows how to do this:
```go
package mainimport (
"fmt"
"os""github.com/pieterclaerhout/go-finance"
)func main() {
info, err := finance.CheckVAT("BE0836157420")
if err != nil {
fmt.Println("ERROR:", err.Error())
os.Exit(1)
}fmt.Println(info)
}
```## IBAN & BIC
There is also a function which converts a regular Belgian Bank Account Number to it's IBAN / BIC equivalent:
```go
package mainimport (
"fmt"
"os""github.com/pieterclaerhout/go-finance"
)func main() {
info, err := finance.CheckIBAN("738120256174")
if err != nil {
fmt.Println("ERROR:", err.Error())
os.Exit(1)
}fmt.Println(info)
}
```