The error occurs because the Go binary is not in your system's PATH environment variable. Add the Go bin directory to your PATH and restart your terminal.
export PATH=$PATH:/usr/local/go/bin
To make this change permanent, add the line above to your shell configuration file (~/.bashrc, ~/.zshrc, or ~/.profile) and reload it with source ~/.bashrc (or the equivalent for your shell).