Skip to content

Finance related Go functions (e.g. exchange rates, VAT number checking, …)

License

Notifications You must be signed in to change notification settings

pieterclaerhout/go-finance

Folders and files

NameName
Last commit message
Last commit date
Feb 7, 2023
Oct 2, 2019
Oct 16, 2022
Oct 1, 2019
Oct 2, 2019
Oct 2, 2019
Oct 6, 2019
Oct 1, 2019
Oct 21, 2019
Nov 25, 2024
Nov 25, 2024
Oct 2, 2019
Oct 21, 2019
Oct 16, 2022
Oct 16, 2022

Repository files navigation

go-finance

Go Report Card Documentation license GitHub version GitHub issues

This is a Golang library which contains finance related functions.

Exchange Rates

The following example explains how to use this package to retrieve the exchange rates from ECB:

package main

import (
	"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. The following sample code shows how to do this:

package main

import (
	"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:

package main

import (
	"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)

}