• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang beego.Warn函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Post

/**
POST: collect train record data
body: json, two types, append and flush
{
  "op" : $op(append, flush)
  "player": $player
  "data": $data
}
result:
{
  "success": $succ
}
*/
func (this *RawTrainRecordController) Post() {
	type PostData struct {
		Op     string               `json:"op"`
		Player string               `json:"player"`
		Data   types.RawTrainRecord `json:"data"`
	}
	type Success struct {
		Succ bool `json:"success"`
	}

	var data PostData
	json.Unmarshal(this.Ctx.Input.RequestBody, &data)
	switch data.Op {
	case "append":
		models.AppendRawTrainData(data.Player, &data.Data)
		this.Data["json"] = &Success{true}
	case "flush":
		err := models.FlushRawTrainData()
		if err != nil {
			beego.Warn("Flush train data error, database error: ", err)
			this.Data["json"] = errors.Issue("Flush raw train data failed",
				errors.E_TYPE_SERVICE+errors.E_MODULE_TRAINRECORD+errors.E_DETAIL_INTERNAL_DB_ERROR,
				this.Ctx.Request.URL.String())
		} else {
			this.Data["json"] = &Success{true}
		}
	default:
		this.Data["json"] = errors.Issue("parameter op needed",
			errors.E_TYPE_SERVICE+errors.E_MODULE_TRAINRECORD+errors.E_DETAIL_ILLEGAL_PARAM,
			this.Ctx.Request.URL.String())
	}
	this.ServeJson()
}
开发者ID:Lkyzlwj,项目名称:Graduate,代码行数:46,代码来源:rawtrainrecord.go


示例2: Get

/**
GET: request the history train data(processed remark)
params: player=$player&page=$page&num=$num
result:
{
	"result": [{}, {}, ...],
	"total_number": 2,
  "before": 0,
  "current": 1,
  "next": 0
}
*/
func (this *TrainHistoryController) Get() {
	page, err := this.GetInt("page", 0)
	if err != nil {
		beego.Warn("Query train history error, parse page error: ", err)
		this.Data["json"] = errors.Issue("Parse page error",
			errors.E_TYPE_SERVICE+errors.E_MODULE_TRAINHISTORY+errors.E_DETAIL_PARSE_PARAM_ERROR,
			this.Ctx.Request.URL.String())
		this.ServeJson()
		return
	}

	num, err := this.GetInt("num", 10)
	if err != nil {
		beego.Warn("Query train history error, parse num error: ", err)
		this.Data["json"] = errors.Issue("Parse num error",
			errors.E_TYPE_SERVICE+errors.E_MODULE_TRAINHISTORY+errors.E_DETAIL_PARSE_PARAM_ERROR,
			this.Ctx.Request.URL.String())
		this.ServeJson()
		return
	}

	if page < 0 || num < 0 {
		beego.Warn("Query train history error, wrong params: page, num = ", page, num)
		this.Data["json"] = errors.Issue("Page and num must be non-negative",
			errors.E_TYPE_SERVICE+errors.E_MODULE_TRAINHISTORY+errors.E_DETAIL_ILLEGAL_PARAM,
			this.Ctx.Request.URL.String())
		this.ServeJson()
		return
	}

	player := this.GetString("player")
	if len(player) != 40 {
		beego.Warn("Query train history error, wrong params: player = ", player)
		this.Data["json"] = errors.Issue("Invalid player",
			errors.E_TYPE_SERVICE+errors.E_MODULE_TRAINHISTORY+errors.E_DETAIL_ILLEGAL_PARAM,
			this.Ctx.Request.URL.String())
		this.ServeJson()
		return
	}

	this.Data["json"] = models.QueryTrainRecord(player, page, num)

	beego.Info(fmt.Sprintf("Query train history, req: %s, player: %s, page: %d, num: %d",
		this.Ctx.Request.URL.String(), player, page, num))

	this.ServeJson()
}
开发者ID:Lkyzlwj,项目名称:Graduate,代码行数:59,代码来源:trainhistory.go


