Skip to content

Commit 011bb43

Browse files
committed
Update README and add test example file
1 parent 6137980 commit 011bb43

File tree

3 files changed

+106
-4
lines changed

3 files changed

+106
-4
lines changed

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "gotf",
9+
"type": "go",
10+
"request": "launch",
11+
"mode": "auto",
12+
"program": "${workspaceFolder}/cmd/gotf",
13+
"args": ["-g", "${workspaceFolder}/log.txt"],
14+
}
15+
]
16+
}

README.md

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,102 @@
1-
# gotf - go time format
1+
# gotf - go time formatter
22

33
`gotf` converts epoch times in inputs to human readable strings
44
and outputs them to stdout.
55

66
```
77
$ gotf --help
8+
usage: ./gotf <options> [file1 [file2 [...]]]
89
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
964
```
1065

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+
````
1274
75+
Global match, converting sub-second times:
1376
```
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
1582
```
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+
----
1698
17-
# Credits and License
99+
## Credits and License
18100
19101
Copyright (c) 2021 Neomantra BV
20102

log.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[1524241219] Time is on my side
2+
[1555777220] Yes it is
3+
[1587399621] A time in ecpoch millis: 1637419929123
4+
[1618935621] A time in ecpoch nanos: 1637419929123456789

0 commit comments

Comments
 (0)