From 6e2cb00008cbf09e556b00f87603797fcaa47e09 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 16 Apr 2018 05:37:14 -0700 Subject: Depenancy upgrades and movign to dep. (#8630) --- .../github.com/mailru/easyjson/opt/optional/opt.go | 80 ---------------------- 1 file changed, 80 deletions(-) delete mode 100644 vendor/github.com/mailru/easyjson/opt/optional/opt.go (limited to 'vendor/github.com/mailru/easyjson/opt/optional/opt.go') diff --git a/vendor/github.com/mailru/easyjson/opt/optional/opt.go b/vendor/github.com/mailru/easyjson/opt/optional/opt.go deleted file mode 100644 index 277dd1a3b..000000000 --- a/vendor/github.com/mailru/easyjson/opt/optional/opt.go +++ /dev/null @@ -1,80 +0,0 @@ -// +build none - -package optional - -import ( - "fmt" - - "github.com/mailru/easyjson/jlexer" - "github.com/mailru/easyjson/jwriter" -) - -// template type Optional(A) -type A int - -// A 'gotemplate'-based type for providing optional semantics without using pointers. -type Optional struct { - V A - Defined bool -} - -// Creates an optional type with a given value. -func OOptional(v A) Optional { - return Optional{V: v, Defined: true} -} - -// Get returns the value or given default in the case the value is undefined. -func (v Optional) Get(deflt A) A { - if !v.Defined { - return deflt - } - return v.V -} - -// MarshalEasyJSON does JSON marshaling using easyjson interface. -func (v Optional) MarshalEasyJSON(w *jwriter.Writer) { - if v.Defined { - w.Optional(v.V) - } else { - w.RawString("null") - } -} - -// UnmarshalEasyJSON does JSON unmarshaling using easyjson interface. -func (v *Optional) UnmarshalEasyJSON(l *jlexer.Lexer) { - if l.IsNull() { - l.Skip() - *v = Optional{} - } else { - v.V = l.Optional() - v.Defined = true - } -} - -// MarshalJSON implements a standard json marshaler interface. -func (v Optional) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - v.MarshalEasyJSON(&w) - return w.Buffer.BuildBytes(), w.Error -} - -// UnmarshalJSON implements a standard json unmarshaler interface. -func (v *Optional) UnmarshalJSON(data []byte) error { - l := jlexer.Lexer{Data: data} - 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 Optional) IsDefined() bool { - return v.Defined -} - -// String implements a stringer interface using fmt.Sprint for the value. -func (v Optional) String() string { - if !v.Defined { - return "" - } - return fmt.Sprint(v.V) -} -- cgit v1.2.3-1-g7c22