Apologies if this has already been asked and answered, I'm not quite sure 
which incantation to put in the google box.

In our organisation, we have many private and public go packages for 
various projects.

For each micro-service, we structure it as:

/cmd/{name}/{name}.go - something which should build a binary
/*.go - if appropriate, the client library of the service

then it's pretty much free-for-all for the actual components:

/foobar - implementation details for the service
/model/*.go - the M of MCV

And for a public or private library the library itself is at /*.go, with 
sub packages if needed.

It seems to work well in practice, but there may be a better way.

What should I call this repository?

Just naming it after the service works well unless, say, we were re-writing 
a v1 in ruby, so the name is already taken.

fizzbar.go: isn't actually the package name (can't be)
go-fizzbar: '-' isn't idiomatic
/go/fizzbar: Excellent if your git server handles it, but 
github.com/org/go/fizzbar... doesn't work.

Then I started playing around with git insteadOf, which works until go get 
expects a folder at github.com/org/go/.git

This would also be a 'thing' for public repos, using one single word to 
name my library, and forcing me to use that name at the root of my github 
directory seems a bit ... rude, tbh.

Is everyone actually following the best practice here? Everything else in 
Go sits right out of my way and I don't have to think about it, but naming 
my packages is a constant source of distraction.

A concrete example, I have a package which does some basic JSON or XML 
things with http requests and responses.
e.g., WriteResponse(rw httpResponseWriter, req *http.Request, 
responseObject interface{})
writes responseObject as either JSON or XML depending on the requested 
Content-Type

I have called it 'api', 'apiutil', 'encoding-util'... all of them bad for 
various practical or idiomatic reasons, and making it my 
github.com/{org}/api is clearly not a good option.

What would you call it?




-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to