|
1 | | -# gotf - go time format |
| 1 | +# gotf - go time formatter |
2 | 2 |
|
3 | 3 | `gotf` converts epoch times in inputs to human readable strings |
4 | 4 | and outputs them to stdout. |
5 | 5 |
|
6 | 6 | ``` |
7 | 7 | $ gotf --help |
| 8 | +usage: ./gotf <options> [file1 [file2 [...]]] |
8 | 9 |
|
| 10 | +GOlang Time Formatter |
| 11 | +
|
| 12 | +Reads text files, converting epoch times to human readable, outputting to stdout. |
| 13 | +
|
| 14 | +10-digits are interpreted as seconds, 13 as milliseconds, |
| 15 | +16 as microseconds, and 19 as nanoseconds. |
| 16 | +
|
| 17 | +If no filenames or only '-' is passed, stdin is processed. |
| 18 | +
|
| 19 | +example: |
| 20 | +echo 1637421447 | gotf |
| 21 | +
|
| 22 | +gotf -g log.txt | head |
| 23 | +
|
| 24 | + -b, --block use block buffering (default: line buffering) |
| 25 | + -d, --date default format with '2006-01-02 15:04:05' |
| 26 | + -f, --format string golang Time.Format string (default: '15:04:05') |
| 27 | + -g, --global global match |
| 28 | + -h, --help show help``` |
| 29 | +``` |
| 30 | + |
| 31 | +---- |
| 32 | + |
| 33 | +## Installing |
| 34 | + |
| 35 | +Binaries for multiple platforms are [released on GitHub](https://github.com/neomantra/gotf/releases) through [GitHub Actions](https://github.com/neomantra/gotf/actions). |
| 36 | + |
| 37 | +You can also install for various platforms with [Homebrew](https://brew.sh) from [`neomantra/homebrew-tap`](https://github.com/neomantra/homebrew-tap): |
| 38 | + |
| 39 | +``` |
| 40 | +brew tap neomantra/homebrew-tap |
| 41 | +brew install gotf |
| 42 | +``` |
| 43 | + |
| 44 | +---- |
| 45 | + |
| 46 | +## Example Usage |
| 47 | + |
| 48 | +Raw log: |
| 49 | +``` |
| 50 | +$ cat log.txt |
| 51 | +[1524241219] Time is on my side |
| 52 | +[1555777220] Yes it is |
| 53 | +[1587399621] A time in ecpoch millis: 1637419929123 |
| 54 | +[1618935621] A time in ecpoch nanos: 1637419929123456789 |
| 55 | +``` |
| 56 | + |
| 57 | +Basic usage, piping from `stdin`: |
| 58 | +``` |
| 59 | +$ cat log.txt | gotf |
| 60 | +[12:20:19] Time is on my side |
| 61 | +[12:20:20] Yes it is |
| 62 | +[12:20:21] A time in ecpoch millis: 1637419929123 |
| 63 | +[12:20:21] A time in ecpoch nanos: 1637419929123456789 |
9 | 64 | ``` |
10 | 65 |
|
11 | | -# Building |
| 66 | +Date conversion: |
| 67 | +``` |
| 68 | +$ gotf -d log.txt |
| 69 | +[2018-04-20 12:20:19] Time is on my side |
| 70 | +[2019-04-20 12:20:20] Yes it is |
| 71 | +[2020-04-20 12:20:21] A time in ecpoch millis: 1637419929123 |
| 72 | +[2021-04-20 12:20:21] A time in ecpoch nanos: 1637419929123456789 |
| 73 | +```` |
12 | 74 |
|
| 75 | +Global match, converting sub-second times: |
13 | 76 | ``` |
14 | | -./build.sh |
| 77 | +$ gotf -gd log.txt |
| 78 | +[2018-04-20 12:20:19] Time is on my side |
| 79 | +[2019-04-20 12:20:20] Yes it is |
| 80 | +[2020-04-20 12:20:21] A time in ecpoch millis: 2021-11-20 09:52:09.123 |
| 81 | +[2021-04-20 12:20:21] A time in ecpoch nanos: 2021-11-20 09:52:09.123456789 |
15 | 82 | ``` |
| 83 | +---- |
| 84 | +
|
| 85 | +## Building |
| 86 | +
|
| 87 | +This [simple script](./build.sh) will run unit tests and build the `gotf` binary for your plaftorm. |
| 88 | +
|
| 89 | +``` |
| 90 | +$ ./build.sh |
| 91 | ++ set -e |
| 92 | ++ go test neomantra/gotf/internal/gotf |
| 93 | +ok neomantra/gotf/internal/gotf (cached) |
| 94 | ++ go build -o gotf cmd/gotf/main.go./build.sh |
| 95 | +``` |
| 96 | +
|
| 97 | +---- |
16 | 98 |
|
17 | | -# Credits and License |
| 99 | +## Credits and License |
18 | 100 |
|
19 | 101 | Copyright (c) 2021 Neomantra BV |
20 | 102 |
|
|
0 commit comments