konradreiche / apigen

Tool to automatically generates API middlewares (logging, instrumentation, etc) and documentation.
https://speakerdeck.com/konradreiche/go-generate-one-file-to-rule-them-all
29 stars 6 forks source link

$GOFILE == api.go, not ../api/api.go #1

Open elimisteve opened 4 years ago

elimisteve commented 4 years ago

Very interesting talk! I was following along and had an issue reproducing the examples in your talk in my own source files, and now I see that I'm having the same issues in apigen's code.

Specifically, when I go get this repo then add a logging statement and run

$ go generate api/api.go

I see that os.Getenv("GOFILE") == "api.go", not "../api/api.go" . Any idea what I'm doing wrong?

Thanks!

elimisteve commented 4 years ago

I just made sure I'm using the latest version of Go and I now am; same issue though.

konradreiche commented 2 years ago

It has been a while, nonetheless thank you for giving this a try. I believe I never got around to fix some of the compile issues when I extracted this code from https://github.com/october93/engine. The usage patterns in the cmd package are probably confusing and misleading.

I updated the repository to use Go modules, removed the vendoring and fixed the broken dependency graph. The generators should all run successfully by calling:

go generate ./...