Introduction Flashcards

1
Q

Why was go invented?

A

Because google had three languages that had its own strengths but did completely solve google’s problem.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which languages google was having issues with and why?

A

C++, Java, Python. For full comparison see here:

https://pasteboard.co/JLkSwPz.png

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the 6 key advantages of go?

A

Fast compilation time. Fully compiled. Strongly typed. Concurrent by default. Garbage collected. Simplicity as a core value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Will go try to infer the type even keeping its “strongly typed” characteristic?

A

Yes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the 3 applications-types that go is very good at?

A

web services, web applications and task automation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Is there a web playground for go?

A

yes. play.golang.org

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the package main in a go program?

A

main namespace of the application. this is the root.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is the import (“fmt”) command do?

A

import fmt lib

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

how does the entrypoint method of a go app looks like?

A
func main() {
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what happens when you import a lib and doesn’t use it or any other kind of “unused” resource?

A

go is going to complaint and throw compilation error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

why does go throws a compilation error when a lib is imported but not used?

A

to improve maintainability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

how is go formatted? empty spaces or tabs? Does it throw an error if not followed?

A

tabs. no

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

where the curly brace has to be added? What happens if not?

A

to the same line of the statement, otherwise compilation error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what does go doc method/class/package?

A

show the documentation about the method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to install all important dependencies via vs code?

A

install the go plugin, then ctrl P, then > go install, finally check them all and install

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

how these libs look like in windows drive?

A

they are all executables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

will the plugin import automatically libraries?

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

what is a workspace?

A

legacy way to organize the projects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

what is a module? which version of go was it introduces? what was deprecated in favor of modules?

A

the new way to organize projects. was introduced on 1.0.3. workspace was deprecated.

20
Q

how to initialize a go module? which file does it create?

A

go mod init github.com/pluralsight/webservice

go.mod

21
Q

why does a go module looks like an URL?

A

to simplify dependency management.

22
Q

Should I write procedural or object oriented with go?

A

you decide… go is multi-paradigm

23
Q

how many loop keywords are available in golang?

A

only one: for (in three different flavors but only one reserved word)

24
Q

Who starts the goroutines concurrent tasks?

A

The scheduler

25
Q

What is the purpose of net and net/http packages?

A

Create web servers using only the standard library.

26
Q

What is the purpose of the goroutines?

A

Start thousands of concurrent tasks with minimal resources.

27
Q

What is the purpose of channels?

A

Safely communication between concurrent tasks (goroutines).

28
Q

What is the main purpose of the standard library?

A

Provides the whole “out of the box experience” where you can build quite a lot of apps only using this lib.

29
Q

What are the main tasks you can achieve with the go cli?

A

project init, build, retrieve deps, tests, profiling, documentation and more.

30
Q

How can I compile a go program into android?

A

Just change the GOOS and GOARCH env vars to android and arm respectively

31
Q

How does go handle forward and backward slashes within the cross-platform topic?

A

The compiler does it for you automatically based on the GOOS.

32
Q

Is backwards compatibility a concern on go?

A

Yes, promised. Any app written to a specific major version will continue to work (even unchanged) when updating to the latest minor.

33
Q

Can go break backwards compatibility promise?

A

Yes, for security, unspecified behavior, spec errors and bugs.

34
Q

What is an “*” in golang? How to access this value?

A

Means it is a pointer to the value. *myVar

35
Q

What does the defer keyword does?

A

Flags that a variable/resource can be cleaned up (open handles in case of os.Open()

36
Q

Why does golang sometimes requires an array of byte as params for specific methods suas as http.ResponseWritter.Write?

A

Because it is closed to the computer “language”.

37
Q

How to convert a string to an array of bytes?

A

[]byte(“My String”)

38
Q

What is the main page of golang to keep myself up to date?

A

golang.org

39
Q

What is the official blog of golang?

A

blog.golang.org

40
Q

What is the official FAQ of the language?

A

golang.org/doc/faq

41
Q

Is there a podcast about golang where experts talks about updates?

A

yes, check it out at golang.org/help

42
Q

What are the three main advices to learn go?

A

create projects with go (write lots of code), join slack and discord channels, checkout the pluralsight library.

43
Q

What is the main goal of the go programming language?

A

To make programmers more productive

44
Q

Is go open source?

A

Yes.

45
Q

What are some characteristics of the go language?

A

Very efficient (fast compilation and binaries), clean (few keywords to memorize), expansive