mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-07 02:07:58 +00:00
Add vendor folder to git
This commit is contained in:
parent
66cf5eaafb
commit
183585f56f
6916 changed files with 2629581 additions and 1 deletions
79
vendor/github.com/mailru/easyjson/opt/gotemplate_Int.go
generated
vendored
Normal file
79
vendor/github.com/mailru/easyjson/opt/gotemplate_Int.go
generated
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
// generated by gotemplate
|
||||
|
||||
package opt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/mailru/easyjson/jlexer"
|
||||
"github.com/mailru/easyjson/jwriter"
|
||||
)
|
||||
|
||||
// template type Optional(A)
|
||||
|
||||
// A 'gotemplate'-based type for providing optional semantics without using pointers.
|
||||
type Int struct {
|
||||
V int
|
||||
Defined bool
|
||||
}
|
||||
|
||||
// Creates an optional type with a given value.
|
||||
func OInt(v int) Int {
|
||||
return Int{V: v, Defined: true}
|
||||
}
|
||||
|
||||
// Get returns the value or given default in the case the value is undefined.
|
||||
func (v Int) Get(deflt int) int {
|
||||
if !v.Defined {
|
||||
return deflt
|
||||
}
|
||||
return v.V
|
||||
}
|
||||
|
||||
// MarshalEasyJSON does JSON marshaling using easyjson interface.
|
||||
func (v Int) MarshalEasyJSON(w *jwriter.Writer) {
|
||||
if v.Defined {
|
||||
w.Int(v.V)
|
||||
} else {
|
||||
w.RawString("null")
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalEasyJSON does JSON unmarshaling using easyjson interface.
|
||||
func (v *Int) UnmarshalEasyJSON(l *jlexer.Lexer) {
|
||||
if l.IsNull() {
|
||||
l.Skip()
|
||||
*v = Int{}
|
||||
} else {
|
||||
v.V = l.Int()
|
||||
v.Defined = true
|
||||
}
|
||||
}
|
||||
|
||||
// MarshalJSON implements a standard json marshaler interface.
|
||||
func (v *Int) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
v.MarshalEasyJSON(&w)
|
||||
return w.Buffer.BuildBytes(), w.Error
|
||||
}
|
||||
|
||||
// MarshalJSON implements a standard json marshaler interface.
|
||||
func (v *Int) UnmarshalJSON(data []byte) error {
|
||||
l := jlexer.Lexer{}
|
||||
v.UnmarshalEasyJSON(&l)
|
||||
return l.Error()
|
||||
}
|
||||
|
||||
// IsDefined returns whether the value is defined, a function is required so that it can
|
||||
// be used in an interface.
|
||||
func (v Int) IsDefined() bool {
|
||||
return v.Defined
|
||||
}
|
||||
|
||||
// String implements a stringer interface using fmt.Sprint for the value.
|
||||
func (v Int) String() string {
|
||||
if !v.Defined {
|
||||
return "<undefined>"
|
||||
}
|
||||
return fmt.Sprint(v.V)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue