Hello, so after a while considered one of my initiatives 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 thing, my naming type suffers and it doesn’t really feel proper in any respect (although, migh be an choice). 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 might not be always 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 recordsdata like snd_explosion.go and so forth), I made a decision to vary my construct script in order that it copies all recordsdata 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, transferring (transfer command as a substitute of copy command) the recordsdata is perhaps an choice. That’s quick. On Home windows, I don’t know what symlinks I may make that work like that. An alternative choice: simply purchase an excellent quicker laptop.
Or possibly there’s one other manner? Possibly.. if Go simply allowed me to do one thing? Possibly… some day it permits me to make use of recordsdata which are in a subfolder?
Greatest 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 parts from different packages; to do it that you must “export” the image (varieties, capabilities, variables, …) and to “export” a logo it’s a must to Capitalize the title.
Should you transfer one thing in a separate package deal, you “simply” have to remane symbols that ought to be obtainable exterior the package deal (not every thing)
If I capitalize every 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 feel I do that rather a lot.
Transferring a reputation (e.g. struct member) from the principle package deal to a different package deal requires to capitalize it, when it isn’t already capitalized. And so, after I was refactoring, most friction got here from this process. So I thought-about simply utilizing capitalized names in all places in the principle package deal, too. This may additionally free me from uncapitalizing names, after I determined that they belong in the principle 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 often don’t know the place I ought to put issues at first.
So, this results in a number of recordsdata 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 nicely after I can open a folder. It seems simply good. I don’t need to give this up or commerce it for the renaming friction. Folders are the right instrument, and IMO seeing them as packages, or seeing packages as folders, is a bit bizarre. I suppose there’s a excellent motive for it. However since I’m utilizing Go, a programs language, as my desktop language, it wouldn’t make sense for me to go looking the most effective reply why issues are like this. So I simply determined to adapt the construct script and the editor to repeat recordsdata and in impact give me the power to make use of subfolders. Effectively, the construct script now’s difficult and sluggish.
Greatest regards
It seems like possibly that you must think twice about your package deal design and public floor space. My folder/package deal construction often grows organically. Like – not too long ago 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 varieties/capabilities however are apprehensive about not permitting different packages to import them, you might check out inner:
On the whole, I feel your issues will largely go away if you consider package deal naming/separation of duties earlier than creating your packages. Listed here are two glorious articles on package deal naming which may aid you (I take into account the primary one a should learn for go builders!):
1 Like
So, mklink /h supply goal
is the way in which to create a tough hyperlink in Home windows. The complication by utilizing totally different paths for compilation than what you edit gained’t go away, nevertheless it’s quicker. I’ll persist with that until it will get too irritating.
Creating packages – possibly, however solely after I know I gained’t change the construction afterwards. I might do then what Dean_Davidson steered so as to stop the unhealthy structure.
Thanks
Anybody agree that capitalization/data-hiding guidelines is the largest design flaw in Go?
As soon as I believed it could be different issues, overly simplified error reporting behaviour and messages, no assure on any struct structure, type of weak generics even with typeparams possibly – however not having the ability to refactor between (transfer code from essential package deal to lib package deal, from lib package deal to essential package deal – or having to make use of caps on a regular basis) is the largest flaw on this language imo, however who cares about me, proper? I have to be doing one thing unsuitable, sigh. I attempted Go really when it was launched publicly, so I’ve examined it at the very least considerably, and I had no concept that for barely larger initiatives (only a few mb of Go code) that is the productiveness killer no 1.
I’ve not discovered any good resolution up to now. At the moment I merely have opted for copying code, which is after all no good technique.
This characteristic appears to offer an answer for a workforce of two or extra staff, one being the worker (or employer) who has to cover/shield code, due to a lack of understanding in regards to the software program inside the different worker.
I do apreciate all company, OOP, agile and whatnot causes for options and wish to check out fairly a couple of. And possibly I even would possibly in some unspecified time in the future like inner packages, possibly 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 forth) the method with code, and never on paper – additionally not at Google, not utilizing servers or loads of workers both. I feel, when the most effective language continues to be the unsuitable one, possibly that’s simply unhealthy luck. Should discover a good workaround; I believed modifying the editor to be far 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 that you must 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.