示例3: check_once

func (mapp *MonitorForApp) check_once() bool {
	milliseconds := 500
	client := &http.Client{
		Timeout: time.Duration(milliseconds) * time.Millisecond,
	}
	resp, err := client.Get(mapp.Url)
	if err != nil {
		beego.Warn("check app error : " + err.Error())
		return false
	}
	defer resp.Body.Close()
	if resp.StatusCode != 200 {
		beego.Warn("check app status is : " + strconv.Itoa(resp.StatusCode))
		return false
	}
	return true
}
开发者ID:souche-open,项目名称:smoni,代码行数:17,代码来源:appsMonitor.go


示例4: Index

// show all criteria
func (c *Crit) Index() {
	crit := &M.Crit{}
	groups, err := crit.GetGroupedCrits()
	if err != nil {
		beego.Warn("GroupError", err)
	}
	c.Data["groups"] = groups
}
开发者ID:grr89,项目名称:hrkb,代码行数:9,代码来源:crit.go


示例5: RoundTrip

func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
	timer := time.AfterFunc(*requestTimeout, func() {
		t.t.CancelRequest(req)
		beego.Warn("Canceled request for %s", req.URL)
	})
	defer timer.Stop()
	resp, err := t.t.RoundTrip(req)
	return resp, err
}
开发者ID:kobeyyf,项目名称:beeweb,代码行数:9,代码来源:http.go


示例6: Post

// save concrete candidate rating
func (c *Rat) Post() {

	if !c.IsAjax() {
		return
	}

	var err error
	var s string
	var v M.ValidMap
	var ok bool

	r := M.Rat{Active: true}

	err = c.ParseForm(&r)

	uid := c.GetSession("uid")
	if uid == nil {
		c.Data["json"] = RJson{T("auth_is_off"), ok}
		return
	}

	fr := M.Rat{}
	err = DM.Find(&fr, M.Sf{}, M.Where{And: M.W{"Cand": r.Cand, "User": uid.(int), "Crit": r.Crit}})
	if err != nil && err != sql.ErrNoRows {
		c.Data["json"] = RJson{T("internal"), ok}
		beego.Warn(err)
		return
	}

	if fr.Id > 0 {
		c.Data["json"] = RJson{T("rat_already"), ok}
		return
	}

	r.User = uid.(int)

	if err == sql.ErrNoRows {
		v, err = DM.Insert(&r)
	}

	if err != nil {
		s = T("save_error")
		beego.Error(err)
	}

	if !v.HasErrors() {
		s = T("rat_added")
		ok = true
	} else {
		s = T("validation_error")
	}

	c.Data["json"] = RJson{s, ok}
}
开发者ID:grr89,项目名称:hrkb,代码行数:55,代码来源:rat.go


示例7: M

func (d *Db) M(collection string, f func(*mgo.Collection)) {
	session := d.Dial()
	defer func() {
		session.Close()
		if err := recover(); err != nil {
			beego.Warn(fmt.Sprintf("MongoDB recover: %s", err))
		}
	}()
	c := session.DB(beego.AppConfig.String("MONGO_DbName")).C(collection)
	f(c)
}
开发者ID:yearnfar,项目名称:gocms,代码行数:11,代码来源:db.go


示例8: LogItemDelete

func LogItemDelete(item interface{}, deleter string) bool {
	log := logs.NewLogger(10000)
	log.SetLogger("file", `{"filename":"db/deletedItems.log"}`)
	if b, err := json.Marshal(item); err == nil {
		fmt.Println(b)
		beego.Warn("deleter: ", deleter, " item: ", string(b))
		log.Info("deleter: ", deleter, " item: ", string(b))
		return true
	}
	return false
}
开发者ID:zixinjian,项目名称:webo_dev,代码行数:11,代码来源:wblog.go


示例9: Get

