protowrap

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: MIT Imports: 4 Imported by: 0

README

Protobuf wrapperspb helpers

pkg-img coverage-img

Provides helpers functions converting wrapperspb

Installation

Go version 1.18+

go get github.com/itcomusic/protowrap

Usage

package main

import (
	"fmt"

	"google.golang.org/protobuf/types/known/wrapperspb"

	"github.com/itcomusic/protowrap"
)

func main() {
	i := protowrap.IntF32V[int](&wrapperspb.Int32Value{Value: 1})
	fmt.Println(*i) // 1

	ints := protowrap.Ints[int]([]int32{1, 2, 3})
	fmt.Println(ints) // [1, 2, 3]

	wi32 := protowrap.Int32Value(i)
	fmt.Println(wi32) // value:1
}

Documentation

Overview

Package protowrap provides functions of converting and helpers for wrapperspb types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v *wrapperspb.BoolValue) *bool

Bool returns *bool from *wrapperspb.BoolValue.

func BoolValue

func BoolValue(v *bool) *wrapperspb.BoolValue

BoolValue returns *wrapperspb.BoolValue from *bool.

func DoubleValue

func DoubleValue[T constraints.Float](v *T) *wrapperspb.DoubleValue

DoubleValue returns *wrapperspb.DoubleValue from *float.

func FloatF32V

func FloatF32V[T constraints.Float](v *wrapperspb.FloatValue) *T

FloatF32V returns *float from *wrapperspb.FloatValue.

func FloatF64V

func FloatF64V[T constraints.Float](v *wrapperspb.DoubleValue) *T

FloatF64V returns *float from *wrapperspb.DoubleValue.

func FloatValue

func FloatValue[T constraints.Float](v *T) *wrapperspb.FloatValue

FloatValue returns *wrapperspb.FloatValue from *float.

func Int32Value

func Int32Value[T constraints.Integer](v *T) *wrapperspb.Int32Value

Int32Value returns *wrapperspb.Int32Value from *int.

func Int64Value

func Int64Value[T constraints.Integer](v *T) *wrapperspb.Int64Value

Int64Value returns *wrapperspb.Int64Value from *int.

func IntF32V

func IntF32V[T constraints.Integer](v *wrapperspb.Int32Value) *T

IntF32V returns *int from *wrapperspb.Int32Value.

func IntF64V

func IntF64V[T constraints.Integer](v *wrapperspb.Int64Value) *T

IntF64V returns *int from *wrapperspb.Int64Value.

func Ints

func Ints[OUT constraints.Integer, IN constraints.Integer](v []IN) []OUT

Ints returns slice of a new type.

func String

func String(v *wrapperspb.StringValue) *string

String returns *string from *wrapperspb.StringValue.

func StringValue

func StringValue(v *string) *wrapperspb.StringValue

StringValue returns *wrapperspb.StringValue from *string.

func Time

func Time(v *timestamppb.Timestamp) *time.Time

Time returns *time.Time from *timestamppb.Timestamp.

func Timestamp

func Timestamp(v *time.Time) *timestamppb.Timestamp

Timestamp returns *timestamppb.Timestamp from *time.Time.

Types

This section is empty.

Jump to

Keyboard shortcuts

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