cheekybits / genny

Elegant generics for Go
MIT License
1.71k stars 167 forks source link

running "genny": exec: "genny": executable file not found in $PATH #70

Open SmileJayden opened 3 years ago

SmileJayden commented 3 years ago

//go:generate genny -in=$GOFILE -out=gen-$GOFILE gen "KeyType=string,int ValueType=string,int"

go generate ./... command with above comment reproduce running "genny": exec: "genny": executable file not found in $PATH messege for me.

However, if I do that command with //go:generate $GOPATH/bin/genny -in=$GOFILE -out=gen-$GOFILE gen "KeyType=string,int ValueType=string,int" this comment, genny generation works for me well.

I want to use //go:generate genny -in=$GOFILE -out=gen-$GOFILE gen "KeyType=string,int ValueType=string,int" this comment which is document's recommended comment.

How can I use this one with the best?

below is my go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jayden/Library/Caches/go-build"
GOENV="/Users/jayden/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/jayden/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/jayden/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/jayden/Desktop/vitalcare-backend/go/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sn/k8tknb_14qdb9nwxb6qd7cv80000gn/T/go-build483121234=/tmp/go-build -gno-record-gcc-switches -fno-common

Thanks!

Ma124 commented 3 years ago

You probably need to write export PATH="$PATH:$(go env GOPATH)/bin" in a shell script that is always executed. Traditionally ~/.profile or ~/.bashrc (or ~/.zprofile, ~/.zshrc if you use zsh).

ljmatkins commented 3 years ago

If you've added github.com/cheekybits/genny to your go.mod file, you can also try using something like:

//go:generate go run github.com/cheekybits/genny -in=$GOFILE -out=gen-$GOFILE gen "KeyType=string,int ValueType=string,int"

piterwie commented 2 years ago

try this one: go install github.com/cheekybits/genny