Golang github.com-alevinval-foosbot.Context类(方法)实例源码

下面列出了Golang github.com-alevinval-foosbot.Context 类(方法)源码代码实例,从而了解它的用法。

作者:alevinva    项目:foosbo   
func benchmarkStoreState(b *testing.B, c *foosbot.Context) {
	b.ResetTimer()
	b.ReportAllocs()
	for i := 0; i < b.N; i++ {
		c.Store()
	}
}

作者:alevinva    项目:foosbo   
func statsCommand(ctx *foosbot.Context, statement *parsing.StatStatement) string {
	stats, err := ctx.ExecuteStats(*statement)
	if err != nil {
		return err.Error()
	}
	return ctx.ReportStats(stats)
}

作者:alevinva    项目:foosbo   
func benchmarkLoadState(b *testing.B, c *foosbot.Context) {
	b.ResetTimer()
	b.ReportAllocs()
	for i := 0; i < b.N; i++ {
		c.Reset()
		c.Load()
	}
}

作者:alevinva    项目:foosbo   
func addMatchCommand(ctx *foosbot.Context, statement *parsing.MatchStatement) string {
	err := ctx.ExecuteMatch(*statement)
	if err != nil {
		panic(err)
	}
	total := statement.TeamOneScore + statement.TeamTwoScore
	return fmt.Sprintf("%d matches registered to history.", total)
}

作者:alevinva    项目:foosbo   
func addMatches(c *foosbot.Context, outcomes []*foosbot.Outcome) {
	for k := 0; k < len(outcomes); k++ {
		c.AddMatchWithOutcome(outcomes[k])
	}
}

作者:alevinva    项目:foosbo   
func getLeaderboard(ctx *foosbot.Context) string {
	stats := ctx.PlayersStatsFromMatches(10, 10)
	response := ctx.ReportLeaderBoard(stats)
	return response
}

作者:alevinva    项目:foosbo   
func backup(c *foosbot.Context) {
	for {
		time.Sleep(1 * time.Hour)
		c.Store()
	}
}


问题


面经


文章

微信
公众号

扫码关注公众号