Skip to content

Instantly share code, notes, and snippets.

@vishal-wadhwa
Last active July 24, 2021 16:57
Show Gist options
  • Save vishal-wadhwa/ef81069f1bcc44bf874004e2c2f11239 to your computer and use it in GitHub Desktop.
Save vishal-wadhwa/ef81069f1bcc44bf874004e2c2f11239 to your computer and use it in GitHub Desktop.
No re-build issue cosmtrek/air
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"
[build]
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ."
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = true
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html", "txt"]
kill_delay = "1s"
log = "build-errors.log"
send_interrupt = true
stop_on_error = false
[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"
[log]
time = false
[misc]
clean_on_exit = true
  1. Start using air -d in one terminal
  2. In another terminal run the following:
    echo -n "abc" | tee a1.txt; echo -n "def2" | tee b1.txt
  3. You'll see that re-build is not triggered.
__ _ ___
/ /\ | | | |_)
/_/--\ |_| |_| \_ , built with Go
[debug] mode
CWD: /tmp/air-bug
watching .
!exclude tmp
building...
!exclude checksum .
!exclude checksum .air.toml
!exclude checksum .git
!exclude checksum README.md
stored checksum for a1.txt: ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
stored checksum for b1.txt: da1464fd7ceaf38ff56043bc1774af4fb5cb83ef5358981d78de0b8be5a6fbcb
stored checksum for main.go: e660c032e6e97e9ce24a044a4dd8da0bb0eb3f68304342f8c9898091d66e0eac
!exclude checksum tmp
running...
a1: abc | b1: def
a1: abc | b1: def
a1: abc | b1: def
event: "/tmp/air-bug/a1.txt": WRITE|CHMOD
a1.txt has changed in watcher
reaching events - /tmp/air-bug/a1.txt
event: "/tmp/air-bug/b1.txt": CHMOD
event: "/tmp/air-bug/b1.txt": WRITE
b1.txt has changed in watcher
flushing events
skipping a1.txt because contents unchanged
a1: abc | b1: def
a1: abc | b1: def
package main
import (
"fmt"
"io/ioutil"
"time"
)
func main() {
a1, _ := ioutil.ReadFile("./a1.txt")
b1, _ := ioutil.ReadFile("./b1.txt")
for {
fmt.Printf("a1: %s | b1: %s\n", string(a1), string(b1))
time.Sleep(time.Second * 5)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment