Repo for basic tutorial-based Golang study
- monkey
- interpreter
- compiler
- macros
- web crawler with
colly
- do
gilded rose
kata - smth with
Hanoi tower
- finish
book
- fix
web_app_bis
(if no JSON is provided, some routes crash) - init
book
- clean
issues
section (for now) - fix github actions
- get book "Język Go. Tworzenie idiomatycznego kodu w praktyce" example link other link
- finish
web_app_bis
tutorial (mostly done, need to check if everything works OK)
- cd
app_name
go build -v ./
go test -v ./
go run main.go
booking app tutorial (booking app + some basics)
basics tutorial (most basics)
web app tutorial (web app + Gin)
web app bis tutorial (web app + Gin)
- How should modules / packages be organized? How are they organized in real-life large projects? docs
- How specifically, does
hash maps
work in Golang? - (DONE)
func (u *UserService) CreateUser(user *models.User)
What does the (u *UserService) part mean? Likely, it specifies return type, it so? (CreateUser(user *models.User)
part specifies the return type) - (DONE)
func (u *UserService) CreateUser(user *models.User)
What does * mean? It looks like a pointer... (yep, it's a pointer) - (DONE)
if err := ctx.ShouldBindJSON(&user); err != nil {...}
What about ShouldBindJSON? (the syntax means, that we first create err variable, assign value to it and only then check if function returned any errors) - (DONE)
query := bson.D{bson.E{Key: "name", Value: name}}
What is bson.D or bson.E? (these are two out of four basic types of BSON documents, which are the basic unit of data in MongoDB, ref: https://www.mongodb.com/docs/drivers/go/current/fundamentals/bson/) -
Why changging Bson.E -> primitive.E fixed erorrs ?? (from https://pkg.go.dev/go.mongodb.org/mongo-driver/bson:
update := bson.D{primitive.E{Key: "$set", Value: bson.D{ primitive.E{Key: "name", Value: user.Name}, primitive.E{Key: "age", Value: user.Age}, primitive.E{Key: "address", Value: user.Address}, }}}
M - unordered representation of a BSON document
D - ordered representation of a BSON document
E - a BSON element for a D
) - (DONE) difference between
=
and:=
in Golang? (:=
means 'declare and assign', while=
means 'assign') - (DONE) can you return empty values in Golang? (yes, you can return empty values in Golang, in fact it's quite often a prefered way of doing things - so
return nil
or justreturn
and don't bother)
- golang function syntax:
func functionName(parameter1 type1, parameter2 type2, parameterN typeN) returnType { //function body }
most important basics
pointers, performance
on type parameters
frameworks
gin
colly
misc
gilded rose
- resources in respective README