The data record result (Value) of gdb supports very flexible type conversion and has built-in support for dozens of common data types.

    The Value type is an alias for the *gvar.Var type, so you can use all the conversion methods of the gvar.Var data type. For details, please refer to the Generic section.

    Example usage:

    First, the data table is defined as follows:

    1. # Product Table
    2. CREATE TABLE `goods` (
    3. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    4. `title` varchar(300) NOT NULL COMMENT 'Product Name',
    5. `price` decimal(10,2) NOT NULL COMMENT 'Product Price',
    6. ...
    7. PRIMARY KEY (`id`)
    8. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

    Next, the data in the table is as follows:

    1. id title price
    2. 1 IPhoneX 5999.99

    Finally, the sample code is as follows:

    1. if r, err := g.Model("goods").FindOne(1); err == nil {
    2. fmt.Printf("goods id: %d\n", r["id"].Int())
    3. fmt.Printf("goods title: %s\n", r["title"].String())
    4. fmt.Printf("goods proce: %.2f\n", r["price"].Float32())
    5. } else {
    6. g.Log().Error(gctx.New(), err)
    7. }

    After execution, the output is:

    1. goods id: 1
    2. goods title: IPhoneX
    3. goods proce: 5999.99