CIOが増殖中

イメージ
急速充電器が増えてきて面倒…  スマートフォン、ノートPCなど増えてきて、標準の充電器ってかさばるし、持ち運ぶのも邪魔。 そこで、電源タップ付きのものや、小形でMacbookProに充電できるものを探して購入。 気づいたら、CIO製品が増加していた。 持ち運び用 (1)  https://amzn.to/4d83MBV (2)  https://amzn.to/3P3B9xZ 自宅用 (3)  https://amzn.to/42WLezS どれも、それ程かさばらず、重宝しています。 電源タップが必要な場合は、(2)を持っていくけれど、ほとんどの場合は(1)のみでOK。 1ポートなら67W出力可能なので、全く問題なし。 2ポート以上使用しても、45W出力してくれるので、困ることはない。 (2) の場合は、延長ケーブルも持って歩くことが多いかなぁ。 1m程のケーブルが有ると、電源が取りにくい場所でも、なんとかなる。 という感じです。 ゼロハリのアタッシュケース自体が重いので、なるべく軽くするために(1)が常用です。 UGREENとかAnkerとかも良さそうなだけど、今の所CIOばかり増殖していますねぇ。

csvqのbuild

使おうと思ったら、無かった…

以前あまりに便利だったので、buildして使っていた「csvq」だけど、マシンを入れ替えた際に入れ忘れていたらしい…。

前にbuildした時は、さっくりと動作したので、最新バージョンを持ってきてbuildすればいいやぁと思って作業してみると、エラーを吐きまくる。
バイナリ持ってきてきても良いけど、時間がある今なので、頑張ってみることにした。


Installation

Install executable binary
Download an archive file from release page.
Extract the downloaded archive and add a binary file in it to your path.
Build from source
Requirements

Go 1.11 or later (ref. Getting Started - The Go Programming Language)
Build with one of the following ways
Use go get
$ go get github.com/mithrandie/csvq
Build with strict dependencies
$ go get -d github.com/mithrandie/csvq
Change directory to $GOPATH/src/github.com/mithrandie/csvq
$ env GO111MODULE=on go install




githubに書かれているとおりに、

$ go get github.com/mithrandie/csvq



すると、以下のようなエラーが大量に…。

$ go get github.com/mithrandie/csvq

# github.com/mithrandie/csvq

../../go/src/github.com/mithrandie/csvq/main.go:35:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:39:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:44:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:48:15: cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in slice literal:
cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:52:18: cannot use cli.Float64Flag literal (type cli.Float64Flag) as type cli.Flag in slice literal:
cli.Float64Flag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:57:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:61:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:66:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:71:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:75:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:75:17: too many errors


しかも、最後の行を見るとtoo many errorsとか言ってくるし…。


さて、このErrorの理由をググってみると、

こんな情報をゲット。


良くわからないが、該当する行を全て書き換えてみる。

main.goのAppFlag内のcli.〜に該当する部分を全て&を先頭に付加。

保存して、buildしてみる。


$ make

GOPATH=/home/yoshimura/go/src/github.com/mithrandie/csvq/build go build -ldflags="-X github.com/mithrandie/csvq/lib/query.Version=v1.13.3-3-g119a62d" -o /home/yoshimura/go/src/github.com/mithrandie/csvq/build/bin/csvq
go: downloading github.com/urfave/cli v1.20.0
go: downloading github.com/mithrandie/ternary v1.1.0
go: downloading github.com/mithrandie/go-text v1.3.1
go: downloading github.com/mitchellh/go-homedir v1.0.0
go: downloading github.com/mithrandie/go-file/v2 v2.0.2
go: downloading golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869
go: downloading github.com/mithrandie/readline-csvq v1.1.1
go: downloading golang.org/x/text v0.3.1
go: downloading golang.org/x/sys v0.0.0-20191029155521-f43be2a4598c


おっ!無事に通った。

build/bin/ を確認すると、csvqが出来上がっている。


念の為、バージョンを確認。

$ ./csvq -v

csvq version v1.13.3-3-g119a62d

ちゃんと、出来上がっているようだ。


helpもInteractiveモードも動作する。


試しに、test.csvを作成し、SQLを叩いてみる。
https://qiita.com/mithrandie/items/146564e748ee235709c0


$ ./csvq
> select * from `test.csv`
+----+------------------+-----------+
| id |       name       | parent_id |
+----+------------------+-----------+
| 1  | ラダトーム       |   NULL    |
| 2  | りゅうおうのしろ |   NULL    |
| 3  | ガライ           | 1         |
| 4  | マイラ           | 1         |
| 5  | リムルダール     | 1         |
| 6  | ドムドーラ       | 1         |
| 7  | メルキド         | 1         |
| 8  | あめのほこら     | 4         |
| 9  | せいなるほこら   | 5         |
+----+------------------+-----------+


問題はなさそう…。

ということで、こいつは~/binに格納しておく。


ただ、ダウンロードしたバイナリと比較してみると微妙にサイズが異なるので、少々心配だけど、動けばOKなので、良しとする。

ちなみに、
csvq-v1.13.1-linux-amd64.tar.gz 内のcsvqは、15,672,673 バイト
自分でbuildしたものは14,517,598バイトなのは、何故かなぁ〜?

ダウンロードしたバイナリのバージョンは、1.13.1とsrcの方が若干新しいのかもしれないと言うことにしておこう。



コメント

このブログの人気の投稿

Ubuntu24.04 でGUIが死んだ

VirtualBoxが異常

MEGAにも弱点があった?