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


Golang Package.ViewedTime方法代碼示例

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


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

示例1: updateCacheInfo

func updateCacheInfo(pdoc *doc.Package, urpids, urpts *http.Cookie) (string, string) {
	pdoc.ViewedTime = time.Now().UTC().Unix()

	updateCachePros(pdoc)
	updateProInfos(pdoc)
	return updateUrPros(pdoc, urpids, urpts)
}
開發者ID:JoeyFan,項目名稱:gowalker,代碼行數:7,代碼來源:home.go

示例2: updateRecentPros

func updateRecentPros(pdoc *doc.Package) {
	// Only projects with import path length is less than 40 letters will be showed.
	if len(pdoc.ImportPath) < 40 {
		index := -1
		listLen := len(recentViewedPros)
		curPro := &recentPro{
			Path:       pdoc.ImportPath,
			Synopsis:   pdoc.Synopsis,
			ViewedTime: time.Now().UTC().Unix(),
			IsGoRepo: pdoc.ProjectName == "Go" &&
				strings.Index(pdoc.ImportPath, ".") == -1,
			Views: pdoc.Views,
		}

		pdoc.ViewedTime = curPro.ViewedTime

		// Check if in the list
		for i, s := range recentViewedPros {
			if s.Path == curPro.Path {
				index = i
				break
			}
		}

		s := make([]*recentPro, 0, recentViewedProNum)
		s = append(s, curPro)
		switch {
		case index == -1 && listLen < recentViewedProNum:
			// Not found and list is not full
			s = append(s, recentViewedPros...)
		case index == -1 && listLen >= recentViewedProNum:
			// Not found but list is full
			s = append(s, recentViewedPros[:recentViewedProNum-1]...)
		case index > -1:
			// Found
			s = append(s, recentViewedPros[:index]...)
			s = append(s, recentViewedPros[index+1:]...)
		}
		recentViewedPros = s
	}
}
開發者ID:hendyyou,項目名稱:gowalker,代碼行數:41,代碼來源:home.go

示例3: updateRecentPros

func updateRecentPros(pdoc *doc.Package) {
	index := -1
	listLen := len(recentViewedPros)
	curPro := &recentPro{
		Path:       pdoc.ImportPath,
		ViewedTime: time.Now().UTC().Unix(),
		IsGoRepo:   pdoc.ProjectName == "Go",
		Views:      pdoc.Views,
	}

	pdoc.ViewedTime = curPro.ViewedTime

	// Check if in the list
	for i, s := range recentViewedPros {
		if s.Path == curPro.Path {
			index = i
			break
		}
	}

	s := make([]*recentPro, 0, recentViewedProNum)
	s = append(s, curPro)
	switch {
	case index == -1 && listLen < recentViewedProNum:
		// Not found and list is not full
		s = append(s, recentViewedPros...)
	case index == -1 && listLen >= recentViewedProNum:
		// Not found but list is full
		s = append(s, recentViewedPros[:recentViewedProNum-1]...)
	case index > -1:
		// Found
		s = append(s, recentViewedPros[:index]...)
		s = append(s, recentViewedPros[index+1:]...)
	}
	recentViewedPros = s
}
開發者ID:skelterjohn,項目名稱:gowalker,代碼行數:36,代碼來源:home.go


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