/**
GET: request the processed remark
params: player=$player&page=$page&num=$num
result:
{
	"result": [...],
	"total_number": 2,
  "before": 0,
  "current": 1,
  "next": 0
}
*/
func (this *TrainRemarkController) Get() {
	player := this.GetString("player")
	if len(player) != 40 {
		beego.Warn("Query train remark error, wrong params: player = ", player)
		this.Data["json"] = errors.Issue("Invalid player",
			errors.E_TYPE_SERVICE+errors.E_MODULE_TRAINREMARK+errors.E_DETAIL_ILLEGAL_PARAM,
			this.Ctx.Request.URL.String())
		this.ServeJson()
		return
	}

	page, err := this.GetInt("page", 0)
	if err != nil {
		beego.Warn("Get players error, parse page error: ", err)
		this.Data["json"] = errors.Issue("Parse page error",
			errors.E_TYPE_SERVICE+errors.E_MODULE_TRAINREMARK+errors.E_DETAIL_PARSE_PARAM_ERROR,
			this.Ctx.Request.URL.String())
		this.ServeJson()
		return
	}

	num, err := this.GetInt("num", 10)
	if err != nil {
		beego.Warn("Get players error, parse num error: ", err)
		this.Data["json"] = errors.Issue("Parse num error",
			errors.E_TYPE_SERVICE+errors.E_MODULE_TRAINREMARK+errors.E_DETAIL_PARSE_PARAM_ERROR,
			this.Ctx.Request.URL.String())
		this.ServeJson()
		return
	}

	this.Data["json"] = models.GetTrainRecord(player, page, num)
	beego.Info(fmt.Sprintf("Query train remark, req: %s, player: %s, page: %d, num: %d",
		this.Ctx.Request.URL.String(), player, page, num))

	this.ServeJson()
}
开发者ID:Lkyzlwj,项目名称:Graduate,代码行数:49,代码来源:trainremark.go


示例10: Get

/**
GET: query players
params: page, num
result: json
error happened:
{
	"error": "Error message",
	"error_code": $code,
	"request": "/api/player?page=$page&num=$num"
}
success:
{
	"result": [{}, {}, ...],
	"total_number": 2,
  "before": 0,
  "current": 1,
  "next": 0
}
*/
func (this *PlayersController) Get() {
	page, err := this.GetInt("page", 0)
	if err != nil {
		beego.Warn("Get players error, parse page error: ", err)
		this.Data["json"] = errors.Issue("Parse page error",
			errors.E_TYPE_SERVICE+errors.E_MODULE_PLAYER+errors.E_DETAIL_PARSE_PARAM_ERROR,
			this.Ctx.Request.URL.String())
		this.ServeJson()
		return
	}

	num, err := this.GetInt("num", 10)
	if err != nil {
		beego.Warn("Get players error, parse num error: ", err)
		this.Data["json"] = errors.Issue("Parse num error",
			errors.E_TYPE_SERVICE+errors.E_MODULE_PLAYER+errors.E_DETAIL_PARSE_PARAM_ERROR,
			this.Ctx.Request.URL.String())
		this.ServeJson()
		return
	}

	if page < 0 || num < 0 {
		beego.Warn("Get players error, wrong params: page, num = ", page, num)
		this.Data["json"] = errors.Issue("Page and num must be non-negative",
			errors.E_TYPE_SERVICE+errors.E_MODULE_PLAYER+errors.E_DETAIL_ILLEGAL_PARAM,
			this.Ctx.Request.URL.String())
		this.ServeJson()
		return
	}

	beego.Info(fmt.Sprintf("Query player, req: %s, page: %d, num: %d",
		this.Ctx.Request.URL.String(), page, num))

	this.Data["json"] = models.QueryPlayer(page, num)
	this.ServeJson()
}
开发者ID:Lkyzlwj,项目名称:Graduate,代码行数:55,代码来源:players.go


示例11: Post

