File: models.go

package info (click to toggle)
golang-gogoprotobuf 1.0.0%2Bgit20180330.1ef32a8b-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 15,932 kB
  • sloc: makefile: 462; sh: 23
file content (41 lines) | stat: -rw-r--r-- 753 bytes parent folder | download | duplicates (3)
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
package typedecl

import (
	"encoding/json"

	"github.com/gogo/protobuf/jsonpb"
)

type Dropped struct {
	Name string
	Age  int32
}

func (d *Dropped) Drop() bool {
	return true
}

func (d *Dropped) UnmarshalJSONPB(u *jsonpb.Unmarshaler, b []byte) error {
	return json.Unmarshal(b, d)
}

func (d *Dropped) MarshalJSONPB(*jsonpb.Marshaler) ([]byte, error) {
	return json.Marshal(d)
}

type DroppedWithoutGetters struct {
	Width  int64
	Height int64
}

func (d *DroppedWithoutGetters) GetHeight() int64 {
	return d.Height
}

func (d *DroppedWithoutGetters) UnmarshalJSONPB(u *jsonpb.Unmarshaler, b []byte) error {
	return json.Unmarshal(b, d)
}

func (d *DroppedWithoutGetters) MarshalJSONPB(*jsonpb.Marshaler) ([]byte, error) {
	return json.Marshal(d)
}