Skip to content

Latest commit

 

History

History
94 lines (63 loc) · 2.03 KB

README.md

File metadata and controls

94 lines (63 loc) · 2.03 KB

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)

}