4 ms·
Ask HN: A Good Makefile for Go?
can someone suggest a good Makefile for Go projects?
- andrewchambers 12y agoYou 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 12y agoI 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 12y agoI 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.
- Spiritus 12y agoThat doesn't cover non-go files though.
- deleted 12y ago[deleted]
- Spiritus 12y agoThis[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
- tobz 12y agoA 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
- tmaly 12y agoThanks 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