0

I have an existing repository (which is organised using the standard Golang project layout)

cmd/
    bigproject/
        main.go
internal/
    ...
pkg/
    ...
vendor/
    ...

What I would like to do is add an extra directory inside cmd which contains an alternative main application:

cmd/
    bigproject/
        main.go
    myalternativerunner/
        main.go
internal/
    ...
pkg/
    ...
vendor/
    ...

But rather than include myalternativerunner inside the main repository, I would like to track it completely separately. To use the project, you do not need to have myalternativerunner included.

Git submodules/subtrees do not seem, to my understanding, solve this use case, as they create a dependency within the main project on myalternativerunner.

My current thinking is to add "myalternativerunner" to my main repository's gitignore and then say "clone myalternativerunner inside cmd if you want it".

Is that the best approach or is there a more idiomatic one?

5
  • 2
    I think you might be trying to solve the wrong problem. I don't think this is a source control issue. It might actually be an application design issue where you want to enable/disable features of the application, or heavily modify an application for a client or due to some technology upgrade. Nov 9 at 21:56
  • 1
    This is what submodules do.
    – user253751
    Nov 9 at 22:08
  • Git-submodules are optional dependencies. They are not downloaded by default. However, submodules include the entire repository, you can't select subfolders. Here, your alternative runner repository would not be able to use the same directory layout.
    – amon
    Nov 10 at 0:34
  • 1
    At which point in the application's lifecycle do these optional dependencies need to be available? i.e. Build time? Deployment Time? Runtime? (I assume with the dependencies being optional that they would always be built separately anyway, and that these aren't "build dependencies". In which case git is almost certainly the wrong tool for the job, and you'd likely be better looking at a different approach entirely, focusing on deployment instead) Nov 10 at 8:38
  • @BenCottrell when I, personally, want to use it (and at no other time) [or other people can grab myalternativerunner and then, when they want to use it]. Essentially, myalternativerunner is using the main project as a dependency (but is embedded within it on the file system).
    – Jivlain
    Nov 10 at 12:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.