Skip to content

Commit

Permalink
Merge pull request #544 from jmarais/upstreamcommits0218
Browse files Browse the repository at this point in the history
Upstreamcommits0218
  • Loading branch information
jmarais authored Feb 18, 2019
2 parents 53c36c5 + 0971fc6 commit 4304ca6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
16 changes: 12 additions & 4 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,19 @@ To use this software, you must:
https://golang.org/doc/install
for details or, if you are using gccgo, follow the instructions at
https://golang.org/doc/install/gccgo
- Grab the code from the repository and install the proto package.
- Grab the code from the repository and install the `proto` package.
The simplest way is to run `go get -u github.com/golang/protobuf/protoc-gen-go`.
The compiler plugin, protoc-gen-go, will be installed in $GOBIN,
defaulting to $GOPATH/bin. It must be in your $PATH for the protocol
compiler, protoc, to find it.
The compiler plugin, `protoc-gen-go`, will be installed in `$GOPATH/bin`
unless `$GOBIN` is set. It must be in your `$PATH` for the protocol
compiler, `protoc`, to find it.
- If you need a particular version of `protoc-gen-go` (e.g., to match your
`proto` package version), one option is
```shell
GIT_TAG="v1.2.0" # change as needed
go get -d -u github.com/golang/protobuf/protoc-gen-go
git -C "$(go env GOPATH)"/src/github.com/golang/protobuf checkout $GIT_TAG
go install github.com/golang/protobuf/protoc-gen-go
```

This software has two parts: a 'protocol compiler plugin' that
generates Go source files that, once compiled, can access and manage
Expand Down
2 changes: 1 addition & 1 deletion types/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func DurationFromProto(p *Duration) (time.Duration, error) {
return 0, fmt.Errorf("duration: %#v is out of range for time.Duration", p)
}
if p.Nanos != 0 {
d += time.Duration(p.Nanos)
d += time.Duration(p.Nanos) * time.Nanosecond
if (d < 0) != (p.Nanos < 0) {
return 0, fmt.Errorf("duration: %#v is out of range for time.Duration", p)
}
Expand Down
6 changes: 2 additions & 4 deletions types/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,9 @@ func TimestampNow() *Timestamp {
// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.
// It returns an error if the resulting Timestamp is invalid.
func TimestampProto(t time.Time) (*Timestamp, error) {
seconds := t.Unix()
nanos := int32(t.Sub(time.Unix(seconds, 0)))
ts := &Timestamp{
Seconds: seconds,
Nanos: nanos,
Seconds: t.Unix(),
Nanos: int32(t.Nanosecond()),
}
if err := validateTimestamp(ts); err != nil {
return nil, err
Expand Down

0 comments on commit 4304ca6

Please sign in to comment.