| // Copyright 2011 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| err := binary.Write(buf, binary.LittleEndian, pi) |
| fmt.Println("binary.Write failed:", err) |
| fmt.Printf("% x", buf.Bytes()) |
| // Output: 18 2d 44 54 fb 21 09 40 |
| func ExampleWrite_multi() { |
| var data = []interface{}{ |
| err := binary.Write(buf, binary.LittleEndian, v) |
| fmt.Println("binary.Write failed:", err) |
| fmt.Printf("%x", buf.Bytes()) |
| b := []byte{0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0x09, 0x40} |
| buf := bytes.NewReader(b) |
| err := binary.Read(buf, binary.LittleEndian, &pi) |
| fmt.Println("binary.Read failed:", err) |
| // Output: 3.141592653589793 |