pbutil

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: BSD-3-Clause Imports: 5 Imported by: 1

README

pbutil

Go Reference

Package pbutil provides utilities for protobuf. Please see godoc.

Proto packages

The proto (github.com/goinsane/pbutil/proto) folder provides those proto packages:

  • goinsane.pbutil in goinsane/pbutil/
  • google.protobuf (Google's protobuf) in google/protobuf/

The proto folder can be used directly as include path for protoc.

goinsane.pbutil

Proto package goinsane.pbutil in goinsane/pbutil/, provides proto files for pbutil.

google.protobuf

Proto package google.protobuf (Google's protobuf) in google/protobuf/ provides proto files of Google's protobuf.

Examples

To run any example, please use the command like the following:

cd examples/
go run example1.go

Tests

To run all tests, please use the following command:

go test -v

To run all examples, please use the following command:

go test -v -run=^Example

To run all benchmarks, please use the following command:

go test -v -run=^Benchmark -bench=.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DuplicateDuration

func DuplicateDuration(x *durationpb.Duration) *durationpb.Duration

DuplicateDuration duplicates the Duration without any check.

func DuplicateTimestamp

func DuplicateTimestamp(x *timestamppb.Timestamp) *timestamppb.Timestamp

DuplicateTimestamp duplicates the Timestamp without any check.

func DurationAsMicroseconds

func DurationAsMicroseconds(x *durationpb.Duration) int64

DurationAsMicroseconds returns microseconds as int64. If the result is out of range, it returns math.MaxInt64 or math.MinInt64.

func DurationAsMilliseconds

func DurationAsMilliseconds(x *durationpb.Duration) int64

DurationAsMilliseconds returns milliseconds as int64. If the result is out of range, it returns math.MaxInt64 or math.MinInt64.

func DurationAsNanos

func DurationAsNanos(x *durationpb.Duration) *big.Int

DurationAsNanos returns nanoseconds as big.Int.

func DurationAsNanoseconds

func DurationAsNanoseconds(x *durationpb.Duration) int64

DurationAsNanoseconds returns nanoseconds as int64. If the result is out of range, it returns math.MaxInt64 or math.MinInt64.

func DurationAsSeconds

func DurationAsSeconds(x *durationpb.Duration) int64

DurationAsSeconds returns seconds as int64. If the result is out of range, it returns math.MaxInt64 or math.MinInt64.

func IsTimestampZero

func IsTimestampZero(x *timestamppb.Timestamp) bool

IsTimestampZero checks whether the Timestamp is zero. If the Timestamp is nil or zero as time.Time, it returns true. Otherwise, returns false.

func NewDuration

func NewDuration(d time.Duration) *durationpb.Duration

NewDuration constructs a new Duration from the provided duration d.

func NewDurationByMicroseconds

func NewDurationByMicroseconds(d int64) *durationpb.Duration

NewDurationByMicroseconds constructs a new Duration from the provided int64 by microseconds.

func NewDurationByMilliseconds

func NewDurationByMilliseconds(d int64) *durationpb.Duration

NewDurationByMilliseconds constructs a new Duration from the provided int64 by milliseconds.

func NewDurationByNanoseconds

func NewDurationByNanoseconds(d int64) *durationpb.Duration

NewDurationByNanoseconds constructs a new Duration from the provided int64 by nanoseconds.

func NewDurationBySeconds

func NewDurationBySeconds(d int64) *durationpb.Duration

NewDurationBySeconds constructs a new Duration from the provided int64 by seconds.

func NewTimestamp

func NewTimestamp(t time.Time) *timestamppb.Timestamp

NewTimestamp constructs a new Timestamp from the provided time t. If t is zero, it returns nil.

func NewTimestampByMicroseconds

func NewTimestampByMicroseconds(d int64) *timestamppb.Timestamp

NewTimestampByMicroseconds constructs a new Timestamp from the provided int64 unix timestamp by microseconds.

func NewTimestampByMilliseconds

func NewTimestampByMilliseconds(d int64) *timestamppb.Timestamp

NewTimestampByMilliseconds constructs a new Timestamp from the provided int64 unix timestamp by milliseconds.

func NewTimestampByNanoseconds

func NewTimestampByNanoseconds(d int64) *timestamppb.Timestamp

NewTimestampByNanoseconds constructs a new Timestamp from the provided int64 unix timestamp by nanoseconds.

func NewTimestampBySeconds

func NewTimestampBySeconds(d int64) *timestamppb.Timestamp

NewTimestampBySeconds constructs a new Timestamp from the provided int64 unix timestamp by seconds.

func TimestampAsMicroseconds

func TimestampAsMicroseconds(x *timestamppb.Timestamp) int64

TimestampAsMicroseconds returns unix timestamp by microseconds as int64. If the result is out of range, it returns math.MaxInt64 or math.MinInt64.

func TimestampAsMilliseconds

func TimestampAsMilliseconds(x *timestamppb.Timestamp) int64

TimestampAsMilliseconds returns unix timestamp by milliseconds as int64. If the result is out of range, it returns math.MaxInt64 or math.MinInt64.

func TimestampAsNanos

func TimestampAsNanos(x *timestamppb.Timestamp) *big.Int

TimestampAsNanos returns unix timestamp by nanoseconds as big.Int.

func TimestampAsNanoseconds

func TimestampAsNanoseconds(x *timestamppb.Timestamp) int64

TimestampAsNanoseconds returns unix timestamp by nanoseconds as int64. If the result is out of range, it returns math.MaxInt64 or math.MinInt64.

func TimestampAsSeconds

func TimestampAsSeconds(x *timestamppb.Timestamp) int64

TimestampAsSeconds returns unix timestamp by seconds as int64. If the result is out of range, it returns math.MaxInt64 or math.MinInt64.

Types

This section is empty.

Directories

Path Synopsis
mongopb module
pbutilmongo module

Jump to

Keyboard shortcuts

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