2016-02-25 22:59:38 +00:00
|
|
|
package pathmatch
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func set(value string, argsIndex int, args ...interface{}) error {
|
|
|
|
|
|
|
|
if 0 > argsIndex {
|
2019-06-21 04:35:33 +00:00
|
|
|
return newInternalError("Index value %d is less than zero.", argsIndex)
|
2016-02-25 22:59:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if lenArgs := len(args); argsIndex >= lenArgs {
|
|
|
|
expectedAtLeast := 1+argsIndex
|
|
|
|
actual := lenArgs
|
|
|
|
|
2019-06-21 04:38:18 +00:00
|
|
|
return newNotEnoughArguments(expectedAtLeast, actual)
|
2016-02-25 22:59:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
arg := args[argsIndex]
|
|
|
|
|
|
|
|
switch a := arg.(type) {
|
|
|
|
case sql.Scanner:
|
|
|
|
if err := a.Scan(value); nil != err {
|
2019-06-21 04:28:51 +00:00
|
|
|
return newScanError(err, argsIndex, fmt.Sprintf("%T", arg))
|
2016-02-25 22:59:38 +00:00
|
|
|
}
|
|
|
|
case *string:
|
|
|
|
*a = value
|
|
|
|
default:
|
|
|
|
return newUnsupportedIndexedArgumentTypeComplainer(argsIndex, fmt.Sprintf("%T", arg))
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|