🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

github.com/sun01822/currency_formatter

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/sun01822/currency_formatter

Source
Go Modules
Version
v1.0.2
Version published
Created
Source

Currency Formatter

Go Reference

A Go library for formatting currency values with custom symbols and formats.

Features

  • Format currency amounts with custom symbols and patterns
  • Supports negative values
  • Handles USD and MYR out of the box
  • Easily extendable for other currencies

Usage

Installation

go get github.com/sun01822/currency_formatter

Example

package main

import (
    "fmt"
    "github.com/sun01822/currency_formatter/currency"
    "github.com/sun01822/currency_formatter/types"
)

func main() {
    value := currency.FormatCurrency(types.Formatter{
        Amount:   -1234567.89,
        Currency: "MYR",
        Format:   "RM ###,###,###.##",
    })
    fmt.Println(value) // Output: -1,234,567.89RM
}

API

FormatCurrency(formatter types.Formatter) string

Formats the currency amount using the provided formatter.

types.Formatter

  • Amount (float64): The amount to format
  • Currency (string): Currency code (e.g., "USD", "MYR")
  • Format (string): Format string (e.g., "RM ###,###,###.##")

Supported Currencies

  • USD
  • MYR

License

Apache License 2.0

FAQs

Package last updated on 14 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts