Skip to content

Commit

Permalink
Fixed google.protobuf.Timestamp transformation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Khabarov authored and ekhabarov committed Nov 21, 2019
1 parent c978960 commit a12d879
Show file tree
Hide file tree
Showing 61 changed files with 17,705 additions and 4,880 deletions.
28 changes: 20 additions & 8 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@
[prune]
go-tests = true
unused-packages = true

[[constraint]]
name = "github.com/pkg/errors"
version = "0.8.1"
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
VERSION=1.0.1-dev
VERSION=1.0.2-dev
BUILDTIME=$(shell date +"%Y-%m-%dT%T%z")
LDFLAGS= -ldflags '-X github.com/bold-commerce/protoc-gen-struct-transformer/generator.version=$(VERSION) -X github.com/bold-commerce/protoc-gen-struct-transformer/generator.buildTime=$(BUILDTIME)'

.PHONY: re-generate-example
.PHONY: re-generate-example imports generate install build version

re-generate-example:
protoc \
--proto_path=vendor/github.com/gogo:. \
--struct-transformer_out=package=transform,debug=false:. \
--struct-transformer_out=package=transform,debug=false,helper-package=helpers:. \
--gogofaster_out=Moptions/annotations.proto=github.com/bold-commerce/protoc-gen-struct-transformer/options:. \
./example/message.proto

.PHONY: imports
imports:
$(GOBIN)/goimports -w example/transform/message_transformer.go

.PHONY: generate
generate: re-generate-example imports
generate: version re-generate-example imports

install:
go install $(LDFLAGS)

build: OUTPUT=.
build:
go build $(LDFLAGS) -o $(OUTPUT)

version:
protoc-gen-struct-transformer --version
35 changes: 35 additions & 0 deletions example/helpers/helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Package helpers contains manually written functions for transforming custom
// types. Such package should be written by end-user because plugin has no idea
// which types could be used. It generates just function names for non-standard
// types.
package helpers

import (
"time"

"github.com/bold-commerce/protoc-gen-struct-transformer/example/nulls"
)

func TimeToNullsTime(t time.Time) nulls.Time {
return nulls.Time{Time: t}
}

func NullsTimeToTime(nt nulls.Time) time.Time {
return nt.Time
}

func TimePtrToNullsTimePtr(t *time.Time) *nulls.Time {
return &nulls.Time{Time: *t}
}

func NullsTimePtrToTimePtr(nt *nulls.Time) *time.Time {
return &nt.Time
}

func TimePtrToNullsTime(t *time.Time) nulls.Time {
return nulls.Time{Time: *t}
}

func NullsTimeToTimePtr(nt nulls.Time) *time.Time {
return &nt.Time
}
Loading

0 comments on commit a12d879

Please sign in to comment.