JOJ3/pkg/sample/sample.go
张泊明518370910136 9321218181
All checks were successful
submodules sync / sync (push) Successful in 1m7s
build / build (push) Successful in 2m54s
build / trigger-build-image (push) Successful in 14s
feat: match empty groups to empty groups
2025-10-21 14:21:58 -07:00

30 lines
700 B
Go

// Package sample provides a sample function that returns a Result.
package sample
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("sample negative score: %d", conf.Score)
return res, err
}
res.Score = conf.Score
res.Comment = "sample comment"
return res, err
}