What I learned creating a CLI with Go
Video size:
Abstract
For the last few months I’ve been contributing to a project on Github called Golings, which teaches Go through a CLI (Command Line Interface). This is my first open source contribution so I want to share some learnings with you.
Summary
-
Today we're going to talk about the Golings project. I will show you what this project do, how I built the iterative terminal, the challenge, I face it, what I learned. And even more to prove that a woman in tech can talk about technology.
-
Golings project is a CLi command line interface with exercise that will teach you how to program in go the project. Today I'm a fully backend developer in video streaming platform here in Brazil. Working with video streaming was my biggest dream the last year.
-
Open source can help you understand of how technology works. Get feedback as soon as faster. Show your code and ask what they think. Understand the go flow to the bug and how channels works. If you can contribute to open source projects, I believe that will help you a lot.
Transcript
This transcript was autogenerated. To make changes, submit a PR.
I'm so happy ive been here. And I confess that in stock
means a really hard challenge for me.
But I'm happy to have the coders to talk
about technology and golings,
and even more to prove that a
woman in tech can talk about technology.
Even your native language is in English. Okay,
I'll talk about what I learned in coding a Cli
in Golings. And here is our agenda.
Today we're going to talk about the Golings project. I will show
you what this project do,
how I built the iterative terminal,
the challenge, I face it, what I learned.
And yeah, here we have also cheers. But we
don't have a conqueror of a compiler program without tears,
am I right? Okay,
so about me. First I present myself for you
all. I am a software developer about five years I
began as a front end developer and today I'm
a fully backend developer in video
streaming platform here in Brazil. Called it global Play.
I forgot, but I am a brazilian girl
and working with video
streaming was my biggest dream the last year. And I'm happy
of being enabled in my first opportunity
to work with that. And I'm also
a guitar player in a funny rock band here in Brazil called
Chijalos Bayans. And in English it
means Baya bricks.
Baya is a brazilian stage name and
bricks is that red bricks
to build houses. So, okay,
let's go to the talk. The Golings
project is a CLi command line interface with
exercise that will teach you how to
program in go the project. Have some comments
like run that will compile the file with
an ahor and you have to fix the zehor. And when
you run the comment,
it will compile the file and tell you if
it's okay and if it has an error.
The least command to show all exercise that
is available for you to edit the files
and fix are hint. To give you a hint
about the exercise, you're stuck. Like here in the video I'm
doing the variables. One exercise
and this file have an error and I
have to fix it. So the challenge was
to build a watch comment with integrative modes
that I'm showing in this video. I have the
variables file. I have to fix this file.
And when I edit, the command
to run and compile must automatically been
run it. And I can also
type in terminal like this. I ask for a hint,
this one. And even I type something
in terminal. It must keep running my project so
I can save again and it will run and
try to compile the file I'm editing.
So what to do. I was thinking about
the order to solve the problems and so first
I built the functions to listen the file chance. And the
last one I created the iterative mode with
user inputs like that video we saw the
user typing hint comments.
Okay how to listen the file chains I
work with infinite loops, goho chains and fs
notify packager. The fs note five packager
is responsible for listening to operational system events
notifications. So I'm going to show you first how I created
the watch event functions and we're going
to use the fs notify packager here to create
a watcher and receiving a channel as a pattern.
Okay we golings to iterate with this channel but we
created a watcher here and this
watcher will return. I struct with some methods
and even structs that we can operate it.
And the last one I created I
formatted a string to a path that I want to watch.
This one I use the root example but tingling it
was the exercise folder.
The add method from our watcher that we creating
in the previous stage doesn't reach
subdirectors. So I'm here in the exercise
and I'm typing the file here
inside the anonymous functions one. So it
doesn't going to work because this
edge only listens to file changes
here. So I have to enter in every
folder here and adding my method.
So to enter inside every folder I'm
going to use the file path and walk jer method.
This directories is the file path here exercise and
it's going to run every folder here.
And when I check if it is
a deer I add this cohen deer
that I mean to my watcher list that
we creating in the previous stage.
So in terminal when I print I
inserted a print here inside the zip and it
looks like this picture here.
And the last one we're
going to iterate in our watch event destruct.
We're going to check if every ever changed here
and we're going to check if the event that my
system notification it was a right
event. So if it is right event I
golings to insert the file name in
my channel that I pass it as a padding my function okay
so here we have our function to watch all the directories
events this
way running every file
change. So when I type and I try
to fix some file the comment must
run automatically my file and tell me if
it's okay or is still broken.
Here is my
mind Cli body and I create
a channel,
a channel to pass as a pattern
to my watch event functions that I creating in the
previous stage I use infinite loop.
We're going to understand better why I have to use infinite
loop when we built the iterative mode, but we're
golings to use that to always keep running the exercise.
And I create a globo chin here because
it's the other process and I wanted to make more
things after the globo chin like
the iterative modes and here inside we have
range in this channel. So every time this
channel is updates I wanted to run the
run next exercise command and
the third is building the iterative mode and
I can resume this step in buffer
packager infinite loops switch case
to choose the right comments to run with
user inputs I'm
going to use the burfuel packager and this packager
implements functionality for buffer data input and
output and we have to build the iterative mode.
So we're going to need the reader types of dispackager
and methods to reach the user input.
So here I get the user input
read string until the user tag press
the enter the enter key and here
I have the CmG share variable and
sir here we have only
a switch case to decide what command
I golings to run with
user inputs here and if a user type list golings
to run this command hint going to run print hint
or maybe kit the program and
here is our mindfelling function step
that we built.
Yeah, so let's go to think
about the challenge I faced.
The first one was really understand what I have to
do. I think this is a good example that shows
how communication write skills are very important
because even I read the issue it
wasn't really clear to me how to build it,
because the first time I thought that I have to build
iterative modes like Cli
flex. So when the user
type a flag after watch
comment, I think it was to
enter in an iterative mode like type
watch trace a watch trace c.
So it wasn't what the
project boner means to say about
how to create watch command or
iterative terminal. I really understand what
I have to do. After the repository
owner showed me a video of how it works in
rust links is the same
project, but for the rest language. So after watching
it I really understand what I have to do.
And the second one, the time to
work on an open source project is difficult to manage.
I have my personal scheduling with tech communities,
family content production and work related
studies, and it took me about three months
to actually finish my contribution. I love
to work on it, but I wish I could do it
faster. Because when I come back to pick up where I
left off I often forgot what I was doing
or thinking. So for my
next contribution I have to better organize
my schedule to keep my constants and not
forget anything. And the last one I faced
concohense problems and operational system notifications
that we're going to show you. I'm going to show you now.
This was my problem. Here we have a file
that I am editing and check.
Pay attention here. And this is mobile.
And the left we have a simple code that represents
what we built into now. A channel.
A function that received a channel running in a goho chain.
Another goal hosting and a for iterating
in this channel that I pasted to understand which
file have changed.
So if a file is changed I want to print the file
name here. And after 2 seconds I want to finishing
my program. So pay attention
here. I saved my file about 1234
ive times. And my watch is in functions
only printed one. And after it finished.
And check this one again.
One, two.
I save it two times my file and
it printed only the finish.
So how channel works? How it
must works. When I create a channel
it receives the value like this
one. I created a channel with two
length of buffer. I insert one
two and iterate over it
to print it. So here is this print element
and here is that two the last element that it
passed to a variable.
The channel must work with this. So every
time I save a file change it must
inserting the channel. So if it
isn't inserting the event in my
channel. I think or my system notification
isn't working very well. Or maybe
or I think it can means system
problem with my machine,
with the me one chip or maybe
my code. But I faced this problem
with a long time and
thinking all the problems I face it or
all the things I develop it.
I thinking what I learned with that.
The first one is get feedback as soon
as faster. Talk it to people. Show your
code and ask what they think. Maybe they
can see things you're not seeing. Or teach you better ways
to do what you're doing.
Understand the go flow to the bug and how channels
works. I work with go but I don't write a
lot of code that use channel or handles with
operational sustain notifications. So this project helped
me a lot to understand how gold handles with
this context and open source.
Yes open source can help you a lot to understand
of how the universe of technology works.
It can turn a k in your head that
you can also participate in discussions of
tools that you use and you can create
something new and create together with other
people. I think it is an active
learning where you're looking for information on
how to do it and then you
apply to practice. Okay. So if
you can contribute to open source projects,
I believe that will help you a lot.
And thank you so much for watching my
talk until here. Thank you for
confidential, for accepting my talk and any
questions or comments you have. I am at your
disposal. You can find me on the network
as Leislim.
Usually my feet, my postures is important,
is from Brazil, but I also talk in English.
You can send me a message. Okay, see you.
Bye. Take care and thank you.