Introduction Flashcards
Why was go invented?
Because google had three languages that had its own strengths but did completely solve google’s problem.
Which languages google was having issues with and why?
C++, Java, Python. For full comparison see here:
https://pasteboard.co/JLkSwPz.png
What are the 6 key advantages of go?
Fast compilation time. Fully compiled. Strongly typed. Concurrent by default. Garbage collected. Simplicity as a core value.
Will go try to infer the type even keeping its “strongly typed” characteristic?
Yes.
What are the 3 applications-types that go is very good at?
web services, web applications and task automation
Is there a web playground for go?
yes. play.golang.org
what is the package main in a go program?
main namespace of the application. this is the root.
what is the import (“fmt”) command do?
import fmt lib
how does the entrypoint method of a go app looks like?
func main() { }
what happens when you import a lib and doesn’t use it or any other kind of “unused” resource?
go is going to complaint and throw compilation error.
why does go throws a compilation error when a lib is imported but not used?
to improve maintainability.
how is go formatted? empty spaces or tabs? Does it throw an error if not followed?
tabs. no
where the curly brace has to be added? What happens if not?
to the same line of the statement, otherwise compilation error.
what does go doc method/class/package?
show the documentation about the method
How to install all important dependencies via vs code?
install the go plugin, then ctrl P, then > go install, finally check them all and install
how these libs look like in windows drive?
they are all executables
will the plugin import automatically libraries?
yes
what is a workspace?
legacy way to organize the projects.
what is a module? which version of go was it introduces? what was deprecated in favor of modules?
the new way to organize projects. was introduced on 1.0.3. workspace was deprecated.
how to initialize a go module? which file does it create?
go mod init github.com/pluralsight/webservice
go.mod
why does a go module looks like an URL?
to simplify dependency management.
Should I write procedural or object oriented with go?
you decide… go is multi-paradigm
how many loop keywords are available in golang?
only one: for (in three different flavors but only one reserved word)
Who starts the goroutines concurrent tasks?
The scheduler