Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. type BigInt big.Int
  2.  
  3. // String casts BigInt into big.Int and uses its String method.
  4. func (b *BigInt) String() string {
  5. bc := big.Int(*b)
  6. return bc.String()
  7. }
  8.  
  9. // UnmarshalJSON casts BigInt into big.Int and uses its UnmarshalJSON method.
  10. func (b *BigInt) UnmarshalJSON(text []byte) error {
  11. bc := new(big.Int)
  12. err := bc.UnmarshalJSON(text)
  13. if err != nil {
  14. return err
  15. }
  16. b = b.Set(bc)
  17. return nil
  18. }
  19.  
  20. // Set is different from big.Int.Set() in that you must use the value it returns
  21. func (b *BigInt) Set(i *big.Int) *BigInt {
  22. iB := BigInt(*i)
  23. b = &iB
  24. return b
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement