Skip to content
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

go generate panics (only have package main though) #18

Closed
schleicherse opened this issue Apr 5, 2024 · 2 comments · Fixed by #19
Closed

go generate panics (only have package main though) #18

schleicherse opened this issue Apr 5, 2024 · 2 comments · Fixed by #19

Comments

@schleicherse
Copy link

schleicherse commented Apr 5, 2024

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
Copy link
Owner

g4s8 commented Apr 5, 2024

Thanks for reporting! I'll investigate this issue

g4s8 added a commit that referenced this issue Apr 10, 2024
Add flag to process unexported types with
AST visitor.

Fix: #18
@g4s8 g4s8 closed this as completed in #19 Apr 10, 2024
@g4s8
Copy link
Owner

g4s8 commented Apr 10, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants