evcc-io/provider/helper.go
2021-08-21 12:53:25 +02:00

18 lines
407 B
Go

package provider
import (
"fmt"
"github.com/evcc-io/evcc/util"
)
// setFormattedValue formats a message template or returns the value formatted as %v if the message template is empty
func setFormattedValue(message, param string, v interface{}) (string, error) {
if message == "" {
return fmt.Sprintf("%v", v), nil
}
return util.ReplaceFormatted(message, map[string]interface{}{
param: v,
})
}