#go build -o with subdirectory

7 messages · Page 1 of 1 (latest)

hasty bloom
#

I want to setup air to hot reload website, but I can't make it work.
I have my main.go file in cmd folder.
The cmd part in .air.toml looks like this:

cmd = "templ generate && go build ./cmd -o ./tmp/main ."

But I am getting this error:
malformed import path "-o": leading dash
How to make it work?

dry hill
#

go's flag package doesn't accept to parse flag arguments after positional arguments

#

try go build -o ./tmp/main ./cmd . that AFAIT the equivalent to what you meant, I'm not sure what the . will do or what it's meant to do or if it should be there

safe night
#

by the way, you don't need to modify your cmd

#

Add

  exclude_regex = ["_test.go", "_templ.go"]
  include_ext = ["go", "tpl", "tmpl", "html", "templ"]
  pre_cmd = ["templ generate"]
#

this will recompile/hot-reload when you modify templ files

#

the exclude is important, so you don't get into an infinite loop