Skip to content

andrewheberle/iecbyte

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iecbyte

Go Report Card GoDoc codecov

This package provides a Flag type that can be used as a custom flag for flag and github.com/sp13/pflag as it satisifes the flag.Value and pflag.Value interfaces.

Command line flag values may be as either a plain, non-negative integer or as a positive fixed-point number using one of these quantity suffixes: Ei, Pi, Ti, Gi, Mi, Ki.

For example the following all represent the same value:

  • 2147483648
  • 2097152Ki
  • 2048Mi
  • 2Gi

Example

package main

import (
    "flag"

    "github.com/andrewheberle/iecbyte"
)

func main() {
	size := iecbyte.NewFlag(1024 * 1024)

	flag.Var(&size, "size", "Size in IEC bytes")
	flag.Parse()

	fmt.Printf("Size is %s\n", size)
	// Output: Size is 1Mi
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages