當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。