g4s8/envdoc

go generate panics (only have package main though)

schleicherse opened this issue · 2 comments

Hi, I really like the idea of auto-generating documentation, so thanks for creating this project!

However, I cannot generate the documentation, as go generate panics.
I am using caarlos0/env.

I have a few .go files, but for simplicity, all are in package main.
This is config.go:

package main

import (
	"errors"
	"time"
	"github.com/caarlos0/env"
)

const (
	//Environment values, used for logger configuration
	EnvironmentProduction  = "production"
)

// Error messages
var (
	ErrNoRowsFound           = errors.New("no rows found")
)

//go:generate envdoc -output environments.md
type appconfig struct {
	// Port the application will listen on inside the container
	Port int `env:"PORT" envDefault:"8080"`
       // some more stuff I omitted here
}

func (c *appconfig) ParseEnvVariablesIntoConfigStruct() error {
	if err := env.Parse(c); err != nil {
		return err
	}
	return nil
}

I get this error:

panic: expected type node root child, got nodeField ()

When I uncomment the method at the end, I at least get no errors, and the environments.md file is generated, but only contains
# Environment Variables, nothing else.

go version is 1.22.2

g4s8 commented

Thanks for reporting! I'll investigate this issue

g4s8 commented

@schleicherse this should be fixed in v0.2.3 version.