func (this *MainController2) Post() {
	var filename = this.Ctx.Input.Param(":filename")
	if this.Ctx.Input.RequestBody == nil {
		this.Ctx.Input.CopyBody()
	}
	fout, err := os.Create("files/" + filename)
	defer fout.Close()
	if err != nil {
		beego.Warn("create file", filename, "fail")
	} else {
		fout.Write(this.Ctx.Input.RequestBody)
	}
	this.Ctx.Output.Header("Access-Control-Allow-Origin", "*")
	this.Ctx.Output.SetStatus(200)
}
开发者ID:finove,项目名称:fileserver,代码行数:15,代码来源:default.go


示例12: Handle

func (self *Server) Handle() (bool, error) {

	self.body = self.ctx.Input.RequestBody

	var err error

	if len(self.body) < (PROTOCOL_LENGTH + PACKAGER_LENGTH) {

		return false, errors.New("read request body error.")
	}

	header, err := self.getHeader()

	if err != nil {
		beego.Error(err)
		return false, err
	}

	request, err := self.getRequest(header)

	if err != nil {
		beego.Error(err)
		return false, err
	}

	response := NewResponse()
	response.Status = ERR_OKEY
	response.Protocol = header
	self.call(request, response)
	self.sendResponse(response)

	if response.Status != ERR_OKEY {

		beego.Warn(request.Id, request.Method, response.Error)

	} else {

		beego.Notice(request.Id, request.Method, "OKEY")

	}

	return true, nil
}
开发者ID:weixinhost,项目名称:beego-yar,代码行数:43,代码来源:server.go


示例13: init

func init() {
	//open db
	//the access of db needn't sync, it's done by mongo
	var err error
	dbHelper, err = dbhelper.Open(dbHost, dbName, playersCollName)
	if err != nil {
		panic(err)
	}

	//preload all players
	players, err = dbHelper.QueryAllPlayer()
	if err != nil {
		if players == nil {
			panic(err)
		} //else
		beego.Warn("Error happened when query all player: ", err)
	}

	if players == nil {
		players = make([]types.Player, 0)
	}

	//auth
	appConf, err := config.NewConfig("ini", "conf/app.conf")
	if err != nil {
		panic(err)
	}

	username = appConf.String("admin::username")
	password = appConf.String("admin::password")
	rander = rand.New(rand.NewSource(time.Now().UnixNano()))
	ResetToken()

	//these two maps should sync, ideally it needn't, cause every device access
	//its own k-v pair. but it can not be guaranteed
	//raw train record
	rawTrainRecord = make(map[string]types.RawTrainRecord)
	//processed record
	processedRecord = make(map[string]types.TrainRecord)
	//raw train record processor
	rawDataProcessor = processor.NaiveProcessor{}
}
开发者ID:Lkyzlwj,项目名称:Graduate,代码行数:42,代码来源:storage.go


示例14: Post

//check auth form
func (c *Main) Post() {

	var v M.ValidMap

	c.Data["xsrfdata"] = template.HTML(c.XsrfFormHtml())
	c.TplNames = "loginform.tpl"

	loginform := LoginForm{}
	c.ParseForm(&loginform)
	v.Valid(loginform)

	c.Data["login"] = loginform.Login
	M.ExpandFormErrors(&v, c.Data)

	if v.HasErrors() {
		return
	}

	c.Data["errLogin"] = T("login_error")
	id, err := M.CheckPass(loginform.Login, loginform.Password)

	if err != nil {
		beego.Warn(err)
		return
	}

	u := M.User{}
	err = DM.FindByPk(&u, id)
	if err != nil {
		beego.Error(err)
		return
	}

	if len(u.GToken.String) > 0 {
		c.SetSession("gitlabToken", u.GToken.String)
	}
	c.SetSession("uid", id)
	c.SetSession("role", u.Role)
	c.SetSession("name", u.Name)
	c.Redirect(beego.UrlFor("Cand.Index"), 302)
}
开发者ID:grr89,项目名称:hrkb,代码行数:42,代码来源:main.go


