JOJ3/pkg/dummy/dummy.go
张泊明518370910136 38d1c18471
All checks were successful
continuous-integration/drone/push Build is passing
feat: add dummy error example
2024-03-12 16:38:55 -04:00

29 lines
611 B
Go

package dummy
import (
"fmt"
)
type Conf struct {
Score int
}
type Result struct {
Score int
Comment string
}
func Run(conf Conf) (res Result, err error) {
if conf.Score < 0 {
// Just return the error here instead of logging, as it is run inside
// the sandbox, the logs will not show in drone output directly.
// If there are more kinds of errors need to be handled separately, add
// more fields in the Result struct, don't mess everything up in Stderr.
err = fmt.Errorf("dummy negative score: %d", conf.Score)
return
}
res.Score = conf.Score
res.Comment = "dummy comment"
return
}