goecho

How to install templ in macos & windows. Error:- templ not found


docs says.

  1. go install github.com/a-h/templ/cmd/templ@latest [This does not work.]

what I did. 1.

git clone https://github.com/a-h/templ.git [in /tmp]

cd cmd/templ && go install

still Error.

Solution I came up with. 1.

alias templ=$HOME/go/bin/templ [also added in ~/.zshrc]

why this does not work

go install github.com/a-h/templ/cmd/templ@latest

Edit:- I encountered this in windows too. Here are the steps I did to resolve this.

  1. Download the latest binary from github repo in $HOME/tmp Folder.
 2. Extract it in $HOME/tmp and copy it.
 3. Paste it in Folder where Golang is installed, i.e. Go/bin/[here].

In my case it was "C:\Program Files\Go\bin" I found it using which go I also have this path configured in System Environment Variable.


Solution

  • go install worked just fine as you can see from the alias you created. It only works because the installation was successful.

    Add export PATH="$PATH:$HOME/go/bin" to your ~/.zshrc file to add Go's default installation folder to PATH. That way all binaries that are installed with go install will be available globally.