air-verse / air

☁️ Live reload for Go apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disable tmp directory

Auxority opened this issue · comments

Hey, first of all I want to thank you guys for creating this amazing tool.

I'd like to disable the creation of the tmp directory. But I cannot find any way to do this.
I managed to disable the creation of any files inside the directory, but the directory itself is still created.
This is my .air.toml file, I run it inside a Docker container using a development stage:

root = "/app"
tmp_dir = "tmp"

[build]
  args_bin = []
  bin = "/go/bin/app"
  cmd = "go build -o /go/bin/app ."
  delay = 1000
  exclude_dir = ["tmp"]
  exclude_file = []
  exclude_regex = ["_test.go"]
  exclude_unchanged = false
  follow_symlink = false
  full_bin = ""
  include_dir = []
  include_ext = ["go"]
  include_file = []
  kill_delay = "0s"
  log = "/dev/null"
  poll = true
  poll_interval = 0
  post_cmd = []
  pre_cmd = []
  rerun = false
  rerun_delay = 500
  send_interrupt = false
  stop_on_error = false

[color]
  app = ""
  build = "yellow"
  main = "magenta"
  runner = "green"
  watcher = "cyan"

[log]
  main_only = true
  time = false

[misc]
  clean_on_exit = true

[screen]
  clear_on_rebuild = false
  keep_scroll = true

+1 for this! There is always an empty tmp directory even if not used. I tried settings tmp_dir="", but still created a tmp folder.

I'd also like to get rid of this tmp directory. I'd rather have the build log files placed in the root directory. I tried tmp = "./" and tmp = ".", but both of those resulted in the tmp directory created under root. This is surprising as it contradicts with the statement that all directories are relative to root, which implies that "." and "./" should refer to the same directory as root, given that tmp and ./tmp result in ${root}/tmp.

I'm sharing what I end up doing for my setup. In my project I got many services that are all under the cmds/ folder. I also didnt like having an air file next to the main file so I created a air directory that contains the air files and the air tmp directories.

structure

/root
  .air/
     core/
     twin/
     core.toml
     twin.toml
     ...
  bin/
    core
    twin
  cmds/
    core/
      main.go
    twin/
      main.go

core.toml

root = "../"
testdata_dir = "testdata"
tmp_dir = "core"

[build]
args_bin = []
bin = "bin/core"
cmd = "go build -o ./bin/core ./cmds/core"

im simply starting my apps using air -c .air/core.toml at the root level. I also use a makefile for ease.