Reputation: 150852
Coming from the Node.js world, whenever you need a script (such as a build script there), a very common way of handling this is by adding it to the scripts
block in the package.json
file, so that you can the script by calling npm run <scriptname>
. In other words, Node.js (respectively npm) has a built-in way to deal with (simple) scripts.
Does an equivalent to this exist in the Go world?
To put it differently: Suppose I have some commands such as doing a build, cleaning the build directory, creating a new version, and so on, is there a better way to do this than by adding a bunch of (platform-dependant) Bash script files?
In case there isn't – is there at least a common way of where to put these scripts? Or is this all left to the developer?
Upvotes: 6
Views: 2013
Reputation: 683
You can use Makefile
this one is what I use sometimes:
BINARY_NAME=main
build:
go mod tidy
go build -o ${BINARY_NAME} main.go
clean:
go clean
rm ${BINARY_NAME}
Upvotes: 5