Hello, so after a while one among my tasks grew bigger and I put issues into libraries, realizing after some time that I battle with Capitalization (aaa => Aaa, Aaa => aaa when refactoring). If I capitalize every little thing, my naming type suffers and it doesn’t really feel proper in any respect (although, migh be an possibility). If I don’t then I can’t make these libraries.
So, no, downside, simply determine what’s a part of the library and what’s not. Then I’d not be continuously altering the primary letters of names. And what I discovered is, that it isn’t potential to determine what’s a part of the library and what’s not, as a result of no matter landed in there was a part however no library (package deal).
Issues that get larger is perhaps a part however no library. Folders for parts do look good.
So, since folders are additionally higher than utilizing prefixes (e.g. I discover it simpler to work with gfxsprite.go than with gfx_sprite.go alongside all the opposite information like snd_explosion.go and so on), I made a decision to alter my construct script in order that it copies all information into one non permanent folder earlier than utilizing go. And voila, I can lastly use folders. The editor rewrites the paths – no downside.
However copying takes a while and utilizing the construct script within the editor is laggier than earlier than. So, shifting (transfer command as a substitute of copy command) the information is perhaps an possibility. That’s quick. On Home windows, I don’t know what symlinks I may make that work like that. An alternative choice: simply purchase a good sooner pc.
Or perhaps there’s one other means? Perhaps.. if Go simply allowed me to do one thing? Perhaps… some day it permits me to make use of information which are in a subfolder?
Finest regards
PS: Library is what I used to be considering of, “package deal” is what the time period can be with Go.
HI and welcome.
Go has easy rule about utilizing components from different packages; to do it it is advisable “export” the image (sorts, capabilities, variables, …) and to “export” an emblem it’s important to Capitalize the identify.
Should you transfer one thing in a separate package deal, you “simply” must remane symbols that needs to be out there outdoors the package deal (not every little thing)
If I capitalize every little thing, my naming type suffers and it doesn’t really feel proper in any respect
are you able to elaborate a bit extra this?
2 Likes
I ought to make clear issues. I used to be doing refactoring. I believe I do that so much.
Shifting a reputation (e.g. struct member) from the primary package deal to a different package deal requires to capitalize it, when it isn’t already capitalized. And so, once I was refactoring, most friction got here from this job. So I thought of simply utilizing capitalized names all over the place in the primary package deal, too. This might additionally free me from uncapitalizing names, once I determined that they belong in the primary package deal once more – provided that these capital letters ought to point out what you’re working with, not only for making the compiler cease complaining.
I normally don’t know the place I ought to put issues at first.
So, this results in a number of information in a single folder, and I assume that’s anticipated to occur. However this isn’t my type of utilizing file managers / Explorer. I can focus so properly once I can open a folder. It appears to be like simply good. I don’t wish to give this up or commerce it for the renaming friction. Folders are the right device, and IMO seeing them as packages, or seeing packages as folders, is a bit bizarre. I assume there’s a excellent cause for it. However since I’m utilizing Go, a techniques language, as my desktop language, it wouldn’t make sense for me to look the perfect reply why issues are like this. So I simply determined to adapt the construct script and the editor to repeat information and in impact give me the power to make use of subfolders. Effectively, the construct script now’s sophisticated and gradual.
Finest regards
It feels like perhaps it is advisable think twice about your package deal design and public floor space. My folder/package deal construction normally grows organically. Like – just lately I had a challenge the place I added an integration with slack, so I created a slack
package deal to summary that away. Then I wanted to combine with github; so similar factor. Every of my packages does one factor and it’s clear from the folder construction what they do.
If you wish to have exported sorts/capabilities however are fearful about not permitting different packages to import them, you could possibly check out inside:
Usually, I believe your issues will principally go away if you concentrate on package deal naming/separation of duties earlier than creating your packages. Listed here are two glorious articles on package deal naming which may assist you to (I take into account the primary one a should learn for go builders!):
1 Like
So, mklink /h supply goal
is the best way to create a tough hyperlink in Home windows. The complication by utilizing completely different paths for compilation than what you edit gained’t go away, but it surely’s sooner. I’ll follow that until it will get too irritating.
Creating packages – perhaps, however solely once I know I gained’t change the construction afterwards. I’d do then what Dean_Davidson advised with the intention to forestall the dangerous structure.
Thanks
Anybody agree that capitalization/data-hiding guidelines is the most important design flaw in Go?
As soon as I assumed it will be different issues, overly simplified error reporting behaviour and messages, no assure on any struct structure, type of weak generics even with typeparams perhaps – however not with the ability to refactor between (transfer code from predominant package deal to lib package deal, from lib package deal to predominant package deal – or having to make use of caps on a regular basis) is the most important flaw on this language imo, however who cares about me, proper? I should be doing one thing fallacious, sigh. I attempted Go really when it was launched publicly, so I’ve examined it not less than considerably, and I had no concept that for barely larger tasks (only a few mb of Go code) that is the productiveness killer no 1.
I’ve not discovered any good answer to this point. At the moment I merely have opted for copying code, which is in fact no good technique.
This characteristic appears to offer an answer for a workforce of two or extra workers, one being the worker (or employer) who has to cover/defend code, due to a lack of know-how in regards to the software program throughout the different worker.
I do apreciate all company, OOP, agile and whatnot causes for options and prefer to check out fairly just a few. And perhaps I even would possibly sooner or later like inside packages, perhaps defending my code from myself, who is aware of.
However what I actually miss in Go is a few acknowledgement of individuals in a artistic design course of, iterating (suppose, dash and so on) the method with code, and never on paper – additionally not at Google, not utilizing servers or loads of employees both. I believe, when the perfect language remains to be the fallacious one, perhaps that’s simply dangerous luck. Must discover a good workaround; I assumed modifying the editor to be rather more conscious of the Go syntax appears a good suggestion, but I used to be considering: Why then use this language within the first place, when it is advisable begin linting i.e. really partly re-writing the compilation course of. Why hassle with this mess, when it’s solely a workaround.
PS: Humorous factor, currently I used to be utilizing Goland. The story doesn’t relate a lot to my packages downside however the error reporting. Goes like this: You write code, add imports. Then you definately remark out a line, Goland does its sensible issues and removes the import because the file wouldn’t compile in any other case. Good characteristic from Goland. Now you uncomment within the code once more, and Goland has no concept what to do now. You go to the start of the file and add the import once more, what a characteristic.