Tuesday, April 22, 2025
HomeGolangUtilizing folders for elements - Getting Assist

Utilizing folders for elements – Getting Assist


Hello, so after a while one in every of my initiatives grew bigger and I put issues into libraries, realizing after some time that I wrestle with Capitalization (aaa => Aaa, Aaa => aaa when refactoring). If I capitalize all the things, my naming fashion 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 continually altering the primary letters of names. And what I came upon is, that it isn’t doable 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 elements 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 on), I made a decision to vary my construct script in order that it copies all recordsdata into one momentary 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 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 perhaps there may be one other method? Perhaps.. if Go simply allowed me to do one thing? Perhaps… some day it permits me to make use of recordsdata which might be in a subfolder?

Finest regards

PS: Library is what I used to be considering of, “package deal” is what the time period could be with Go.

HI and welcome.

Go has easy rule about utilizing parts from different packages; to do it it is advisable to “export” the image (varieties, capabilities, variables, …) and to “export” a logo it’s important to Capitalize the identify.

If you happen to transfer one thing in a separate package deal, you “simply” have to remane symbols that ought to be accessible exterior the package deal (not all the things)

If I capitalize all the things, my naming fashion 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 lots.

Transferring 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, after I was refactoring, most friction got here from this activity. So I thought-about simply utilizing capitalized names all over the place in the primary package deal, too. This could additionally free me from uncapitalizing names, after I determined that they belong in the primary package deal once more – on condition 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 plenty of recordsdata in a single folder, and I assume that’s anticipated to occur. However this isn’t my fashion of utilizing file managers / Explorer. I can focus so effectively after I can open a folder. It seems to be simply good. I don’t wish to give this up or commerce it for the renaming friction. Folders are the proper software, and IMO seeing them as packages, or seeing packages as folders, is a bit bizarre. I suppose there’s a good motive for it. However since I’m utilizing Go, a methods language, as my desktop language, it wouldn’t make sense for me to go looking one of the best 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 could be difficult and sluggish.

Finest regards

It feels like perhaps it is advisable to consider carefully about your package deal design and public floor space. My folder/package deal construction often grows organically. Like – lately I had a venture 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 possibly can check out inner:

Usually, I believe your issues will largely 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 enable you (I contemplate 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 through the use of totally different paths for compilation than what you edit received’t go away, nevertheless it’s quicker. I’ll keep on with that until it will get too irritating.
Creating packages – perhaps, however solely after I know I received’t change the construction afterwards. I might do then what Dean_Davidson advised with the intention to forestall the dangerous structure.
Thanks

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments