- Go v1.23.1
- OS: macOS 14.4.1, Apple M1
I’m new-ish to Go and I want to try out the OpenAPI codegen. I’ve been trying to follow the readme instructions for setting up tools.go but I’m getting errors. I can’t tell if the instructions are incomplete or there’s something about my system (maybe my VS Code) that’s not configured right, or if it’s something about Go (possibly Go modules) that I don’t understand.
I’ve read every instruction I can find online talking about setting up tools.go
but it seems that they’re all either 1+ years old, using the Makefile approach, or just lacking detail. I read that Go now allows us to use modules instead of the Makefile. Should I expect VS Code to give these errors? Where should I put the directives that are given by the OpenAPI codegen instructions? The relative path given by this directive looks wrong to me:
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml ../../api.yaml
I saw a person putting their api.yaml in the project path openapi/api.yaml
, so I don’t understand why these instructions use ../../api.yaml
.
https://github.com/oapi-codegen/oapi-codegen?tab=readme-ov-file#install
1