go record

2026-08-30 浏览 (1)

record.go 源码

// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials  : https://learngoprogramming.com
// In-person training  : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package record

const fieldsLength = 4

// Record stores fields of a log line.
type Record struct {
	Domain  string
	Page    string
	Visits  int
	Uniques int
}

// Sum the numeric fields with another record.
func (r *Record) Sum(other Record) {
	r.Visits += other.Visits
	r.Uniques += other.Uniques
}

// Reset all the fields of this record.
func (r *Record) Reset() {
	r.Domain = ""
	r.Page = ""
	r.Visits = 0
	r.Uniques = 0
}

你可能感兴趣的文章

go sum

go validate

go text

go json

  • 所属分类: 后端技术
  • 本文标签: golang
  • 版权声明: 本文链接 https://seaxiang.com/blog/kR7fSb4E