start working on tail's readme/example

This commit is contained in:
Sridhar Ratnakumar 2012-10-12 09:05:11 -07:00
parent 74f84016b8
commit f7193d4658
4 changed files with 41 additions and 0 deletions

18
README.md Normal file
View File

@ -0,0 +1,18 @@
# Tail implementation in Go
A Go package striving to emulate the BSD `tail` program.
```Go
t := tail.TailFile("/var/log/nginx.log", 1000, true, true)
for line := range t.Lines {
fmt.Println(line.Text)
}
```
## TODO
* tests
* command line program (`tail -f ...`)
* refactor: use Config? `NewTail(tail.Config{Filename: "", Follow: tail.FOLLOW_NAME})`
* refactor: get rid of 'end' flag; allow `-n <number>` with `-n -1`
for end.

1
cmd/tail/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
tail

4
cmd/tail/Makefile Normal file
View File

@ -0,0 +1,4 @@
default: tail
tail: *.go
GOPATH=~/as/logyard go build

18
cmd/tail/main.go Normal file
View File

@ -0,0 +1,18 @@
package main
import (
"fmt"
"logyard/tail"
)
var samplefile = "/Users/sridharr/Library/Logs/PyPM/1.3/PyPM.log"
func main() {
t, err := tail.TailFile(samplefile, 1000, true, true)
if err != nil {
panic(err)
}
for line := range t.Lines {
fmt.Println(line.Text)
}
}