Comments (1)
I saw this too and was confused. For example if I'm trying to extract some disk details:
$ nvme list -o json | gron -v
panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
main.gronValues({0xc000126070?, 0xc00012a010?}, {0xc000142170?, 0x7555d8?}, 0x1?)
github.com/tomnomnom/gron/main.go:411 +0x27f
main.main()
github.com/tomnomnom/gron/main.go:178 +0x6bc
The solution is to run gron twice in a row:
$ nvme list -o json | gron | gron -v
/dev/nvme0n1
0
0
1
0
Non-Volatile memory controller: Toshiba Corporation NVMe SSD Controller
1
0
/dev/nvme1n1
1
0
1
0
Non-Volatile memory controller: Toshiba Corporation NVMe SSD Controller
1
0
I think this was probably missed because in practice you'd never use gron by itself, it's meant to be combined with grep, so you'd do something like:
nvme list -o json | gron | grep SerialNumber | gron --values
This is alluded to in the comments:
Lines 401 to 404 in badf401
but not in the docs and it threw me off too. Maybe it can be explained with an example, or mentioning "Print just the values of gron-format assignments"?
And also it would be better not to panic at all. If the input format is wrong maybe that can become an error message explaining that the format is wrong.
from gron.
Related Issues (20)
- --no-sort option is unstable HOT 5
- Ungron doesn't respect --no-sort option HOT 1
- Output format HOT 12
- more tollerance when parsing
- Remove this HOT 1
- Export functions? HOT 1
- asdf gron
- Colour - Support Highlighting when Ungronning from grep.
- Bash completions HOT 1
- gron will fail to link at runtime once OpenBSD removes syscall(2)
- Auto-provide command line completions
- `--no-sort` should apply on each line when using `-s`
- github client downloa
- Feature Request: Support for Ruby syntax HOT 4
- failed to form statements: invalid character 'ï' looking for beginning of value HOT 3
- Binary builds broken?? HOT 4
- Add release for armv6l
- Special-case `new Array()` and `new Object`
- v0.7.1 does not report its own version HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gron.