Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should auxiliary code generators be in cmd/ or in tools/? #235

Closed
renom opened this issue Sep 28, 2023 · 2 comments
Closed

Should auxiliary code generators be in cmd/ or in tools/? #235

renom opened this issue Sep 28, 2023 · 2 comments
Labels

Comments

@renom
Copy link

renom commented Sep 28, 2023

E.g. we have an app in cmd/ and a couple of code generators that generate code used in the app. Where should we put those generators?

@kcq
Copy link
Member

kcq commented Jan 25, 2024

It depends... Whenever you have something with the main package, even if it's not an app you ship, putting it under cmd is ok. Kubernetes is kind of like that: https://github.com/kubernetes/kubernetes/tree/master/cmd

A lot of times the external/3rd party code generators or other code related tools (e.g., linters) go into the tools directory where they get pulled in as dependencies (which is an enhanced version of what's described here https://www.jvt.me/posts/2022/06/15/go-tools-dependency-management/ and here https://marcofranssen.nl/manage-go-tools-via-go-modules ):

Here are a few examples of that:

https://github.com/cilium/cilium/blob/main/tools/tools.go
https://github.com/dapr/dapr/blob/master/tools/tools.go
https://github.com/buildpacks/pack/blob/main/tools/tools.go

Sometimes the tools directory does include custom code too. Here's an example: https://github.com/influxdata/influxdb/blob/master/tools/tmpl/main.go

And sometimes the tools directory has a bunch of supporting components that are all over the place like Istio, for example: https://github.com/istio/istio/tree/master/tools

@kcq kcq added the question label Jun 29, 2024
@kcq
Copy link
Member

kcq commented Jun 29, 2024

converting to a discussion... useful question and info

@golang-standards golang-standards locked and limited conversation to collaborators Jun 29, 2024
@kcq kcq converted this issue into discussion #251 Jun 29, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

2 participants