From 6b7f58b2ac084088c8ef37ce041262be710404b1 Mon Sep 17 00:00:00 2001 From: Etienne Perot Date: Wed, 22 Sep 2021 17:12:57 -0700 Subject: Add `NewCondition` helper in `bigquery.go`. PiperOrigin-RevId: 398366805 --- tools/bigquery/bigquery.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/bigquery/bigquery.go b/tools/bigquery/bigquery.go index 082410697..2e401b630 100644 --- a/tools/bigquery/bigquery.go +++ b/tools/bigquery/bigquery.go @@ -107,10 +107,7 @@ func (bm *Benchmark) AddMetric(metricName, unit string, sample float64) { // AddCondition adds a condition to an existing Benchmark. func (bm *Benchmark) AddCondition(name, value string) { - bm.Condition = append(bm.Condition, &Condition{ - Name: name, - Value: value, - }) + bm.Condition = append(bm.Condition, NewCondition(name, value)) } // NewBenchmark initializes a new benchmark. @@ -136,6 +133,14 @@ type Condition struct { Value string `bq:"value"` } +// NewCondition returns a new Condition with the given name and value. +func NewCondition(name, value string) *Condition { + return &Condition{ + Name: name, + Value: value, + } +} + func (c *Condition) String() string { return fmt.Sprintf("Condition:\nName: %s Value: %s\n", c.Name, c.Value) } -- cgit v1.2.3