Thanks, as mentioned in the previous reply, this is what I end up using. On Thursday, April 16, 2020 at 10:25:03 AM UTC+8, Shulhan wrote: > > > > On 15 Apr 2020, at 18.55, Glen Huang <hey...@gmail.com <javascript:>> > wrote: > > > > I have a makefile where upon a new go binary being built, it builds some > other stuff that is not go related. > > > > The go binary is unconditionally built with a FORCE prerequisite, so the > go build command always runs, but that command always updates the output > binary, which leads to downstream being unnecessarily built. > > > > Is there a way to tell go not to touch the output file if it builds > purely from the cache? > > > > Currently it prevents me from using a makefile, and I don't really feel > like sidestepping go's cache system by manually listing all go files and > have the makefile functions as a cache, besides, it's really difficult to > correctly list dependencies if the module is big and the binary being built > only depends on a subset. > > > > If the source code is not large enough, I think this will works, > > ``` > CMD_SRC :=$(shell go list -f '{{ $$dir := .Dir }}{{ range > .GoFiles }} {{ $$dir }}/{{.}} {{end}}' $(CMD_DIR)) > > your/binary: $(CMD_SRC) > go build ./cmd/binary > ```
-- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/d0bc8e99-5e85-4c16-87b6-0b663c6cd9a1%40googlegroups.com.