go-type-adapters

module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0

README

Go google.type Adapters

ci latest release go version

This library provides helper functions for converting between the Go proto messages in google.type (as found in genproto) and Go native types.

Full docs are at https://pkg.go.dev/github.com/googleapis/go-type-adapters.

Example

As a simple example, this library can convert between a google.type.Decimal (proto definition, Go docs) and a Go big.Float:

import (
  "github.com/googleapis/go-type-adapters/adapters"
  dpb "google.golang.org/genproto/type/decimal"
)

func main() {
  decimal := &dpb.Decimal{Value: "12345.678"}
  flt, err := adapters.DecimalToFloat(decimal)
  if err != nil {
    panic(err)
  }
  // flt is a Go *big.Float and can be used as such...
}

License

This software is made available under the Apache 2.0 license.

Directories

Path Synopsis
package adapters provides helper functions for the google.type protobuf messages (Decimal, Fraction, etc.).
package adapters provides helper functions for the google.type protobuf messages (Decimal, Fraction, etc.).

Jump to

Keyboard shortcuts

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