Closed andrerocco closed 1 year ago
$GOPATH itself is not deprecated, what this was doing was fine. https://blog.smantic.dev/posts/gopath-is-not-deprecated/
What is deprecated is using $GOPATH as the workspace for go projects. This was typically where you developed go codebases before go modules.
read -p "Go's 'air' is not installed on your machine. Do you want to install it? [Y/n] " choice; \
if [ "$$choice" != "n" ] && [ "$$choice" != "N" ]; then \
go install github.com/cosmtrek/air@latest;
\air;\
echo "Watching...";\
This assumes that the user has added $GOBIN ($GOPATH/bin) to the user's path. This isnt a thing that happens automatically. The previous implementation did not assume that the user had $GOBIN in their path.
Yess @smantic, the description of the issue is indeed wrong, thanks for pointing it out.
My experience (and from issue #111 apparently) was that the previous implementation ran on every run of make watch
. So it would install air on the system but not detect the installation afterward. Then I think neither the previous implementation should be relied upon.
I'm currious to see if people will have issues with the new implementation as you said that. I will take look into what could solution could be taken to make this as more generalized (work on more machines) as possible.
Hi @andrerocco
I'm using the latest versions of both go and go-blueprint. but i'm still facing this problem of air: not found
. Below is the watch
target:
# Live Reload
watch:
@if command -v air > /dev/null; then \
air; \
echo "Watching...";\
else \
read -p "Go's 'air' is not installed on your machine. Do you want to install it? [Y/n] " choice; \
if [ "$$choice" != "n" ] && [ "$$choice" != "N" ]; then \
go install github.com/air-verse/air@latest; \
air; \
echo "Watching...";\
else \
echo "You chose not to install air. Exiting..."; \
exit 1; \
fi; \
fi
i also tried this:
watch:
@echo "Watching..."
@air -v
but that also didn't do any help. any idea what i'm doing wrong here?
note: i can successfully access the air
command from terminal directly. this problem only occurs when i do it using the makefile
Description
When running
make watch
after successfully installingair
, the Makefile still prompts "air is not installed. Do you want to install it now? (y/n)". This happens even thoughair
has been installed and is available in the PATH.It seems like the GOPATH has been deprecated in Go 1.16 and should not be relied on.
Environment
Additional Information
Here is the
watch
target in the Makefile: