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

fmt.Sprint(func) does not compile #36

Open
cphaensch opened this issue May 15, 2024 · 3 comments
Open

fmt.Sprint(func) does not compile #36

cphaensch opened this issue May 15, 2024 · 3 comments

Comments

@cphaensch
Copy link

./packrat.go:361:43: fmt.Sprint arg List is a func value, not called
./printer.go:66:23: fmt.Sprint arg v is a func value, not called
./printer.go:66:40: fmt.Sprint arg List is a func value, not called
./printer.go:142:119: fmt.Sprint arg List is a func value, not called
./printer.go:165:25: fmt.Sprint arg v is a func value, not called

The thing is, the code is correct and should compile (and does compile on go 1.22.0). The result of fmt.Sprint(f) where f is a func() is a hex value identifying the closure like in:

                // tell if v is the "List" function
                if fmt.Sprint(v) == fmt.Sprint(List) { //fmt.Sprint
                        return "list"
                }
@rillig
Copy link
Owner

rillig commented May 15, 2024

If your code does not build successfully, it is not ready for gobco.

Just as you need to run go test -vet=off for your code to build, you need to run gobco -test -vet=off to run gobco on it.

I don't see anything that gobco should do differently to support your case.

@rillig rillig closed this as completed May 15, 2024
@cphaensch
Copy link
Author

The code builds with Go 1.22.0, but does not build with goboco.

I changed the code from fmt.Sprint(f) to reflect.GetValue(f).Pointer() though, so it works now ;)

@rillig
Copy link
Owner

rillig commented Jun 10, 2024

Sorry for prematurely closing this issue, now I understand it. I'll have to look into the details why gobco fails but a plain go test succeeds.

@rillig rillig reopened this Jun 10, 2024
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

No branches or pull requests

2 participants