money

package module
v2.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2016 License: MIT Imports: 3 Imported by: 3

README

Money

travis godoc

A golang library to deal with money and currency representation. Inspired by ruby money library.

Installation

$ go get github.com/joiggama/money

Usage

First, import the package adding:

import "github.com/joiggama/money"

Examples:

money.Format(10)                                                     // "$10.00"
money.Format(10, money.Options{"currency": "EUR"})                   // "€10.00"
money.Format(10, money.Options{"with_cents": false})                 // "$10"
money.Format(10, money.Options{"with_currency:" true })              // "$10.00 USD"
money.Format(10, money.Options{"with_symbol": false})                // "10.00"
money.Format(10, money.Options{"with_symbol_space":true})            // "$ 10.00"
money.Format(1000)                                                   // "$1,000.00"
money.Format(1000, money.Options{"with_thousands_separator": false}) // "$1000.00"

For more detailed documentation refer to godoc

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

The MIT licence

Documentation

Overview

Package money is a library to deal with money and currency representation. Inspired by ruby money library http://rubymoney.github.io/money.

Defaults

Options{
  "currency":                 "USD",
  "with_cents":               true,
  "with_currency":            false,
  "with_symbol":              true,
  "with_symbol_space":        false,
  "with_thousands_separator": true,
}

Usage

Format(10)                                               // "$10.00"
Format(10, Options{"currency": "EUR"})                   // "€10.00"
Format(10, Options{"with_cents": false})                 // "$10"
Format(10, Options{"with_currency:" true })              // "$10.00 USD"
Format(10, Options{"with_symbol": false})                // "10.00"
Format(10, Options{"with_symbol_space":true})            // "$ 10.00"
Format(1000)                                             // "$1,000.00"
Format(1000, Options{"with_thousands_separator": false}) // "$1000.00"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(val float64, opts ...Options) (result string)

Format returns a formatted price string according to currency rules and options

Types

type Options

type Options map[string]interface{}

Options is convenience shorthand for a map[string]interface{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL