File: params.go

package info (click to toggle)
golang-github-influxdata-influxdb1-client 0.0~git20220302.a9ab567-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 380 kB
  • sloc: makefile: 2
file content (73 lines) | stat: -rw-r--r-- 1,576 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package client

import (
	"encoding/json"
	"time"
)

type (
	// Identifier is an identifier value.
	Identifier string

	// StringValue is a string literal.
	StringValue string

	// RegexValue is a regexp literal.
	RegexValue string

	// NumberValue is a number literal.
	NumberValue float64

	// IntegerValue is an integer literal.
	IntegerValue int64

	// BooleanValue is a boolean literal.
	BooleanValue bool

	// TimeValue is a time literal.
	TimeValue time.Time

	// DurationValue is a duration literal.
	DurationValue time.Duration
)

func (v Identifier) MarshalJSON() ([]byte, error) {
	m := map[string]string{"identifier": string(v)}
	return json.Marshal(m)
}

func (v StringValue) MarshalJSON() ([]byte, error) {
	m := map[string]string{"string": string(v)}
	return json.Marshal(m)
}

func (v RegexValue) MarshalJSON() ([]byte, error) {
	m := map[string]string{"regex": string(v)}
	return json.Marshal(m)
}

func (v NumberValue) MarshalJSON() ([]byte, error) {
	m := map[string]float64{"number": float64(v)}
	return json.Marshal(m)
}

func (v IntegerValue) MarshalJSON() ([]byte, error) {
	m := map[string]int64{"integer": int64(v)}
	return json.Marshal(m)
}

func (v BooleanValue) MarshalJSON() ([]byte, error) {
	m := map[string]bool{"boolean": bool(v)}
	return json.Marshal(m)
}

func (v TimeValue) MarshalJSON() ([]byte, error) {
	t := time.Time(v)
	m := map[string]string{"string": t.Format(time.RFC3339Nano)}
	return json.Marshal(m)
}

func (v DurationValue) MarshalJSON() ([]byte, error) {
	m := map[string]int64{"duration": int64(v)}
	return json.Marshal(m)
}