4 ms·
Hay a quick dumb question, I have seen a lot of CLIs written in go recently, why do people prefer to write CLIs in go. On the other hand why did you write a CLI
by fazkan 10y ago
Hay a quick dumb question, I have seen a lot of CLIs written in go recently, why do people prefer to write CLIs in go. On the other hand why did you write a CLI in go....
I am comparing go with other scripting languages like python, which has all the libraries to write a CLI itself.
Is there any particular reason....
- weberc2 10y agoNot the OP, but Go also has those libraries, and it compiles to a single binary. This means I can write a tool and give it to you without needing to worry if you have the right version of Python installed, etc. Further, I can trivially cross-compile (if you're on Linux/ARM, I can build a binary for you on my Macbook via `GOOS=linux GOARCH=arm go build <project>`).
- swah 10y agoThat, and there are nice terminal libraries that work on Linux, OSX and Windows. https://github.com/nsf/godit https://github.com/nsf/godit
- zuzuleinen 10y agoHi, I'm the author. I'm still new to Go, so I haven't gone so far to check web applications let's say. I think a CLI would be the closest thing for me right now to start with. And I really wanted a way to block websites and add reminder quickly. Since I work as a programmer I always have a terminal open so it made sense for me. In the end, it was just a simple way to start learning Go.
- fazkan 10y agoso you could have done the same thing in python as well...
- zuzuleinen 10y agoI could, but now I'm learning Golang. The sole purpose of this project is to learn a new language.
- tylerpachal 10y agoMy team all use macOS, so it was really easy for me to write a CLI in Go (this library [1] is great), and then run go install to create a full-contained binary that I could distribute to everyone. People can put the binary somewhere on their PATH, for example: `/usr/local/bin`, and then be able to run it like any other shell command. If you already have python installed then it isn't too much trouble to run a .py file by doing python mycli.py But if you have a bin on your PATH you could just run mycli without having to install Go or any of the dependancies because they're bundled up in the binary. edit: I should add that it is possible to cross-compile with Go, so if someone on my team wasn't on the same OS as me I could support them as well [1] https://github.com/urfave/cli https://github.com/urfave/cli