risor-io / risor

Fast and flexible scripting for Go developers and DevOps.
https://risor.io
Apache License 2.0
581 stars 24 forks source link

fix format verb for reflect.Type #192

Closed runsisi closed 5 months ago

codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 30.95%. Comparing base (c5e6756) to head (add3487). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #192 +/- ## ========================================== + Coverage 30.79% 30.95% +0.16% ========================================== Files 113 113 Lines 14517 14519 +2 ========================================== + Hits 4471 4495 +24 + Misses 9486 9473 -13 + Partials 560 551 -9 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

myzie commented 5 months ago

Hi @runsisi, thank you for the bugfix!

I was going to add a test case to get the codecov check to pass, but to be honest I can't immediately figure out how to reproduce the error that triggers this message. Could you share an example of the Go type that demonstrates this? Partly I'm just curious 😄

I'm not sure I'm going to keep this codecov check...

runsisi commented 5 months ago

ur welcome :)

package main

import (
    "context"
    "reflect"

    "github.com/risor-io/risor"
)

type Service struct {
    V reflect.Value
}

// or

// type Service struct {
// }
//
// func (m *Service) Test() *reflect.Value {
//  return nil
// }

func main() {
    svc := &Service{}
    _, _ = risor.Eval(context.Background(), "", risor.WithGlobal("svc", svc))
}

StructField.Offset https://github.com/golang/go/blob/go1.22.0/src/reflect/type.go#L887

myzie commented 5 months ago

@runsisi - I pushed a slightly bigger refactoring of that error message. What do you think of this?

runsisi commented 5 months ago

the error message is much clearer now, lgtm