示例15: runCmdWithTimeout

func runCmdWithTimeout(cmd *exec.Cmd, timeout time.Duration) (error, bool) {
	done := make(chan error)
	go func() {
		done <- cmd.Wait()
	}()

	var err error
	select {
	case <-time.After(timeout):
		beego.Warn(fmt.Sprintf("任务执行时间超过%d秒,进程将被强制杀掉: %d", int(timeout/time.Second), cmd.Process.Pid))
		go func() {
			<-done // 读出上面的goroutine数据,避免阻塞导致无法退出
		}()
		if err = cmd.Process.Kill(); err != nil {
			beego.Error(fmt.Sprintf("进程无法杀掉: %d, 错误信息: %s", cmd.Process.Pid, err))
		}
		return err, true
	case err = <-done:
		return err, false
	}
}
开发者ID:cluo,项目名称:webcron,代码行数:21,代码来源:init.go


示例16: InitNewrelicAgent

func InitNewrelicAgent() {

	license := beego.AppConfig.String("NewrelicLicense")
	if license == "" {
		beego.Warn("Please specify NewRelic license in the application config: NewrelicLicense=7bceac019c7dcafae1ef95be3e3a3ff8866de245")
		return
	}

	agent = gorelic.NewAgent()
	agent.NewrelicLicense = license

	agent.HTTPTimer = metrics.NewTimer()
	agent.CollectHTTPStat = true

	if beego.RunMode == "dev" {
		agent.Verbose = true
	}
	if verbose, err := beego.AppConfig.Bool("NewrelicVerbose"); err == nil {
		agent.Verbose = verbose
	}

	nameParts := []string{beego.AppConfig.String("appname")}
	switch strings.ToLower(beego.AppConfig.String("NewrelicAppnameRunmode")) {
	case "append":
		nameParts = append(nameParts, beego.RunMode)

	case "prepend":
		nameParts = append([]string{beego.RunMode}, nameParts...)
	}
	agent.NewrelicName = strings.Join(nameParts, SEPARATOR)
	agent.Run()

	beego.InsertFilter("*", beego.BeforeRouter, InitNewRelicTimer, false)
	beego.InsertFilter("*", beego.FinishRouter, ReportMetricsToNewrelic, false)

	beego.Info("NewRelic agent started")
}
开发者ID:jiaxinwang,项目名称:beego_gorelic,代码行数:37,代码来源:gorelic.go


示例17: Post

/**
POST: insert or update player(ObjId not empty means update)
request body: player info(json)
result: json
success:
{
	"success": true,
	"id": $ObjId
}
*/
func (this *PlayersController) Post() {
	var player types.Player
	json.Unmarshal(this.Ctx.Input.RequestBody, &player)
	/*if !player.Valid() {
		beego.Warn("Add/Update players error, invalid data: ", player, string(this.Ctx.Input.RequestBody))
		this.Data["json"] = errors.Issue("Player info incomplete",
			errors.E_TYPE_SERVICE + errors.E_MODULE_PLAYER + errors.E_DETAIL_INCOMPLETE_DATA,
			this.Ctx.Request.URL.String())
		this.ServeJson()
		return
	}*/
	beego.Info("data & player ", string(this.Ctx.Input.RequestBody), player)
	var err error
	if player.ObjId != "" {
		err = models.UpdatePlayer(&player)
	} else {
		err = models.InsertPlayer(&player)
	}

	if err != nil {
		beego.Warn("Add/Update players error, database error: ", err)
		this.Data["json"] = errors.Issue("Database operate error",
			errors.E_TYPE_SERVICE+errors.E_MODULE_PLAYER+errors.E_DETAIL_INTERNAL_DB_ERROR,
			this.Ctx.Request.URL.String())
		this.ServeJson()
		return
	}

	beego.Info("Add/Update players success, player id: ", player.ObjId.Hex())

	type Success struct {
		Succ         bool `json:"success"`
		types.Player `json:"player"`
	}
	this.Data["json"] = &Success{true, player}
	this.ServeJson()
}
开发者ID:Lkyzlwj,项目名称:Graduate,代码行数:47,代码来源:players.go


