Skip to content

Instantly share code, notes, and snippets.

@spikeekips
Created January 11, 2019 04:06
Show Gist options
  • Select an option

  • Save spikeekips/70c0cce635ef3577a9660b710053d459 to your computer and use it in GitHub Desktop.

Select an option

Save spikeekips/70c0cce635ef3577a9660b710053d459 to your computer and use it in GitHub Desktop.
// gonToBOS prints with dot for GON.
func gonToBOS(i interface{}) string {
var s string
switch i.(type) {
case uint64:
s = strconv.FormatUint(i.(uint64), 10)
case common.Amount:
s = i.(common.Amount).String()
}
if len(s) < 7 {
return fmt.Sprintf(
"0.%s%s",
strings.Repeat("0", 7-len(s)),
s,
)
}
if len(s) == 7 {
return fmt.Sprintf("0.%s", s)
}
return fmt.Sprintf("%s.%s", s[:len(s)-7], s[len(s)-7:])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment