From 5c73ef922e218a33b8b3abd28a61a11a80a95d37 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Tue, 13 Feb 2024 08:52:15 +0100 Subject: [PATCH] More on go in backend readme --- backend/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/README.md b/backend/README.md index 67fa3a6..818d3fc 100644 --- a/backend/README.md +++ b/backend/README.md @@ -2,6 +2,10 @@ This is the root of the backend. It contains the main server and the database logic. The structure might look confusing at first, given that go conventions (which I followed to the best of my ability) uses a rather goofy structure with the `cmd` and `internal` directories. +Golang does not support classes, but it does support structs. These are practically synonymous, with the important distinction being that structs does not support traditional inheritance. Instead, go uses interfaces to achieve polymorphism. This is a rather interesting way of doing things, and it's a bit of a learning curve if you're coming from a language like C++ or Java. Having a good understanding of [Composition over Inheritance](https://en.wikipedia.org/wiki/Composition_over_inheritance) will help you understand the go way of doing things. + +An [interface](https://golangdocs.com/interfaces-in-golang) is functionally similar to an interface in Java, or an abstract class in C++. It simply describes how an object can behave. + An important note is that go, unlike C, handles its own dependencies. A simple `go get` command will fetch all the dependencies for you. The `go.mod` file is the equivalent of a `package.json` file in Node.js, if you're familiar with that. To run the backend, you can use the `go run` command. For example, to run the server, you can use `go run cmd/main.go`. This will start the server on its default port (8080, at the time of writing).