As an introduction, let me tell you that I've been using Go for only one week. But I think that a newcomer's opinion can be valuable for the commun...
For further actions, you may consider blocking this person and/or reporting abuse
Hi Boris, nice that you're trying something new! As a lot of people say, learning a new language probably will improve your skills at your "first" language even if you don't use the new one during your daily work.
It depends on how you organize your code.
If two files belong to the same package then yes, the splitting is just logic, but they are technically the same unit of work (package) to begin with.
The convention is to name the package with the same name of the directory those files are in. So if you have a directory "store", all the files inside it should belong to the
store
package. You should also avoid mixing files from different packages in the same directory.Encapsulation in Go is pretty straightforward. In each package, everything whose name starts with a lowercase letter is private to that package, everything with a uppercase letter is visible to other packages, and can be imported.
So
func privateFunction() {}
will be accessible only inside your package butfunc PublicFunction() {}
can be used in other packages.To organize a Go project I googled a bit but ended up copying how Go projects on Github organize their code (and failed to adhere in a way). There's no single way but popular Go projects on GitHub are as good a starting point as any.
A note: there's not a single way to do OOP, the class based paradigm popularized by languages like Java is definitely the most famous known but you can do OOP in many different ways. Strictly speaking OOP is about objects (and their relationships), not about classes. You need to have objects, with a state and with methods that can operate on such state and alter it. Objects can inherit behavior and state from one another. JavaScript is probably the most famous example of OOP done without classes (well, until ES6 but if I remember correctly that's just syntax on top of prototypes).
Go has taken some concepts from OOP: you have methods that operate on structs that hold data. There's no direct inheritance, though you can use composition to build a new struct from another one (and "inherit" state and methods).
Polymorphism is achieved through interfaces.
So, is Go OOP? Probably. The official FAQ has this to say:
Have fun, remember that concurrency is not parallelism...
If you're interested in my initial experience with Go I documented it here:
Seven days of Go
rhymes ・ Mar 22 '18 ・ 11 min read
Thanks a lot for your detailed answer!
I'll take a look at your post.
I knew about functions' visibility with upper/lower case and I found it was a great way to simplify the code readability.
I am from Node.js background and gave Go a try recently. After trying out some basic stuff and using Mux etc. I tried Beego Web Framework along with Go Modules. It's really amazing, solves most of my problems.
Most of the time, I try to avoid frameworks, even if it could change. But for the moment, I want to learn raw Go as it's the language's philosophy.
Happy to know your way.
Cuando un prueba una nueva herramienta de desarrollo siempre consigue algunos asuntos difíciles, yo programo en C/C++, y con PHP, y encontré a GO algo incomodo al principio, luego de probar las virtudes de GO estoy convencido de que es una de las mejores herramientas de desarrollo que he Usado. Simple, elegante, y muy versátil: pero por sobre todo: 1) Rápido en desarrollo 2) Mas Rápido para la ejecución 3) Resuelve el problema de la Memoria y la basura 4) Concurrente 5) Es genial
I moved from PHP to Go as well many months ago, i'd say the best thing to do is to practice but not only in the web domain, you should also try to build programs using qml or sciter-sdk on the front-end for example!
You're right but I feel like I would be unable to build a frontend app right now. It would take a long time before I can feel comfortable with that. As I only work on production, I haven't that time.
Bonne chance :)
Thumbs up for still rocking PHP, in the banking world of all places! I've dipped my toes in the go pool recently as well. A lot of things to love, some to hate. Not sure whether it'll usurp .NET Core for me yet.
As an alternative to vim, it seems that Visual Studio Code is very good option for Go dev with the Go plugin. It's the only graphical editor that works pretty well out-of-the-box.
You should try gin or echo. They are very good micro frameworks
This might help as well. They are slides (and examples) from a talk on how to structure Go code.
Way to Go! 😁 I'm also learning Go a few days back and find that it's an interesting language. Out of curiosity, do you have any project in mind after wrapping up learning the fundamentals?
Yes, I'm about to start a new project in the next days.
It's an API with a NoSQL db.
I'll be working with another newbie.