Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for NewReader (0.17 sec)

  1. src/archive/tar/example_test.go

    		if _, err := tw.Write([]byte(file.Body)); err != nil {
    			log.Fatal(err)
    		}
    	}
    	if err := tw.Close(); err != nil {
    		log.Fatal(err)
    	}
    
    	// Open and iterate through the files in the archive.
    	tr := tar.NewReader(&buf)
    	for {
    		hdr, err := tr.Next()
    		if err == io.EOF {
    			break // End of archive
    		}
    		if err != nil {
    			log.Fatal(err)
    		}
    		fmt.Printf("Contents of %s:\n", hdr.Name)
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Thu Nov 16 16:54:08 GMT 2017
    - 1.4K bytes
    - Viewed (0)
  2. src/bufio/example_test.go

    		fmt.Fprintln(os.Stderr, "reading standard input:", err)
    	}
    }
    
    // Return the most recent call to Scan as a []byte.
    func ExampleScanner_Bytes() {
    	scanner := bufio.NewScanner(strings.NewReader("gopher"))
    	for scanner.Scan() {
    		fmt.Println(len(scanner.Bytes()) == 6)
    	}
    	if err := scanner.Err(); err != nil {
    		fmt.Fprintln(os.Stderr, "shouldn't see an error scanning a string")
    	}
    	// Output:
    	// true
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Mon Oct 23 09:06:30 GMT 2023
    - 4.9K bytes
    - Viewed (0)
  3. src/bytes/example_test.go

    	// Output:
    	// 'Gjnf oevyyvt naq gur fyvgul tbcure...
    }
    
    func ExampleReader_Len() {
    	fmt.Println(bytes.NewReader([]byte("Hi!")).Len())
    	fmt.Println(bytes.NewReader([]byte("こんにちは!")).Len())
    	// Output:
    	// 3
    	// 16
    }
    
    func ExampleRepeat() {
    	fmt.Printf("ba%s", bytes.Repeat([]byte("na"), 2))
    	// Output: banana
    }
    
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Mon Mar 04 15:54:40 GMT 2024
    - 15K bytes
    - Viewed (1)
Back to top