-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Panic on generate #15
Comments
I've just tried your example (just removed
Original source file: package config
import (
"time"
"github.com/g4s8/go-lifecycle/pkg/lifecycle"
"github.com/ipfs/go-log/v2"
)
//go:generate go run github.com/g4s8/envdoc@latest -output environments.md
type Config struct {
ProgName string `env:"PROG_NAME,notEmpty" envDefault:"prog"`
Logger log.Config
Application lifecycle.Config
RestAPI restapi.Config
}
type Config struct {
Level string `env:"LOG_LEVEL,notEmpty" envDefault:"info"`
Format string `env:"LOG_FORMAT,notEmpty" envDefault:"json"`
}
type Config struct {
AppGracePeriod time.Duration `env:"APP_GRACE_PERIOD,notEmpty" envDefault:"10s"`
}
type Config struct {
Port int `env:"RESTAPI_PORT" envDefault:"8080"`
ReadTimeout time.Duration `env:"RESTAPI_READ_TIMEOUT" envDefault:"5s"`
WriteTimeout time.Duration `env:"RESTAPI_WRITE_TIMEOUT" envDefault:"10s"`
IdleTimeout time.Duration `env:"RESTAPI_IDLE_TIMEOUT" envDefault:"120s"`
} Maybe you have some old cached version of envdoc? Could you try using the latest version manually:
And please add the output of |
Hello!
The same:
go version go1.22.0 linux/amd64 |
Ok, I got a different result: File tree structure:
Files:
package config
import (
"tmp/internal/lifecycle"
"tmp/internal/log"
"tmp/internal/restapi"
)
//go:generate go run github.com/g4s8/envdoc@latest -output environments.md
type Config struct {
ProgName string `env:"PROG_NAME,notEmpty" envDefault:"prog"`
Logger log.Config
Application lifecycle.Config
RestAPI restapi.Config
}
package lifecycle
import "time"
type Config struct {
AppGracePeriod time.Duration `env:"APP_GRACE_PERIOD,notEmpty" envDefault:"10s"`
}
package log
type Config struct {
Level string `env:"LOG_LEVEL,notEmpty" envDefault:"info"`
Format string `env:"LOG_FORMAT,notEmpty" envDefault:"json"`
}
package restapi
import "time"
type Config struct {
Port int `env:"RESTAPI_PORT" envDefault:"8080"`
ReadTimeout time.Duration `env:"RESTAPI_READ_TIMEOUT" envDefault:"5s"`
WriteTimeout time.Duration `env:"RESTAPI_WRITE_TIMEOUT" envDefault:"10s"`
IdleTimeout time.Duration `env:"RESTAPI_IDLE_TIMEOUT" envDefault:"120s"`
} MD file generation works, although the result is somewhat truncated # Environment Variables
## Config
- `PROG_NAME` (**required**, non-empty, default: `prog`) -
|
The problem here is that go generate tools with AST parsers are working with source files, not packages, so it's not possible to resolve the type from another package automatically. I see two solutions to fix that:
Need to think about better solution |
Hello!
I'm trying to make documentation out of a structure
There is a config.Config structure, and nested structures in different packages
When trying to generate an error is thrown
The text was updated successfully, but these errors were encountered: