Standard library / math/big

big.Int.GobDecode()

Decode gob integer data into the receiver, returning an error for invalid input. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '-42\n'.

Formal Syntax & Structure

go syntaxgo
func (z *Int) GobDecode(buf []byte) error

Parameters & Attributes

NameTypeDescription
buf[]byteByte buffer or encoded data, as specified in the method contract.

Return Value

error

Returns the result described above; see the example for the observed behavior.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func check(err error) {  if err != nil {    panic(err)  }}func main() {  b, e := big.NewInt(-42).GobEncode()  check(e)  z := new(big.Int)  check(z.GobDecode(b))  fmt.Println(z)}
Go Reference