Created
January 11, 2019 04:06
-
-
Save spikeekips/70c0cce635ef3577a9660b710053d459 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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