mirror of
https://github.com/la5nta/pat
synced 2026-08-13 17:46:54 -04:00
30 lines
736 B
Go
30 lines
736 B
Go
package cfg
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
type PredictionEngine string
|
|
|
|
const (
|
|
PredictionEngineAuto PredictionEngine = ""
|
|
PredictionEngineDisabled PredictionEngine = "disabled"
|
|
PredictionEngineVOACAP PredictionEngine = "voacap"
|
|
PredictionEngineVOACAPAPI PredictionEngine = "voacap-api"
|
|
)
|
|
|
|
func (p *PredictionEngine) UnmarshalJSON(b []byte) error {
|
|
var str string
|
|
if err := json.Unmarshal(b, &str); err != nil {
|
|
return err
|
|
}
|
|
switch v := PredictionEngine(strings.ToLower(strings.TrimSpace(str))); v {
|
|
case PredictionEngineVOACAP, PredictionEngineVOACAPAPI, PredictionEngineDisabled, PredictionEngineAuto:
|
|
*p = v
|
|
return nil
|
|
default:
|
|
return fmt.Errorf("invalid prediction engine '%s'", v)
|
|
}
|
|
}
|