本文整理汇总了Golang中database/sql/driver.Value函数的典型用法代码### 示例。如果您正苦于以下问题:Golang Value函数的具体用法?Golang Value怎么用?Golang Value使用的例子?那么恭喜您, 这里精选的函数代码### 示例或许可以为您提供帮助。

在下文中一共展示了Value函数的18个代码### 示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码### 示例。

示例1: Value

// Value implements the driver.Value interface.
func (c Command) Value() (driver.Value, error) {
    raw, err := json.Marshal(c)
    if err != nil {
        return nil, err
    }
    return driver.Value(raw), nil
}

开发者ID:carriercomm,项目名称:empire,代码行数:8,代码来源:processes.go

示例2: Next

// DATE, DATETIME, TIMESTAMP are treated as they are in Local time zone (this
// can be changed globaly using SetLocation function).
func (r *rowsRes) Next(dest []driver.Value) error {
    if r.my == nil {
        return io.EOF // closed before
    }
    err := r.my.ScanRow(r.row)
    if err == nil {
        if r.simpleQuery == textQuery {
            // workaround for time.Time from text queries
            for i, f := range r.my.Fields() {
                if r.row[i] != nil {
                    switch f.Type {
                    case native.MYSQL_TYPE_TIMESTAMP, native.MYSQL_TYPE_DATETIME,
                        native.MYSQL_TYPE_DATE, native.MYSQL_TYPE_NEWDATE:
                        r.row[i] = r.row.ForceTime(i, location)
                    }
                }
            }
        }
        for i, d := range r.row {
            dest[i] = driver.Value(d)
        }
        return nil
    }
    if err != io.EOF {
        return errFilter(err)
    }
    if r.simpleQuery != nil && r.simpleQuery != textQuery {
        if err = r.simpleQuery.Delete(); err != nil {
            return errFilter(err)
        }
    }
    r.my = nil
    return io.EOF
}

开发者ID:whosonfirst,项目名称:go-whosonfirst-rtree,代码行数:36,代码来源:driver.go

示例3: Next

func (r *Rows) Next(dest []driver.Value) error {
    more := r.rows.Next()
    if !more {
        if r.rows.Err() == nil {
            return io.EOF
        } else {
            return r.rows.Err()
        }
    }

    values, err := r.rows.Values()
    if err != nil {
        return err
    }

    if len(dest) < len(values) {
        fmt.Printf("%d: %#v\n", len(dest), dest)
        fmt.Printf("%d: %#v\n", len(values), values)
        return errors.New("expected more values than were received")
    }

    for i, v := range values {
        dest[i] = driver.Value(v)
    }

    return nil
}

开发者ID:josephwinston,项目名称:flynn,代码行数:27,代码来源:sql.go

示例4: Value

// Convert to SQL driver value.
func (pys Pinyins) Value() (value driver.Value, err error) {
    var buf []byte
    var ret = []byte{'{'}
    for _, py := range pys {
        for _, b := range []byte(py) {
            if b >= 65 && b <= 90 { // A - Z
                b += 32
            }
            if b >= 97 && b <= 122 { // a - z
                buf = append(buf, b)
            }
        }
        if len(buf) > 0 {
            buf = append(buf, ',')
            ret = append(ret, buf...)
            buf = nil
        }
    }
    if ret[len(ret)-1] == ',' {
        ret[len(ret)-1] = '}'
    } else {
        ret = append(ret, '}')
    }
    value = driver.Value(string(ret))
    return
}

开发者ID:caiguanhao,项目名称:gopinyin,代码行数:27,代码来源:gopinyin.go

示例5: TestFloat32_Value

func TestFloat32_Value(t *testing.T) {
    expect, val := Float32(10.5), driver.Value(10.5)
    var f Float32
    f.Scan(val)
    if f != expect {
        t.Errorf("Expect %f, but %f", expect, f)
    }
}

开发者ID:hirokidaichi,项目名称:genmai,代码行数:8,代码来源:type_test.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng