当前位置: 首页>>代码示例>>Golang>>正文


Golang debug.Error函数代码示例

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


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

示例1: CreateProject

func CreateProject(params map[string]string) (int64, error) {
	const rawSQL = `
	INSERT INTO project (author_id, title, tagline, description, image_url, view_count, status, updated_at, created_at)
	VALUES ($1, $2, $3, $4, '', 0, 'concept', now(), now())
	RETURNING id`

	var parser Parser
	authorID := parser.Int(params["authorID"])
	if parser.Err != nil {
		debug.Error(parser.Err)
		return 0, parser.Err
	}

	title := params["title"]
	tagline := params["tagline"]
	description := params["description"]

	var id int64
	if err := db.QueryRow(rawSQL, authorID, title, tagline, description).Scan(&id); err != nil {
		debug.Error(err)
		return 0, err
	}

	return id, nil
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:25,代码来源:project.go

示例2: CreateTask

func CreateTask(params CreateTaskParams) (int64, error) {
	const rawSQL = `
	INSERT INTO task (author_id, project_id, title, description, done,
			  start_date, end_date, updated_at, created_at)
	VALUES ($1, $2, $3, $4, $5, $6, $7, now(), now())
	RETURNING id`

	var id int64
	if err := db.QueryRow(
		rawSQL,
		params.AuthorID,
		params.ProjectID,
		params.Title,
		params.Description,
		params.Done,
		params.StartDate,
		params.EndDate,
	).Scan(&id); err != nil {
		debug.Error(err)
		return 0, err
	}

	if err := UpdateTaskTags(id, params.Tags); err != nil {
		debug.Error(err)
		return 0, err
	}

	return id, nil
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:29,代码来源:task.go

示例3: GetFriendIDs

func GetFriendIDs(userID int64) ([]int64, error) {
	const rawSQL = `
	SELECT user_.id FROM user_
	INNER JOIN friend ON user_.id = friend.user1_id
	WHERE user_.id != $1`

	rows, err := db.Query(rawSQL, userID)
	if err != nil {
		debug.Error(err)
		return nil, err
	}
	defer rows.Close()

	var ids []int64
	for rows.Next() {
		var id int64
		if err = rows.Scan(&id); err != nil && err != sql.ErrNoRows {
			debug.Error(err)
			return ids, err
		}

		ids = append(ids, id)
	}

	return ids, nil
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:26,代码来源:friend.go

示例4: queryChats

func queryChats(rawSQL string, data ...interface{}) ([]Chat, error) {
	rows, err := db.Query(rawSQL, data...)
	if err != nil {
		debug.Error(err)
		return nil, err
	}
	defer rows.Close()

	var cs []Chat
	for rows.Next() {
		var c Chat

		if err = rows.Scan(
			&c.ID_,
			&c.UserID_,
			&c.ChannelID_,
			&c.ChannelType_,
			&c.Text_,
			&c.CreatedAt_,
			&c.Username_,
		); err != nil && err != sql.ErrNoRows {
			debug.Error(err)
			return nil, err
		}

		cs = append(cs, c)
	}

	return cs, nil
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:30,代码来源:chat.go

示例5: UpdateTaskTags

func UpdateTaskTags(taskID int64, tags []string) error {
	const rawSQL = `
	INSERT INTO task_tag VALUES ($1, (SELECT id FROM tag WHERE name = $2))`

	if err := ClearTaskTags(taskID); err != nil {
		debug.Error(err)
		return err
	}

	for _, tag := range tags {
		if yes, err := TagExists(tag); err != nil {
			debug.Error(err)
			return err
		} else if !yes {
			if err := CreateTag(tag); err != nil {
				debug.Error(err)
				return err
			}
		}
		if _, err := db.Exec(rawSQL, taskID, tag); err != nil {
			debug.Error(err)
			return err
		}
	}

	return nil
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:27,代码来源:task_tag.go

示例6: DeleteProject

func DeleteProject(projectID int64) error {
	const rawSQL = `DELETE FROM project WHERE id = $1`

	// delete project
	if _, err := db.Exec(rawSQL, projectID); err != nil {
		debug.Error(err)
		return err
	}

	const rawSQL2 = `DELETE FROM member WHERE project_id = $1`

	// delete project users
	if _, err := db.Exec(rawSQL2, projectID); err != nil {
		debug.Error(err)
		return err
	}

	// delete project image
	if err := os.RemoveAll(fmt.Sprintf(path.Base(ProjectImageURL), projectID)); err != nil {
		debug.Error(err)
		return err
	}

	return nil
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:25,代码来源:project.go

示例7: queryTasks

func queryTasks(rawSQL string, data ...interface{}) ([]Task, error) {
	rows, err := db.Query(rawSQL, data...)
	if err != nil {
		debug.Error(err)
		return nil, err
	}
	defer rows.Close()

	var ts []Task
	for rows.Next() {
		var t task

		if err = rows.Scan(
			&t.ID,
			&t.AuthorID,
			&t.ProjectID,
			&t.Title,
			&t.Description,
			&t.Done,
			&t.StartDate,
			&t.EndDate,
			&t.UpdatedAt,
			&t.CreatedAt,
		); err != nil && err != sql.ErrNoRows {
			debug.Error(err)
			return nil, err
		}

		if t.Author, err = GetUser(t.AuthorID); err != nil {
			debug.Error(err)
			return nil, err
		}

		t.StartDateStr = t.StartDate.Format("02 January, 2006")
		t.EndDateStr = t.EndDate.Format("02 January, 2006")
		if t.Workers, err = GetWorkers(t.ID); err != nil {
			debug.Error(err)
			return nil, err
		}

		if t.Tags, err = TaskTags(t.ID); err != nil {
			debug.Error(err)
			return nil, err
		}

		ts = append(ts, t)
	}

	return ts, nil
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:50,代码来源:task.go

示例8: queryProjects

func queryProjects(rawSQL string, data ...interface{}) ([]Project, error) {
	rows, err := db.Query(rawSQL, data...)
	if err != nil {
		debug.Error(err)
		return nil, err
	}
	defer rows.Close()

	var ps []Project
	for rows.Next() {
		var p Project

		if err = rows.Scan(
			&p.ID,
			&p.AuthorID,
			&p.Title,
			&p.Tagline,
			&p.Description,
			&p.ImageURL,
			&p.ViewCount,
			&p.Status,
			&p.UpdatedAt,
			&p.CreatedAt,
		); err != nil {
			debug.Error(err)
			return nil, err
		}

		if p.Tasks, err = GetTasks(p.ID); err != nil {
			debug.Error(err)
			return ps, err
		}

		if p.Milestones, err = GetMilestones(p.ID); err != nil {
			debug.Error(err)
			return ps, err
		}

		if p.Members, err = GetMembers(p.ID); err != nil {
			debug.Error(err)
			return ps, err
		}

		ps = append(ps, p)
	}

	return ps, nil
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:48,代码来源:project.go

示例9: ValidLogin

func ValidLogin(email, password string) (bool, error) {
	const q = `SELECT * FROM user_ WHERE email = $1`

	var u user
	if err := db.QueryRow(q, email).Scan(
		&u.ID_,
		&u.Email,
		&u.Password,
		&u.Fullname,
		&u.Title,
		&u.Description,
		&u.AvatarURL,
		&u.VerificationCode,
		&u.IsAdmin_,
		&u.UpdatedAt,
		&u.CreatedAt,
	); err != nil {
		if err != sql.ErrNoRows {
			debug.Error(err)
			return false, err
		} else {
			err = nil
		}
	}

	if bcrypt.CompareHashAndPassword([]byte(u.Password), []byte(password)) != nil || u.VerificationCode != "verified" {
		return false, nil
	}

	return true, nil
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:31,代码来源:login.go

示例10: queryMilestones

func queryMilestones(rawSQL string, data ...interface{}) ([]Milestone, error) {
	rows, err := db.Query(rawSQL, data...)
	if err != nil {
		return nil, err
	}
	defer rows.Close()

	var ms []Milestone
	for rows.Next() {
		var m milestone

		if err = rows.Scan(
			&m.ID_,
			&m.ProjectID_,
			&m.Title_,
			&m.Description_,
			&m.Date_,
			&m.UpdatedAt_,
			&m.CreatedAt_,
		); err != nil && err != sql.ErrNoRows {
			debug.Error(err)
			return nil, err
		}

		m.DateStr = m.Date_.Format("02 January, 2006")

		ms = append(ms, m)
	}

	return ms, nil
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:31,代码来源:milestone.go

示例11: updateProjectImage

func updateProjectImage(projectID int64, imageURL string) error {
	const rawSQL = `UPDATE project SET image_url = $1 WHERE id = $2`

	if _, err := db.Exec(rawSQL, imageURL, projectID); err != nil {
		debug.Error(err)
		return err
	}
	return nil
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:9,代码来源:project.go

示例12: NotifyChat

func NotifyChat(params NotifyChatParams) error {
	extra := fmt.Sprintf("c/%d/%d/%d/%s", params.ID, params.UserID, params.ChannelID, params.ChannelType)

	if _, err := db.Exec(`NOTIFY chat, '` + extra + `'`); err != nil {
		debug.Error(err)
		return err
	}

	return nil
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:10,代码来源:chat.go

示例13: ToggleTaskStatus

func ToggleTaskStatus(taskID int64) error {
	const rawSQL = `UPDATE task SET done = not done WHERE id = $1`

	if _, err := db.Exec(rawSQL, taskID); err != nil {
		debug.Error(err)
		return err
	}

	return nil
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:10,代码来源:task.go

示例14: UpdateProjectDescription

func UpdateProjectDescription(projectID int64, description string) error {
	const rawSQL = `UPDATE project SET description = $1, updated_at = now() WHERE id = $2`

	if _, err := db.Exec(rawSQL, description, projectID); err != nil {
		debug.Error(err)
		return err
	}

	return nil
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:10,代码来源:project.go

示例15: UpdateProjectTagline

func UpdateProjectTagline(projectID int64, tagline string) error {
	const rawSQL = `UPDATE project SET tagline = $1, updated_at = now() WHERE id = $2`

	if _, err := db.Exec(rawSQL, tagline, projectID); err != nil {
		debug.Error(err)
		return err
	}

	return nil
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:10,代码来源:project.go


注:本文中的github.com/bbhmakerlab/openinnovation/debug.Error函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。