Help us shape the future of Go! Take the 2026 Go Developer Survey

money

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2015 License: MIT Imports: 3 Imported by: 0

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.New(10)                                                     // "$10.00"
money.New(10, money.Options{"currency": "EUR"})                   // "€10.00"
money.New(10, money.Options{"with_cents": false})                 // "$10"
money.New(10, money.Options{"with_currency:" true })              // "$10.00 USD"
money.New(10, money.Options{"with_symbol": false})                // "10.00"
money.New(10, money.Options{"with_symbol_space":true})            // "$ 10.00"
money.New(1000)                                                   // "$1,000.00"
money.New(1000, money.Options{"with_thousands_separator": false}) // "$1000.00"

For more detailed documentation refer to godoc

Contributing

  1. Fork it ( https://github.com/joiggama/money/fork )
  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

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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

New 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