Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Golang subdirectories

Tags:

go

Is there not a way to create a sub-directory for some of my files? This is purely for file organization. I've got a large number of small structs/methods that I'd like to put into their own files and into a sub-directory, but I don't want to put them into their own package. They rely on other functionality in my project. Each one is anywhere from 10-50 lines and I've been sticking them in one file, but this is ugly.

like image 681
Jayson Bailey Avatar asked Jul 15 '14 16:07

Jayson Bailey


1 Answers

There is no way to do it. Go does this on purpose, because if you feel like you need another sub-directory. More than likely you need another package. Also, if you truly do not need a sub-package, then you could just split all those small structs and their appropriate methods into their own separate files in the same package.

like image 172
Simba Avatar answered Nov 06 '22 07:11

Simba