As a Python and Django developer, I can run any part of the code in my project using a script independently.
I'm not too sure how to achieve the same thing in Go, since it seems like every Go project should have only one main executable.
I would like to call a function in my project from cronjob, but I'm not too sure how to add this. Using flags in my main function is the only way I can do this. But this will look rather confusing if my script accepts additional flags on its own, as shown below:
go run server.go --debug --another-flag --script-name <MY-SCRIPT> --my-script-flag-one <FLAG-ONE> --my-script-flag-two <FLAG-TWO>
Is there an elegant way to do this?
source share