air
air copied to clipboard
Detect main.go in subdir when running air init with defaults
Motivation
I ran air init without args in a project that already had a main in a cmd subdirectory. Running air init always uses the current directory as default arg for the TOML file's cmd block. I figured it would be cool if air init detected any pre-existing main.go files as I usually don't initialize air before building the base structure of the project.
Also, the error when running air on a directory is fairly confusing (bin/bash: permission denied) so it would also alleviate the potential for that error occurring in the first place.
Changes
This PR still passes the current dir to go build if ./main.go exists or no main.go exists. Otherwise it inserts the first main.go found when pre-order traversing the file system.