DEV Community

Takahiro Kudo
Takahiro Kudo

Posted on

Go - Considering package name.

I was considering the package name of golang today.
This package provides utility functions of operating HTTP.

At first, mypackage/utils
This is not good because "Avoid meaningless package names." is given as a bad here.

Next, mypackage/http or mypackage/httputil
These naming are also bad because "Avoid unnecessary package name collisions" is given as a bad too.

Finally, mypackage/apphttputils
I chose this.

If I use packages only in my application, do I not need to think?

Reference

https://blog.golang.org/package-names

Top comments (6)

Collapse
 
konart profile image
Artem Kondratev • Edited

If I use packages only in my application, do I not need to think?

Name them so that anyone can understand.

If you have an internal package http (let's assume that's the best name somehow) under internal/ packages folder than you can just give in an alias during an import.

If the package is intended to be used (can be used) by other dev's you better think of those things you've mentioned but in the end it's their job to keep their code clean.

Collapse
 
takakd profile image
Takahiro Kudo

Oh, internal/ is easy to understand.
That's a good idea, I thought too.
Thanks for your feedback!

Collapse
 
konart profile image
Artem Kondratev

github.com/golang-standards/projec...

This repo has a layout example for Go application projects. We often use it within our team. Get a look!

Thread Thread
 
takakd profile image
Takahiro Kudo

Thank you for introducing helpful resources.
I'll try it!

Collapse
 
kamranayub profile image
Kamran Ayub

Maybe mypackage/myhttp, mypackage/httpext meaning ext for extensions/extended?

Collapse
 
takakd profile image
Takahiro Kudo

Thanks, I didn't notice "ext".
I thought "ext" better than "utils".