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

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

示例1: ScanIssue

func ScanIssue(row *sql.Row) (*Issue, error) {
    var v0 int64
    var v1 int
    var v2 string
    var v3 string
    var v4 string
    var v5 string
    var v6 []byte

    err := row.Scan(
        &v0,
        &v1,
        &v2,
        &v3,
        &v4,
        &v5,
        &v6,
    )
    if err != nil {
        return nil, err
    }

    v := &Issue{}
    v.ID = v0
    v.Number = v1
    v.Title = v2
    v.Body = v3
    v.Assignee = v4
    v.State = v5
    json.Unmarshal(v6, &v.Labels)

    return v, nil
}

开发者ID:ajiyoshi-vg,项目名称:scannergen,代码行数:33,代码来源:issue.scanner.go

示例2: extractPost

func extractPost(row *sql.Row) (*structure.Post, error) {
    post := structure.Post{}
    var userId int64
    var status string
    err := row.Scan(&post.Id, &post.Uuid, &post.Title, &post.Slug, &post.Markdown, &post.Html, &post.IsFeatured, &post.IsPage, &status, &post.Image, &userId, &post.Date)
    if err != nil {
        return nil, err
    }
    // If there was no publication date attached to the post, make its creation date the date of the post
    if post.Date == nil {
        post.Date, err = retrievePostCreationDateById(post.Id)
        if err != nil {
            return nil, err
        }
    }
    // Evaluate status
    if status == "published" {
        post.IsPublished = true
    } else {
        post.IsPublished = false
    }
    // Retrieve user
    post.Author, err = RetrieveUser(userId)
    if err != nil {
        return nil, err
    }
    // Retrieve tags
    post.Tags, err = RetrieveTags(post.Id)
    if err != nil {
        return nil, err
    }
    return &post, nil
}

开发者ID:itkpi,项目名称:journey,代码行数:33,代码来源:retrieval.go

示例3: populateVideo

// Populates a video + type
func populateVideo(row *sql.Row, ch chan Video) {
    var v Video
    var tName, tIcon *string
    err := row.Scan(
        &v.ID,
        &v.VideoType.ID,
        &v.Title,
        &v.Description,
        &v.DateAdded,
        &v.DateModified,
        &v.IsPrimary,
        &v.Thumbnail,
        &tName,
        &tIcon,
    )
    if err != nil {
        ch <- v
        return
    }
    if tName != nil {
        v.VideoType.Name = *tName
    }
    if tIcon != nil {
        v.VideoType.Icon = *tIcon
    }

    ch <- v
    return
}

开发者ID:ninnemana,项目名称:API,代码行数:30,代码来源:video.go

示例4: rowToCompte

func rowToCompte(trollId int, row *sql.Row) (*Compte, error) {
    c := new(Compte)
    c.trollId = trollId
    c.Troll = new(TrollData)
    err := row.Scan(
        &c.statut,
        &c.mdpRestreint,
        &c.Troll.PV_max,
        &c.Troll.PV_actuels,
        &c.Troll.X,
        &c.Troll.Y,
        &c.Troll.Z,
        &c.Troll.Fatigue,
        &c.Troll.PA,
        &c.Troll.Vue,
        &c.Troll.ProchainTour,
        &c.Troll.DureeTour,
        &c.Troll.MiseAJour)
    c.Troll.ProchainTour *= 1000
    c.Troll.MiseAJour *= 1000
    if err != nil {
        return nil, err
    }
    return c, err
}

开发者ID:TheDudeness,项目名称:Chrall,代码行数:25,代码来源:comptestore.go

示例5: QuerySpaceConsumptionFor

// Query the currently used space for the given user
func (tx *Transaction) QuerySpaceConsumptionFor(user string) (result uint64, err error) {
    err = tx.do(func(tx *sql.Tx) (err error) {
        var row *sql.Row

        row = tx.QueryRow(`
      SELECT
        SUM("u"."size") AS "size"
            FROM (
              SELECT --DISTINCT
                "u"."user" AS "user",
                "u"."id" AS "id",
                "u"."size" AS "size"
              FROM "uploads" AS "u"
              WHERE "u"."expiration" >= NOW()
                AND "u"."user" = $1
            ) AS "u"
            GROUP BY "u"."user"`,
            user)

        // Get result - use zero if query returned no result for the given username
        err = row.Scan(&result)
        if err == sql.ErrNoRows {
            result = 0
            err = nil
        }

        return
    })

    return
}

开发者ID:asta-fulda,项目名称:box,代码行数:32,代码来源:database.go

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