fgdfg
This commit is contained in:
@@ -2,10 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ByteCount int
|
||||
@@ -86,7 +88,16 @@ func LimitReader(r io.Reader,n int) io.Reader {
|
||||
}
|
||||
}
|
||||
|
||||
// Проверка, что ByteCount действительно соответствует интерфейсу io.Writer
|
||||
var _ io.Writer = new(ByteCount)
|
||||
|
||||
var period = flag.Duration("period",1 * time.Second,"sleep period")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
fmt.Printf("Waiting %v...",period)
|
||||
time.Sleep(*period)
|
||||
fmt.Println()
|
||||
// var bc ByteCount
|
||||
// bc.Write([]byte("Hello dodik"))
|
||||
// fmt.Println(bc)
|
||||
@@ -99,14 +110,14 @@ func main() {
|
||||
// writer.Write([]byte("Hello Baga"))
|
||||
// fmt.Printf("Bytes %d",*count)
|
||||
|
||||
str := "hello"
|
||||
buf := make([]byte,100)
|
||||
reader := LimitReader(strings.NewReader(str),3)
|
||||
// str := "hello"
|
||||
// buf := make([]byte,100)
|
||||
// reader := LimitReader(strings.NewReader(str),3)
|
||||
// // n,_ := reader.Read(buf)
|
||||
// // reader := strings.NewReader(str)
|
||||
// n,_ := reader.Read(buf)
|
||||
// reader := strings.NewReader(str)
|
||||
n,_ := reader.Read(buf)
|
||||
fmt.Printf("Result is %d\n",n)
|
||||
fmt.Printf("String is %s",string(buf))
|
||||
// fmt.Printf("Result is %d\n",n)
|
||||
// fmt.Printf("String is %s",string(buf))
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user