Before I ask this, I need to apologize, I know that programmatically running this kind of thing within code is dumb, and should be moved to makefiles - but management want everything inside a binary for this job, so, cool...
I need to know how to cd to a directory, and then run:
go fmt ./...
I have found stuff like exec, etc... but the problem there is that seems to look specifically for files to work with, when I need to run a command.
Anyone done this? Got an example for me?
When you run ‘go fmt’ you are in fact running a file just don’t know which file it is. Try running ‘which go’ on the command line. That will return the path of the file run for go. Then you can use the exec functions you found.
To change your working directory, you can follow this answer. But you might also just be able to pass a relative path.