GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — xray/line_reader.go at master · evilsocket/xray
This repository was archived by the owner on Jul 10, 2024. It is now read-only.
Expand file tree/ Copy pathline_reader.goMore file actions 38 lines (32 loc) · 730 Bytes / Copy pathline_reader.goFile metadata and controls38 lines (32 loc) · 730 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 package xray import ( "bufio" "fmt" "os" ) // LineReader will accept the name of a file and offset as argument // and will return a channel from which lines can be read // one at a time. func LineReader(filename string) (chan string, error) { fp, err := os.Open(filename) if err != nil { return nil, err } out := make(chan string) go func() { defer func() { if err = fp.Close(); err != nil { fmt.Printf("error closing %s: %v\n", filename, err) } }() // we need to close the out channel in order // to signal the end-of-data condition defer close(out) scanner := bufio.NewScanner(fp) scanner.Split(bufio.ScanLines) for scanner.Scan() { out <- scanner.Text() } }() return out, nil } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |