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
What is the purpose of net and net/http packages?
Create web servers using only the standard library.
What is the purpose of the goroutines?
Start thousands of concurrent tasks with minimal resources.
What is the purpose of channels?
Safely communication between concurrent tasks (goroutines).
What is the main purpose of the standard library?
Provides the whole “out of the box experience” where you can build quite a lot of apps only using this lib.
What are the main tasks you can achieve with the go cli?
project init, build, retrieve deps, tests, profiling, documentation and more.
How can I compile a go program into android?
Just change the GOOS and GOARCH env vars to android and arm respectively
How does go handle forward and backward slashes within the cross-platform topic?
The compiler does it for you automatically based on the GOOS.
Is backwards compatibility a concern on go?
Yes, promised. Any app written to a specific major version will continue to work (even unchanged) when updating to the latest minor.
Can go break backwards compatibility promise?
Yes, for security, unspecified behavior, spec errors and bugs.
What is an “*” in golang? How to access this value?
Means it is a pointer to the value. *myVar
What does the defer keyword does?
Flags that a variable/resource can be cleaned up (open handles in case of os.Open()
Why does golang sometimes requires an array of byte as params for specific methods suas as http.ResponseWritter.Write?
Because it is closed to the computer “language”.
How to convert a string to an array of bytes?
[]byte(“My String”)
What is the main page of golang to keep myself up to date?
golang.org
What is the official blog of golang?
blog.golang.org
What is the official FAQ of the language?
golang.org/doc/faq
Is there a podcast about golang where experts talks about updates?
yes, check it out at golang.org/help
What are the three main advices to learn go?
create projects with go (write lots of code), join slack and discord channels, checkout the pluralsight library.
What is the main goal of the go programming language?
To make programmers more productive
Is go open source?
Yes.
What are some characteristics of the go language?
Very efficient (fast compilation and binaries), clean (few keywords to memorize), expansive