Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you name a multi-term package in golang?

Naming conventions for go packages are well-documented, with golang.org's blog stating:

Good package names are short and clear. They are lower case, with no under_scores or mixedCaps. They are often simple nouns, such as [descriptions removed]: time, list, http

The same guide then presents two examples of bad names:

Here are two examples of names that might be good style in other languages but do not fit well in Go: computeServiceClient, priority_queue

What the guide doesn't say is what to do when you have a package with a very specific purpose that really doesn't fit well as a one-word noun.

We have a library called Rhino Horn used internally for finding credentials that are being leaked accidentally. For reasons owing to how resource intensive it is to run Rhino Horn, I've been instructed to write a supervisor in golang for Rhino Horn that monitors its performance and enables quick shutoff when needed. Rhino Horn wasn't written in go, and is an entirely separate project.

What would the golang naming conventions have me name the Rhino Horn Supervisor?

like image 392
TheEnvironmentalist Avatar asked Jun 13 '18 16:06

TheEnvironmentalist


1 Answers

I think there are many many many options. A few of which are:

  • If your project is only focused on supervising rhino horn you could name your project rhino-horn-supervisor and not package anything just have flat top level files main.go, hornoutput.go, or w/e
  • If supervising rhino horn is one component of a larger application there could be lots of setups, one of which could be a supervisors package and rhino horn being a single file with its implementation
  • Theres also the possibility of sub packages, supervisors/rhinohorn package
  • Also you could just make a rhinohorn package with a supervisor.go file :P
like image 182
dm03514 Avatar answered Sep 28 '22 02:09

dm03514