示例18: Get

// Get implemented Get method for HomeRouter.
func (this *HomeRouter) Get() {
	// Filter unusual User-Agent.
	ua := this.Ctx.Request.Header.Get("User-Agent")
	if len(ua) < 20 {
		beego.Warn("User-Agent:", this.Ctx.Request.Header.Get("User-Agent"))
		this.Ctx.WriteString("")
		return
	}

	// Set language version.
	curLang := globalSetting(this.Ctx, this.Input(), this.Data)

	// Get argument(s).
	q := strings.TrimRight(
		strings.TrimSpace(this.Input().Get("q")), "/")

	if path, ok := utils.IsBrowseURL(q); ok {
		q = path
	}

	// Get pure URL.
	reqUrl := this.Ctx.Request.RequestURI[1:]
	if i := strings.Index(reqUrl, "?"); i > -1 {
		reqUrl = reqUrl[:i]
		if path, ok := utils.IsBrowseURL(reqUrl); ok {
			reqUrl = path
		}
	}

	// Redirect to query string.
	if len(reqUrl) == 0 && len(q) > 0 {
		reqUrl = q
		this.Redirect("/"+reqUrl, 302)
		return
	}

	// User Recent projects.
	urpids, _ := this.Ctx.Request.Cookie("UserRecentPros")
	urpts, _ := this.Ctx.Request.Cookie("URPTimestamps")

	this.TplNames = "home_" + curLang.Lang + ".html"
	// Check to show home page or documentation page.
	if len(reqUrl) == 0 && len(q) == 0 {
		serveHome(this, urpids, urpts)
	} else {
		// Documentation.
		this.TplNames = "docs_" + curLang.Lang + ".html"
		broPath := reqUrl // Browse path.

		// Check if it's the standard library.
		if utils.IsGoRepoPath(broPath) {
			broPath = "code.google.com/p/go/source/browse/src/pkg/" + broPath
		}

		// Check if it's a remote path that can be used for 'go get', if not means it's a keyword.
		if !utils.IsValidRemotePath(broPath) {
			// Search.
			this.Redirect("/search?q="+reqUrl, 302)
			return
		}

		// Get tag field.
		tag := strings.TrimSpace(this.Input().Get("tag"))
		if tag == "master" || tag == "default" {
			tag = ""
		}

		// Check documentation of this import path, and update automatically as needed.
		pdoc, err := doc.CheckDoc(reqUrl, tag, doc.HUMAN_REQUEST)
		if err == nil {
			if pdoc != nil {
				pdoc.UserExamples = getUserExamples(pdoc.ImportPath)
				// Generate documentation page.
				if generatePage(this, pdoc, broPath, tag, curLang.Lang) {
					ps, ts := updateCacheInfo(pdoc, urpids, urpts)
					this.Ctx.SetCookie("UserRecentPros", ps, 9999999999, "/")
					this.Ctx.SetCookie("URPTimestamps", ts, 9999999999, "/")
					return
				}
			}
		} else {
			this.Data["IsHasError"] = true
			this.Data["ErrMsg"] = strings.Replace(err.Error(),
				doc.GetGithubCredentials(), "<githubCred>", 1)
			beego.Error("HomeRouter.Get ->", err)
			this.TplNames = "home_" + curLang.Lang + ".html"
			serveHome(this, urpids, urpts)
			return
		}

		this.Redirect("/search?q="+reqUrl, 302)
		return
	}
}
开发者ID:JoeyFan,项目名称:gowalker,代码行数:95,代码来源:home.go


示例19: Warn

func Warn(message string) {
	beego.Warn(message)
	Log.logger.Warn(message)
}
开发者ID:e-wings,项目名称:go-tools,代码行数:4,代码来源:log.go


