func GetValue(t reflect.Type, lit string) (ret reflect.Value, err error) {
	switch t.Kind() {
	case reflect.String:
		return reflect.ValueOf(lit), nil
	case reflect.Float64:
		v, err1 := ParseFloat(lit)
		if err1 != nil {
			err = err1
			return
		}
		return reflect.ValueOf(v), nil
	case reflect.Int64:
		v, err1 := ParseInt(lit)
		if err1 != nil {
			err = err1
			return
		}
		return reflect.ValueOf(v), nil
	case reflect.Int:
		v, err1 := ParseInt(lit)
		if err1 != nil {
			err = err1
			return
		}
		return reflect.ValueOf(int(v)), nil
	}
	err = errors.New("unsupported type: " + t.String())
	return
}
GetValue parses a literal.
package interpreter
import (
	"errors"
	"fmt"
	"reflect"
	"strconv"
	"github.com/qiniu/text/tpl"
	"github.com/qiniu/text/tpl/interpreter.util"
)
var (
	typeIntf    = reflect.TypeOf((*interface{})(nil)).Elem()
	typeEng     = reflect.TypeOf((*interpreter.Engine)(nil)).Elem()
	typeCtx     = reflect.TypeOf((*interpreter.Context)(nil))
	zeroIntfVal = reflect.Zero(typeIntf)
)
func ParseInt(lit string) (v int64, err error) {
	switch lit[0] {
	case '0':
		if len(lit) == 1 {
			return
		}
		switch lit[1] {
		case 'x', 'X':
			return strconv.ParseInt(lit[2:], 16, 64)
		default:
			return strconv.ParseInt(lit[1:], 8, 64)
		}
	default:
		return strconv.ParseInt(lit, 10, 64)
	}
}
func ParseFloat(lit string) (v float64, err error) {
	switch lit[0] {
	case '0':
		if len(lit) == 1 {
			return
		}
		switch lit[1] {
		case 'x', 'X':
			v1, err1 := strconv.ParseInt(lit[2:], 16, 64)
			return float64(v1), err1
		default:
			v1, err1 := strconv.ParseInt(lit[1:], 8, 64)
			if err1 == nil {
				return float64(v1), nil
			}
		}
	}
	return strconv.ParseFloat(lit, 64)
}