debian-mirror-gitlab/workhorse-vendor/github.com/googleapis/go-type-adapters
2023-01-13 15:02:22 +05:30
..
.github New upstream version 15.6.4+ds1 2023-01-13 15:02:22 +05:30
adapters New upstream version 15.6.4+ds1 2023-01-13 15:02:22 +05:30
.editorconfig New upstream version 15.6.4+ds1 2023-01-13 15:02:22 +05:30
CHANGELOG.md New upstream version 15.6.4+ds1 2023-01-13 15:02:22 +05:30
CODE_OF_CONDUCT.md New upstream version 15.6.4+ds1 2023-01-13 15:02:22 +05:30
CONTRIBUTING.md New upstream version 15.6.4+ds1 2023-01-13 15:02:22 +05:30
go.mod New upstream version 15.6.4+ds1 2023-01-13 15:02:22 +05:30
go.sum New upstream version 15.6.4+ds1 2023-01-13 15:02:22 +05:30
LICENSE New upstream version 15.6.4+ds1 2023-01-13 15:02:22 +05:30
README.md New upstream version 15.6.4+ds1 2023-01-13 15:02:22 +05:30
version.txt New upstream version 15.6.4+ds1 2023-01-13 15:02:22 +05:30

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 Golang 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 Golang 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 Golang *big.Float and can be used as such...
}

License

This software is made available under the Apache 2.0 license.