pb-go-tag-bson

command module
v0.0.0-...-23e5988 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2018 License: MIT Imports: 9 Imported by: 0

README

pb-go-tag-bson

Adds bson:"-" tag to XXX_ fields in .pb.go

This utility is useful if you insert structs generated from protocol buffers into MongoDB.

Note: XXX_ fields were introduced in github.com/golang/protobuf v1.1.0

Before
type Entity struct {
	Type                 string   `protobuf:"bytes,1,opt,name=type" json:"type,omitempty"`
	Id                   string   `protobuf:"bytes,2,opt,name=id" json:"id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}
After
type Entity struct {
	Type                 string   `protobuf:"bytes,1,opt,name=type" json:"type,omitempty"`
	Id                   string   `protobuf:"bytes,2,opt,name=id" json:"id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-" bson:"-"`
	XXX_unrecognized     []byte   `json:"-" bson:"-"`
	XXX_sizecache        int32    `json:"-" bson:"-"`
}

Install

go get -u github.com/arkavo-com/pb-go-tag-bson

Usage

pb-go-tag-bson -dir /path/to/pbfiles

/path/to/pbfiles is a directory that contains *.pb.go . Recursively checks child directories.

pb-go-tag-bson -dir /path/to/pbfiles -verbose

Provides output of files analyzed and processed.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL