Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ jobs:
test-build:
strategy:
matrix:
go-version: [1.21.x, 1.20.x, 1.19.x, 1.18.x]
os: [ubuntu-20.04, macos-latest, windows-latest]
go-version: [1.26.x, 1.25.x]
os: [ubuntu-22.04, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Test
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unreleased
* PR #1: possible line loss and duplication when file is renamed.

# Version v1.4.11
* Bump fsnotify to v1.6.0. Should fix some issues.

Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
FROM golang

RUN mkdir -p $GOPATH/src/github.com/nxadm/tail/
ADD . $GOPATH/src/github.com/nxadm/tail/
RUN mkdir -p $GOPATH/src/github.com/tarantool/go-tail/
ADD . $GOPATH/src/github.com/tarantool/go-tail/

# expecting to fetch dependencies successfully.
RUN go get -v github.com/nxadm/tail
RUN go get -v github.com/tarantool/go-tail

# expecting to run the test successfully.
RUN go test -v github.com/nxadm/tail
RUN go test -v github.com/tarantool/go-tail

# expecting to install successfully
RUN go install -v github.com/nxadm/tail
RUN go install -v github.com/nxadm/tail/cmd/gotail
RUN go install -v github.com/tarantool/go-tail
RUN go install -v github.com/tarantool/go-tail/cmd/gotail

RUN $GOPATH/bin/gotail -h || true

Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[![Go Reference](https://pkg.go.dev/badge/github.com/nxadm/tail.svg)](https://pkg.go.dev/github.com/nxadm/tail#section-documentation)
![ci](https://github.com/nxadm/tail/workflows/ci/badge.svg)
[![FreeBSD](https://api.cirrus-ci.com/github/nxadm/tail.svg)](https://cirrus-ci.com/github/nxadm/tail)
[![Go Reference](https://pkg.go.dev/badge/github.com/tarantool/go-tail.svg)](https://pkg.go.dev/github.com/tarantool/go-tail#section-documentation)
![ci](https://github.com/tarantool/go-tail/workflows/ci/badge.svg)
# tail functionality in Go

nxadm/tail provides a Go library that emulates the features of the BSD `tail`
tarantool/go-tail provides a Go library that emulates the features of the BSD `tail`
program. The library comes with full support for truncation/move detection as
it is designed to work with log rotation tools. The library works on all
operating systems supported by Go, including POSIX systems like Linux, *BSD,
Expand All @@ -25,11 +24,11 @@ for line := range t.Lines {
}
```

See [API documentation](https://pkg.go.dev/github.com/nxadm/tail#section-documentation).
See [API documentation](https://pkg.go.dev/github.com/tarantool/go-tail#section-documentation).

## Installing

go get github.com/nxadm/tail/...
go get github.com/tarantool/go-tail/...

## History

Expand Down
6 changes: 4 additions & 2 deletions cmd/gotail/gotail.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Copyright (c) 2026 FOSS contributors of https://github.com/tarantool/go-tail
// Copyright (c) 2019 FOSS contributors of https://github.com/nxadm/tail
// Copyright (c) 2015 HPE Software Inc. All rights reserved.
// Copyright (c) 2013 ActiveState Software Inc. All rights reserved.
Expand All @@ -7,9 +8,10 @@ package main
import (
"flag"
"fmt"
"io"
"io"
"os"
"github.com/nxadm/tail"

"github.com/tarantool/go-tail"
)

func args2config() (tail.Config, int64) {
Expand Down
2 changes: 1 addition & 1 deletion examples/01-tailAndPrint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package main
import (
"fmt"

"github.com/nxadm/tail"
"github.com/tarantool/go-tail"
)

var logFile = "/var/log/syslog"
Expand Down
2 changes: 1 addition & 1 deletion examples/02-closeAndReopen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"time"

"github.com/nxadm/tail"
"github.com/tarantool/go-tail"
)

var logFile = "/var/log/syslog"
Expand Down
8 changes: 4 additions & 4 deletions examples/03-consumeJSON/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"io/ioutil"
"os"
"strconv"
"github.com/nxadm/tail"

"github.com/tarantool/go-tail"
)

type jsonStruct struct {
Expand All @@ -36,13 +36,13 @@ func main() {
go createJSON(file)
var js jsonStruct
for line := range t.Lines {
fmt.Printf("JSON: " + line.Text + "\n")
fmt.Println("JSON: " + line.Text)

err := json.Unmarshal([]byte(line.Text), &js)
if err != nil {
panic(err)
}
fmt.Printf("JSON counter field: " + js.Counter + "\n")
fmt.Println("JSON counter field: " + js.Counter)
}
}

Expand Down
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module github.com/nxadm/tail
module github.com/tarantool/go-tail

go 1.13
go 1.25.7

require (
github.com/fsnotify/fsnotify v1.6.0
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
)

require golang.org/x/sys v0.0.0-20220908164124-27713097b956 // indirect
25 changes: 17 additions & 8 deletions tail.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Copyright (c) 2026 FOSS contributors of https://github.com/tarantool/go-tail
// Copyright (c) 2019 FOSS contributors of https://github.com/nxadm/tail
// Copyright (c) 2015 HPE Software Inc. All rights reserved.
// Copyright (c) 2013 ActiveState Software Inc. All rights reserved.

//nxadm/tail provides a Go library that emulates the features of the BSD `tail`
//program. The library comes with full support for truncation/move detection as
//it is designed to work with log rotation tools. The library works on all
//operating systems supported by Go, including POSIX systems like Linux and
//*BSD, and MS Windows. Go 1.9 is the oldest compiler release supported.
// tarantool/go-tail provides a Go library that emulates the features of the BSD `tail`
// program. The library comes with full support for truncation/move detection as
// it is designed to work with log rotation tools. The library works on all
// operating systems supported by Go, including POSIX systems like Linux and
// *BSD, and MS Windows. Go 1.9 is the oldest compiler release supported.
package tail

import (
Expand All @@ -21,10 +22,11 @@ import (
"sync"
"time"

"github.com/nxadm/tail/ratelimiter"
"github.com/nxadm/tail/util"
"github.com/nxadm/tail/watch"
"gopkg.in/tomb.v1"

"github.com/tarantool/go-tail/ratelimiter"
"github.com/tarantool/go-tail/util"
"github.com/tarantool/go-tail/watch"
)

var (
Expand Down Expand Up @@ -383,6 +385,13 @@ func (tail *Tail) waitForChanges() error {
}
}

// The write event should be handled first.
select {
case <-tail.changes.Modified:
return nil
default:
}

select {
case <-tail.changes.Modified:
return nil
Expand Down
2 changes: 2 additions & 0 deletions tail_posix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Copyright (c) 2026 FOSS contributors of https://github.com/tarantool/go-tail
// Copyright (c) 2019 FOSS contributors of https://github.com/nxadm/tail
//go:build !windows
// +build !windows

package tail
Expand Down
5 changes: 3 additions & 2 deletions tail_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Copyright (c) 2026 FOSS contributors of https://github.com/tarantool/go-tail
// Copyright (c) 2019 FOSS contributors of https://github.com/nxadm/tail
// Copyright (c) 2015 HPE Software Inc. All rights reserved.
// Copyright (c) 2013 ActiveState Software Inc. All rights reserved.
Expand All @@ -17,8 +18,8 @@ import (
"testing"
"time"

"github.com/nxadm/tail/ratelimiter"
"github.com/nxadm/tail/watch"
"github.com/tarantool/go-tail/ratelimiter"
"github.com/tarantool/go-tail/watch"
)

func TestTailFile(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion tail_windows.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Copyright (c) 2026 FOSS contributors of https://github.com/tarantool/go-tail
// Copyright (c) 2019 FOSS contributors of https://github.com/nxadm/tail
//go:build windows
// +build windows

package tail

import (
"os"

"github.com/nxadm/tail/winfile"
"github.com/tarantool/go-tail/winfile"
)

// Deprecated: this function is only useful internally and, as such,
Expand Down
3 changes: 2 additions & 1 deletion util/util.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Copyright (c) 2026 FOSS contributors of https://github.com/tarantool/tail
// Copyright (c) 2019 FOSS contributors of https://github.com/nxadm/tail
// Copyright (c) 2015 HPE Software Inc. All rights reserved.
// Copyright (c) 2013 ActiveState Software Inc. All rights reserved.
Expand All @@ -19,7 +20,7 @@ var LOGGER = &Logger{log.New(os.Stderr, "", log.LstdFlags)}

// fatal is like panic except it displays only the current goroutine's stack.
func Fatal(format string, v ...interface{}) {
// https://github.com/nxadm/log/blob/master/log.go#L45
// https://github.com/hpcloud/log/blob/master/log.go#L45
LOGGER.Output(2, fmt.Sprintf("FATAL -- "+format, v...)+"\n"+string(debug.Stack()))
os.Exit(1)
}
Expand Down
12 changes: 0 additions & 12 deletions vendor/github.com/fsnotify/fsnotify/.editorconfig

This file was deleted.

1 change: 0 additions & 1 deletion vendor/github.com/fsnotify/fsnotify/.gitattributes

This file was deleted.

6 changes: 0 additions & 6 deletions vendor/github.com/fsnotify/fsnotify/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions vendor/github.com/fsnotify/fsnotify/.mailmap

This file was deleted.

Loading
Loading