Skip to content

Commit

Permalink
mark readme code snippets as a golang code
Browse files Browse the repository at this point in the history
  • Loading branch information
satyrius committed Nov 11, 2013
1 parent 15757ff commit 7ee6baa
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,27 @@ The library provides `Reader` type and two constructors for it.

Common constructor `NewReader` gets opened file (`io.Reader`) and log format (`string`) as argumets. format is in form os nginx `log_format` string.

reader := gonx.NewReader(file, format)
```go
reader := gonx.NewReader(file, format)
```

`NewNginxReader` provides mo magic. It gets nginx config file (`io.Reader`) as second argument and `log_format` name (`string`) a third.

reader := gonx.NewNginxReader(file, nginxConfig, format_name)
```go
reader := gonx.NewNginxReader(file, nginxConfig, format_name)
```

`Reader` implements `io.Reader`. Here is example usage

for {
rec, err := reader.Read()
if err == io.EOF {
break
}
// Process the record... e.g.
```go
for {
rec, err := reader.Read()
if err == io.EOF {
break
}
// Process the record... e.g.
}
```

See more examples in `example/*.go` sources.

Expand All @@ -48,4 +54,4 @@ This library API and internal representation can be changed at any moment, but I

## Contributing

Fork the repo, create a feature branch then send me pull request. Feel free to create new issues or contact me using email.
Fork the repo, create a feature branch then send me pull request. Feel free to create new issues or contact me using email.

0 comments on commit 7ee6baa

Please sign in to comment.