- Sort Score
- Result 10 results
- Languages All
Results 1 - 2 of 2 for ExampleRead (0.1 sec)
-
src/crypto/rand/example_test.go
package rand_test import ( "bytes" "crypto/rand" "fmt" ) // This example reads 10 cryptographically secure pseudorandom numbers from // rand.Reader and writes them to a byte slice. func ExampleRead() { c := 10 b := make([]byte, c) _, err := rand.Read(b) if err != nil { fmt.Println("error:", err) return } // The slice should now contain random bytes instead of only zeroes.
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue Mar 01 23:34:33 UTC 2016 - 621 bytes - Viewed (0) -
src/encoding/binary/example_test.go
err := binary.Write(buf, binary.LittleEndian, v) if err != nil { fmt.Println("binary.Write failed:", err) } } fmt.Printf("%x", buf.Bytes()) // Output: beefcafe } func ExampleRead() { var pi float64 b := []byte{0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0x09, 0x40} buf := bytes.NewReader(b) err := binary.Read(buf, binary.LittleEndian, &pi) if err != nil { fmt.Println("binary.Read failed:", err)
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Mon Dec 13 18:45:54 UTC 2021 - 3.2K bytes - Viewed (0)