

Ask HN: A Good Makefile for Go? - tmaly

can someone suggest a good Makefile for Go projects?
======
tobz
A coworker of mine landed on a skeleton that seems to work for him. I'm not
entirely sold on the choice of libraries, but it's a good starting point if
your goal is to go from source code to a deployable binary (we use CentOS so
it builds you an RPM) with sensible choices for logging and testing.

[https://github.com/blalor/go-template](https://github.com/blalor/go-template)

------
Spiritus
This[1] is what I used for a toy project of mine. Nothing fancy though, and
probably not what you're looking for but could at least prompt some ideas.

[1] [https://github.com/renstrom/go-
wiki/blob/master/Makefile](https://github.com/renstrom/go-
wiki/blob/master/Makefile)

------
andrewchambers
You don't need a makefile for go. Generally all you need are "go build" "go
install" "go test". If you have some generated source you can now used "go
generate".

~~~
tmaly
I use those now, but I want to setup some other ideas such as prompting for
the database username/password to write into a config.go before compiling. I
did not want to store information like this in a public git repo

~~~
jzs
I suggest that instead of compiling it into the binary, that you use
environment variables instead. Or make it command line flags.

Then you can have a bash script that you don't check in that executes the
variable with environment variables/ flags.

------
tmaly
Thanks for the suggestions, I ended up taking a simple Makefile and calling a
sub shell to a perl script to change placeholders in a config.go with my
environment variables on the default target if they were not already set in
config.go

