當前位置: 首頁>>代碼示例>>Golang>>正文


Golang User.CreateTime方法代碼示例

本文整理匯總了Golang中rter/data.User.CreateTime方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.CreateTime方法的具體用法?Golang User.CreateTime怎麽用?Golang User.CreateTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rter/data.User的用法示例。


在下文中一共展示了User.CreateTime方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: scanUser

func scanUser(user *data.User, rows *sql.Rows) error {
	var createTimeString string

	err := rows.Scan(
		&user.Username,
		&user.Password,
		&user.Salt,
		&user.Role,
		&user.TrustLevel,
		&createTimeString,
	)

	if err != nil {
		return err
	}

	createTime, err := time.Parse("2006-01-02 15:04:05", createTimeString) // this assumes UTC as timezone

	if err != nil {
		log.Println("User scanner failed to parse time.")
		return err
	}

	user.CreateTime = createTime

	return nil
}
開發者ID:falahhaprak,項目名稱:rter,代碼行數:27,代碼來源:scanners.go

示例2: TestReadUser

func TestReadUser(t *testing.T) {
	readUser := new(data.User)

	testRead(t, "/users/"+user.Username, readUser)

	readUser.CreateTime = user.CreateTime

	structJSONCompare(t, user, readUser)
}
開發者ID:falahhaprak,項目名稱:rter,代碼行數:9,代碼來源:crud_test.go

示例3: TestSelectUser

func TestSelectUser(t *testing.T) {
	selectedUser := new(data.User)
	selectedUser.Username = user.Username
	err := Select(selectedUser)

	if err != nil {
		t.Error(err)
	}

	t.Log(selectedUser.CreateTime.UTC())
	t.Log(user.CreateTime.UTC())

	selectedUser.CreateTime = user.CreateTime // Hack because MySQL will eat part of the timestamp and they won't match

	structJSONCompare(t, user, selectedUser)
}
開發者ID:falahhaprak,項目名稱:rter,代碼行數:16,代碼來源:storage_test.go

示例4: scanUser

func scanUser(user *data.User, rows *sql.Rows) error {
	var createTimeString string
	var updateTimeString string
	var statusTimeString string

	err := rows.Scan(
		&user.Username,
		&user.Password,
		&user.Salt,
		&user.Role,
		&user.TrustLevel,
		&createTimeString,
		&user.Heading,
		&user.Lat,
		&user.Lng,
		&updateTimeString,
		&user.Status,
		&statusTimeString,
	)

	if err != nil {
		return err
	}

	// TODO: this is a hacky fix for null times
	if createTimeString == "0000-00-00 00:00:00" {
		createTimeString = "0001-01-01 00:00:00"
	}
	createTime, err := time.Parse("2006-01-02 15:04:05", createTimeString) // this assumes UTC as timezone

	if err != nil {
		log.Println("User scanner failed to parse create time.")
		return err
	}

	user.CreateTime = createTime

	// TODO: this is a hacky fix for null times
	if updateTimeString == "0000-00-00 00:00:00" {
		updateTimeString = "0001-01-01 00:00:00"
	}
	updateTime, err := time.Parse("2006-01-02 15:04:05", updateTimeString) // this assumes UTC as timezone

	if err != nil {
		log.Println("User scanner failed to parse update time.")
		return err
	}

	user.UpdateTime = updateTime

	// TODO: this is a hacky fix for null times
	if statusTimeString == "0000-00-00 00:00:00" {
		statusTimeString = "0001-01-01 00:00:00"
	}
	statusTime, err := time.Parse("2006-01-02 15:04:05", statusTimeString) // this assumes UTC as timezone

	if err != nil {
		log.Println("User scanner failed to parse time.")
		return err
	}

	user.StatusTime = statusTime

	return nil
}
開發者ID:jacobmil990,項目名稱:rter,代碼行數:65,代碼來源:scanners.go


注:本文中的rter/data.User.CreateTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。