Skip to content

pflag-decimal implements a Golang pflag.Value interface for shopspring/decimal

License

Notifications You must be signed in to change notification settings

gbarr/pflag-decimal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pflag-decimal

Go Reference codecov Go ReportCard golangci-lint

pflag-decimal implements a Golang pflag.Value interface decimal values. Combining github.com/spf13/pflag with github.com/shopspring/decimal. This facilitiates command-line argument handling of date parameters such --value=123.45.

Documentation

go get github.com/gbarr/pflag-decimal

https://pkg.go.dev/github.com/gbarr/pflag-decimal

Example

package main

import (
	"fmt"

	pfdecimal "github.com/gbarr/pflag-decimal"
	"github.com/spf13/pflag"
)

func main() {
	var dec pfdecimal.Decimal
	pflag.VarP(&dec, "value", "v", "decimal value")
	pflag.Parse()
	fmt.Println("value:", dec.String())
}

Credits and License

Copyright (c) 2024 Graham Barr.

Released under the MIT License, see LICENSE.

About

pflag-decimal implements a Golang pflag.Value interface for shopspring/decimal

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages