Hello, everyone. I’m CAI Bing.

Old friends may remember that I advised you to prepare for the interview only focusing on Java/C++, but according to my observation of this fall’s recruitment, in fact, Go can be a new option. Compared with C++, Go is less difficult to get started, and compared with Java, Go is less related to the eight-essay knowledge, so that the interview will focus on the language questions will be less, but also easy for everyone to prepare.

In fact, I knew nothing about Go when I was a byte intern. As a Java player, I was forced to seamlessly join Go and began to receive small demands after two days on the job.

I think the core is the ability to learn quickly.

Today I would like to share with you how to quickly start the Go language, as well as some more advanced information sharing.

0x01

For students who have already mastered one or two languages, learning a new one can be very quick.

There are three steps to getting started:

  • Environment configuration
  • Grammar learning
  • practice

The Go language tour, on the other hand, compresses it further:

  • Execute code online, environment does not need to match
  • Grammar study and practice are integrated, and you can learn Go by passing each level as if you were playing a game

tour.go-zh.org/list tour.studygolang.com/list

The above two links are the same, but the difference is that one is provided by the official website and the other is provided by Go Chinese language.

0x02

Click open welcome and we can see using the interface below

The trick to getting started quickly when learning a new language is to find similarities and differences

That is to find out the differences and similarities between the new language and existing knowledge

cycle

As we all know, in C/C++/Java, there are two types of loops: while and for

The for loop looks like this:

for (int i = 0; i < n; i++) {
    doSomething(i);
}
Copy the code

But in Go, there’s only one for loop (while can be implemented with for)

for i := 0; i < 10; i++ {
    doSomething(i)
}
Copy the code

Did you find that it actually looks like

Let’s look at the C/C++/Java while loop:

while (i < n) {
    doSomething(i);
}
Copy the code

The while loop inside Go:

for i < n {
    doSomething(i)
}
Copy the code

This is a little bit more of a pattern, because Go is a loop with less (), and while is merged into for.

Range

We also know that in Java you can iterate over elements of a group quickly in this way:

int[] arr = new int[10];
for(int value: arr) {
    doSomething(value);
}
Copy the code

Go has a similar approach:

for _, value := range arr {
    doSomething(value);
}
Copy the code

If you want to use an index, you can write it as follows:

for index, value := range arr {
    doSomething(index, value);
}
Copy the code

This tutorial is detailed at every step, making it easy for you to master the basics of Go.

It doesn’t take much time to go through the whole tutorial.

And if you go to watch the video, although the difficulty of getting started is lower, after all, someone knocks for you to see, but the time cost is greatly increased.

A video is usually dozens of minutes, and after the Go lecture, it often takes more than a dozen videos.

Try it out for yourself, and you’ll see why I’ve always prioritized reading documents to learn new things.

0x03

Of course, after entering the Go language, we can not always stay in the initial stage, to advance, then it is necessary to further theoretical study + a lot of practice

So having a build environment on your computer is essential

It is recommended to install ToolBox first

www.jetbrains.com/toolbox-app…

Then download GoLand and the Student Party can use the student email to apply for the education edition, which is free.

If you can’t, you can also use VsCode, and you can find some installation tutorials online, which will not be described here.

0x04

In addition to the in-depth study of language, the application of language should also be horizontally expanded.

Find a few open source Go projects on Github, such as Web framework, RPC framework, run them, use them, and see how they work.

Further, you can look at how frameworks are implemented. For example, I put together a series of articles on writing Web frameworks in Go

0x05

As a programmer, the ability to learn quickly is very core, adapt to change to grow quickly.

Mastering a language quickly is one of the manifestations of fast learning ability.

There is a very classic book “seven weeks seven Language”, can not only broaden their horizons, but also train their fast learning ability, interested partners can go to see.

I’m choppie, and I’ll see you next time.