Learn to Code In 5 Minutes a Day: Lesson 2
By Code with ADHD
- 3 minutes read - 438 wordsLesson 2: Write Your First Program, aka Hello, World
So yesterday we learned how to install golang.
If you haven’t done that yet, go do that.
Goals Today:
- write your first go program.
- build the habit of spending 5 minutes a day learning.
Let’s get started:
In this course I’m going to spend most of my time giving high level directions and trust your ADHD will take you down rabbit holes as you get curious about things. This is totally normal and part of the learning process.
Remember, if you just type what you see on the screen, you are not learning.
Today we are going to build the most simple program possible. It will just say “hello, world” when you run it.
So fire up a text editor or IDE and let’s create a file called “hello.go”
I’m intentionally not going to tell you which IDE or text editor. I will tell you that Microsoft Word is not (really) text editor.
You want something that can create .txt files. For example BBEdit on the mac, or TextPad on Windows or Visual Studio Code on any platform. But seriously, if you don’t know what a text editor is, go google it now and find one you enjoy writing in. Try them out and come back tomorrow for the rest of the lesson. There is no one right answer.
Got your text editor?
Now, go google how to write hello world in golang.
Seriously. I’ll give the solution tomorrow, but this course is not about giving you the answers (because then you won’t learn).
It’s about giving you the tools to figure out the answers yourself. Because, surprise surprise… 99% of programming is figuring out how to do things on your own. You want an activity where you just follow instructions, go work at a factory putting labels on beer bottles. (Boring!)
At a high level you will need to
- create a file called something like “hello.go”
- create a function called main()
- have that function print out the words “hello, world” when you run it.
It should behave something like this:
./hello
hello, world
Remember, if you get frustrated and you’ve put in your 5 minutes, walk away. Come back tomorrow. No one is judging you if this step takes you a day, a week, or a month. If you get sidetracked and end up researching the history of why the first program is “hello, world”… great! Totally normal for us ADHDers. Have fun.
When you finish this, we can move on to writing your first unit test (including what the heck is a unit test).
Next: Lesson 3