1
0
hugo/content/blog/2019-12-25-xq.md

41 lines
1.0 KiB
Markdown
Raw Normal View History

2024-04-23 13:21:26 +00:00
+++
date = "2019-12-25"
tags = ["golang"]
title = "golangで作ったxqをアップデートした"
slug = "golang-xq"
+++
xqはxmlをjsonに変換するコマンドラインツールです。必要があったので必要な分だけ作ったやつ。
https://github.com/syui/xq
```sh
$ go get -v -u github.com/syui/xq
$ xq -v
xq version 0.3.4
$ curl -sLO https://syui.cf/blog/index.xml
$ xq ./index.xml | jq .
```
ですが、今回、その名の通り`[q]uery`できるようにしてみました、一部ですが。
具体的には、latestのデータをsub-commandで抽出できるようになります。
```sh
$ xq l l ./index.xml
https://syui.cf/blog/post/2019/12/24/music/
$ xq p ./index.xml
Tue, 24 Dec 2019 00:00:00 +0000
$ xq u ./index.xml
Tue, 24 Dec 2019 00:00:00 +0000
```
これも単に[ArchLinuxJP/archtrans-jp](https://github.com/ArchLinuxJP/archtrans-jp)の`jq`依存を解消したかったので追加しただけだったりします。
あと、xmlのpublish(latest)とupdateって違うんですね。勘違いしてた。