示例20: Get

// Get implemented Get method for HomeRouter.
func (this *HomeRouter) Get() {
	// Filter unusual User-Agent.
	ua := this.Ctx.Request.Header.Get("User-Agent")
	if len(ua) < 20 {
		beego.Warn("User-Agent:", this.Ctx.Request.Header.Get("User-Agent"))
		return
	}

	// Set language version.
	curLang := setLangVer(this.Ctx, this.Input(), this.Data)

	// Get query field.
	q := strings.TrimSpace(this.Input().Get("q"))

	// Remove last "/".
	q = strings.TrimRight(q, "/")

	if path, ok := utils.IsBrowseURL(q); ok {
		q = path
	}

	// Get pure URL.
	reqUrl := this.Ctx.Request.RequestURI[1:]
	if i := strings.Index(reqUrl, "?"); i > -1 {
		reqUrl = reqUrl[:i]
		if path, ok := utils.IsBrowseURL(reqUrl); ok {
			reqUrl = path
		}
	}

	// Redirect to query string.
	if len(reqUrl) == 0 && len(q) > 0 {
		reqUrl = q
		this.Redirect("/"+reqUrl, 302)
		return
	}

	// Check show home page or documentation page.
	if len(reqUrl) == 0 && len(q) == 0 {
		// Home page.
		this.Data["IsHome"] = true
		this.TplNames = "home_" + curLang.Lang + ".html"

		// Recent projects
		this.Data["RecentPros"] = recentViewedPros
		// Get popular project and examples list from database.
		this.Data["PopPros"], this.Data["RecentExams"] = models.GetPopulars(20, 12)
		// Set standard library keyword type-ahead.
		this.Data["DataSrc"] = utils.GoRepoSet
	} else {
		// Documentation page.
		this.TplNames = "docs_" + curLang.Lang + ".html"
		broPath := reqUrl // Browse path.

		// Check if it is standard library.
		if utils.IsGoRepoPath(broPath) {
			broPath = "code.google.com/p/go/source/browse/src/pkg/" + broPath
		}

		// Check if it is a remote path that can be used for 'gopm get', if not means it's a keyword.
		if !utils.IsValidRemotePath(broPath) {
			// Show search page
			this.Redirect("/search?q="+reqUrl, 302)
			return
		}

		// Get tag field.
		tag := strings.TrimSpace(this.Input().Get("tag"))
		if tag == "master" || tag == "default" {
			tag = ""
		}

		// Check documentation of this import path, and update automatically as needed.
		pdoc, err := doc.CheckDoc(reqUrl, tag, doc.HUMAN_REQUEST)
		if err == nil || pdoc == nil {
			pdoc.UserExamples = getUserExamples(pdoc.ImportPath)
			// Generate documentation page.
			if generatePage(this, pdoc, broPath, tag, curLang.Lang) {
				// Update recent project list.
				updateRecentPros(pdoc)
				// Update project views.
				pinfo := &models.PkgInfo{
					Path:        pdoc.ImportPath,
					Synopsis:    pdoc.Synopsis,
					Created:     pdoc.Created,
					ProName:     pdoc.ProjectName,
					ViewedTime:  pdoc.ViewedTime,
					Views:       pdoc.Views,
					IsCmd:       pdoc.IsCmd,
					Etag:        pdoc.Etag,
					Labels:      pdoc.Labels,
					Tags:        strings.Join(pdoc.Tags, "|||"),
					ImportedNum: pdoc.ImportedNum,
					ImportPid:   pdoc.ImportPid,
				}
				models.AddViews(pinfo)
				return
			}
		} else {
//.........这里部分代码省略.........
开发者ID:seacoastboy,项目名称:gowalker,代码行数:101,代码来源:home.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang beego.Controller类代码示例发布时间:2022-05-24
下一篇:
Golang beego.UrlFor函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap