Learning go

Hello World I am not a pro writer. So I am teaching my self to learn go, also to do some advance malware analysis and reverse engineering. I guess If you want to learn something all you have to do is dedicate some time and effort into learning. You want run a marathon? Well you can’t just run a marathon by talking. It requires a certain effort and a lot of steps. How you get better at running, well I guess run faster, time is a determining factor of whether you are getting faster or not.

For me the Determining factor of learning another language is at least the ability to read it, maybe even do a few projects here and there. If you want to learn to code or get better with coding that means you need to practice. Without further to do, I am going to use this site: https://gobyexample.com/ for some of my resources. as I am learning more and more I will post the links here, that way when there is are some questions or while building code I can come back here. I am not trying to be a Mark Zuckerberg, instead I just like learning something new everyday. I am also going to be using w3 schools the link can be found here. https://www.w3schools.com/go/go_introduction.php

First: you need to make sure the computer has go installed. in order to check if go is installed or not. go to the terminal and type: go version

it will display back in the terminal the version number if you don’t have it the terminal is going to print an error message or something along those lines. if you don’t have it, this is when self thinking and how I learn works. I just type on Google or your favorite browser how to download go, but the link is here: https://go.dev/doc/install

Any way, once you have go installed, you might need a text editor, you can use Vscode, sublime, vi, etc… it goes down to choice and what is the task at hand. What I am going to do is basically create a directory and put my files there, later down the road, I might point that directory to Github and also save some of the files on Github basically as a back up and share with everyone. within that directory I am also going to create more folders. I created a directory called hello, then I cd into it. You can do this on Windows or Linux, I recommend doing this stuff with the terminal because it basically keep your terminal skills up to date. inside there create a file call it hello_world.go

inside the file type everything that it is inside the go by example. This is how I like to learn this by studying code that works. type this

package main

import “fmt”

func main() {
fmt.Println(“hello world”)
}

going through the example we can basically study what the code means, always break down everything to the lowest level possible when learning. according to callicoder. https://www.callicoder.com/golang-packages/#:~:text=In%20the%20most%20basic%20terms,files%2C%20or%20other%20Go%20packages.

a package is nothing more than a name.

import “fmt” it is nothing more than a library function from the go lang. What else is inside the “fmt” library? Well lots of stuff, here is great link explaining this stuff. https://pkg.go.dev/fmt

so if we want to display stuff out to the user, we need to use the fmt library basically, a lot of stuff is happening in the background. the application basically starts at function main(). again your use the fmt then a dot then the Println followed by parenthesis. inside the parenthesis we have a literal string inside the double quotes. you can also assigned literal strings to variables but I will write about variables some other time. if you noticed there are curly braces right next to function main, everything within the left curly brace and right curly brace is called a block of code that belongs to the function main. inside the same directory where you type the whole thing you can just type in the terminal go run hello_world.go

you will noticed that it will display back to the user hello world. you can also compile the code and make the file an executable file but telling the computer go build hello_world.go

then just run it in the terminal as an executable as follows: ./hello_world

Go is a very fast language and I will write everything I learn here. Any way, this is all for now. I would study why learn go, if you are new to coding type everything exactly how it is. if you type fmt.println with lower case p, you will get an error. learn from errors and what the errors means because it is also part of the learning process, knowing how to read errors will be helpful when you are debugging. which is a great skill to have and it helps you speed up your learning process.

This is all for now!

PEACE!

Very Respectfully,

Santi

4 thoughts on “Learning go

  1. Hi, i read your blog from time to time and i own a similar one and i was just curious if you get a lot of spam responses? If so how do you reduce it, any plugin or anything you can suggest? I get so much lately it’s driving me mad so any support is very much appreciated.

  2. Hey there I am so happy I found your site, I really found you by error, while I was researching on Digg for something else, Regardless I am here now and would just like to say thanks for a remarkable post and a all round enjoyable blog (I also love the theme/design), I don’t have time to browse it all at the moment but I have bookmarked it and also included your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the fantastic job.

Comments are closed.