Thanks for sharing. I agree Makefile is very useful and recently I came across the `just` command which is a Makefile compatible alternative with a bunch more options (task docs, real default task definition, etc) which makes this workflow even better.
Thks for the video, great tip. I put you a 👍. I did a minor change to your Makefile: BINARY_NAME=$(notdir $(shell pwd)) so that the binary takes the name of the folder where the Makefile is located and so I can reuse it without changes.
Don't forget to use $(system uname -m) an $(system uname -o) to get the GOOS and GOARCH values. Pair this with a pattern match rule to simplify the makefile.
Thanks for the video. I use Makefiles with cespare/reflex for hot reloading the server every time I save changes. It's very easy to do, and makes life easier
Make is a lifesaver for me when I do more involved backend projects in Go. A simple '$ make' bundles and minifies TailwindCSS, bundles and minifies Javascript for HTMX, AlpineJS and some special ‘homegrown’ Javascript elements, compiles one binary version for local testing and one for the use in Docker and builds a Docker container for cloud deployment -- all with one simple CLI command and a number of well-structured dependencies. Good luck trying all this without a well-written Makefile!
Make works on the m_time of the file system. if a file does not exist it will execute a rule block to make that file. the .PHONY statement tells make that the related rules do not output a file but should still be executed. E.g. if you have a rule call `all:` and a file `./all` but `./all` or dependencies hasn't changed make will do nothing. Adding `.PHONY: all` means make will always execute when one types `make all`
There are some really interesting-looking features you have at the bottom of your VS Code instance, like the time spent coding and building. Would you be willing to share a list of those?
Make rules *are* bash scripts. Make is the O.G. cicd system on *nix systems. Every time it enters into a rule block it is taking that block and dumping it into the stdin of an `exec $SHELL /dev/stdin` command. It allows one to set up patterns for routing to scripts instead of having a ton of one off scripts that could break or get out of sync with the project. You can also change the `SHELL` per rule to process in different tools (say with jq and a json template, or some terraform config processor). Or just dynamically create shell scripts depending on what OS/hardware your building for.
I love make. It's pre installed on most unix-like OSs and its a nice consistent way to orchestrate stuff across languages/technologies.
Isn't it great!
Thanks for sharing. I agree Makefile is very useful and recently I came across the `just` command which is a Makefile compatible alternative with a bunch more options (task docs, real default task definition, etc) which makes this workflow even better.
just is quite nice as well. Works well as a task runner.
Thks for the video, great tip. I put you a 👍. I did a minor change to your Makefile:
BINARY_NAME=$(notdir $(shell pwd))
so that the binary takes the name of the folder where the Makefile is located and so I can reuse it without changes.
Nice work!
Don't forget to use $(system uname -m) an $(system uname -o) to get the GOOS and GOARCH values. Pair this with a pattern match rule to simplify the makefile.
fantastic video! I didn't know Go had a native make capability, the syntax is simple as always :)
Thanks for the video. I use Makefiles with cespare/reflex for hot reloading the server every time I save changes. It's very easy to do, and makes life easier
Thanks for watching and for the reflex idea!
Make is a lifesaver for me when I do more involved backend projects in Go. A simple '$ make' bundles and minifies TailwindCSS, bundles and minifies Javascript for HTMX, AlpineJS and some special ‘homegrown’ Javascript elements, compiles one binary version for local testing and one for the use in Docker and builds a Docker container for cloud deployment -- all with one simple CLI command and a number of well-structured dependencies. Good luck trying all this without a well-written Makefile!
Sounds like a great use of a Makefile!
God bless the algorithm
Again God bless the algorithm
@@cooljoe5305hallelujah
I've seen .PHONY section added to a golang makefile. Do you know the purpose for it in golang?
Make works on the m_time of the file system. if a file does not exist it will execute a rule block to make that file. the .PHONY statement tells make that the related rules do not output a file but should still be executed. E.g. if you have a rule call `all:` and a file `./all` but `./all` or dependencies hasn't changed make will do nothing. Adding `.PHONY: all` means make will always execute when one types `make all`
Wow, Nicely done video! Thank you.
Glad you liked it!
How do you install "make" to run make file ?
There are some really interesting-looking features you have at the bottom of your VS Code instance, like the time spent coding and building. Would you be willing to share a list of those?
Hey, thanks for watching. That is WakaTime, but yes, it could be a good video idea. Thanks for suggesting it.
Oh my god! You have a youtube channel? I started the video and that very instant I knew I've heard you somewhere 😂
Yes I do! It's pretty new though, I'm just figuring things out.
@@EarthlyTech Great! Love your podcast!
please more go content
good work
Thank you! Cheers!
Have you tried using Bash/shell script instead of makefile?
For sure. Bash is certainly useful as well.
Make rules *are* bash scripts. Make is the O.G. cicd system on *nix systems. Every time it enters into a rule block it is taking that block and dumping it into the stdin of an `exec $SHELL /dev/stdin` command. It allows one to set up patterns for routing to scripts instead of having a ton of one off scripts that could break or get out of sync with the project. You can also change the `SHELL` per rule to process in different tools (say with jq and a json template, or some terraform config processor). Or just dynamically create shell scripts depending on what OS/hardware your building for.
Thanks, we need tutorials on how to create real projects (not just how to make a specific app and leave it on my machine).
Noted
subscribed :)
Thanks!