import ( "bytes" "github.com/tinylib/msgp/msgp" ) func readInt64FromBytes(data []byte) (int64, error) { reader := msgp.NewReader(bytes.NewReader(data)) return reader.ReadInt64() }
import ( "os" "github.com/tinylib/msgp/msgp" ) func readInt64sFromFile(path string) ([]int64, error) { f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() reader := msgp.NewReader(f) var result []int64 for { i, err := reader.ReadInt64() if err == io.EOF { break } else if err != nil { return nil, err } result = append(result, i) } return result, nil }This example shows how to read multiple 64-bit integer values from a file containing MessagePack-encoded data. The `ReadInt64` method is called in a loop until the end of file is reached (`io.EOF`). Each integer value is appended to a slice, which is returned after all integers have been read.