GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

/

line_reader.go

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
38 lines (32 loc) · 730 Bytes
/

line_reader.go

Copy path

File metadata and controls

38 lines (32 loc) · 730 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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.