air icon indicating copy to clipboard operation
air copied to clipboard

Detect main.go in subdir when running air init with defaults

Open nesselchen opened this issue 11 months ago • 0 comments

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.

nesselchen avatar Feb 03 '25 14:02 nesselchen