diff --git a/README.md b/README.md new file mode 100644 index 0000000..580c7bd --- /dev/null +++ b/README.md @@ -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 ` with `-n -1` + for end. diff --git a/cmd/tail/.gitignore b/cmd/tail/.gitignore new file mode 100644 index 0000000..e84fa9b --- /dev/null +++ b/cmd/tail/.gitignore @@ -0,0 +1 @@ +tail diff --git a/cmd/tail/Makefile b/cmd/tail/Makefile new file mode 100644 index 0000000..2ccd60c --- /dev/null +++ b/cmd/tail/Makefile @@ -0,0 +1,4 @@ +default: tail + +tail: *.go + GOPATH=~/as/logyard go build diff --git a/cmd/tail/main.go b/cmd/tail/main.go new file mode 100644 index 0000000..86dfb6b --- /dev/null +++ b/cmd/tail/main.go @@ -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) + } +}