From Bash to Golang: Elevate Your Terminal Experience with Tview
HTML-код
- Опубликовано: 17 окт 2024
- The DeFacto Golang Book - amzn.to/3Ytywpg
My Code - github.com/dev...
Tview Library - github.com/riv...
All my links - linktr.ee/devhulk
Learn how to create a user interface for your terminal using Golang. This Golang tutorial will show you how to create a simple user interface that allows you to easily navigate your terminal.
If you're looking for a way to increase the usability of your terminal, then this Golang tutorial is for you! By learning how to create a user interface in Golang, you'll be able to easily navigate your terminal and get the most out of your Golang development experience.
These days I don't build a lot of 'menu' based bash scripts anymore. Most of them are executed from other tools with already chosen parameters. Sometimes it get's for example just a job id and fetched extra metadata from a database or rest api, yes you can do stuff like that with bash as well ;)
Seperation of functions in a library in separated files is a step forward too, you don't need to put everything in one file, build nice generic functions and 'source' the files you need in your new script, just as you do with imports in Go.
The harder parts are stuff like return values from functions, so you can move on from the 'everything is global' to a more localized way of working. In the past years I figured out ways to fix those issues. Problem is you have to force yourself into a way of working, the language itself doesn't do that for you. No baby sitter available in Bash 😂
But I'm with you, I'm spending more time in Go and Python these days, makes a lot of work easier. But the mix of it can be quite powerfull, business logic in a more modern language and just simple task execution in bash.
Valid. I can’t say that I’ve ever built a bash menu for anything work related. That’s really why I did it in the first place lol. It’s fun to see the contrast between two approaches.
@@devhulk At the moment I'm using php a lot for writing devops scripts, it integrates well with a lot of linux cli stuff, can do databases easily, all kinds of key value stores, rest api's, it supports anything you can think of and most of it in core packages (so just package manager installable modules), so no hassle with dependency drama. It has good template engines so creating configuration files from templates is easy. And you can actually program readable stuff there with good error handling, you have the choice for procedural vs oo or a combination, not too much abstraction in it unless you create it yourself.
Wouldn't choose it for other projects but it works really nicely here. We tried Python combined with ansible for a while, not really my cup of tea, especially the ansible way of working. Python in itself is fine however it doesn't work as easily as php does. The latter gives you a lot of room for doing it your way.
Have you explored bubble tea , also a tui framework
I haven't but will have to check it out!
Cool video. That library looks neat as well.
Thank you! Was a fun one to make.
golang keeps getting exciting 🎉
Great language.
Great vid! Imagine my depression when I started a new job and we weren't allowed to use Golang for any production use cases.
Thanks! And that sucks, why? They just want to consolidate to one stack or? I'm always curious why different companies make these sorts of decisions.
@@devhulk they haven't got the security scanning setup and they see it as a risk!
@@mgd8867 seems like a simple problem lol oh well 🤷♂️ 😂
Finally found someone who is also devops, and using bash and want to move to go :)
Hello brethren :)
Hej man :) will you be creating some more stuff with bash go?
i like your video editing
Thank you 🙏
bash rocks!
📠
I agree, it's a really sharp tool in the toolbox but not meant for everything. But you can do more with it than most people know.
As with any language it's more efficient if you build/get yourself a library of reusable code.
Everyone starting with bash hates it first, , it is quirky sometimes, later on it's something you can not do without anymore. Especially the oneliners are quite fun 😇
Go wins and you didn’t even have unit testing as a criteria. With unit tests added I wonder how nasty that simple bash script becomes.
The thought of Unit Testing in bash feels like a fever dream lol
Lack of tmux is going on
Yea, I like tmux but iterm does good enough 90% of the time unless I'm remoting into a machine. When I context switch to "devops" work tmux pops into my workflow much more.
Даже тут го гавно. Баш скрипт куда проще будет прочитать и понять чем вот эти кучи хитросплетений GO