mirror of
https://blitiri.com.ar/repos/chasquid
synced 2026-01-08 17:51:57 +00:00
Update protobuf library to v2
There is a new protobuf library (and corresponding code generator) for Go: google.golang.org/protobuf. It is fairly compatible with the previous v1 API (github.com/golang/protobuf), but there are some changes. This patch adjusts the code and generated files to the new API. The on-wire/on-disk format remains unchanged so this should be transparent to the users.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
package config
|
||||
|
||||
// Generate the config protobuf.
|
||||
//go:generate protoc --go_out=. config.proto
|
||||
//go:generate protoc --go_out=. --go_opt=paths=source_relative config.proto
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"blitiri.com.ar/go/log"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"google.golang.org/protobuf/encoding/prototext"
|
||||
)
|
||||
|
||||
// Load the config from the given file.
|
||||
@@ -24,7 +24,7 @@ func Load(path string) (*Config, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = proto.UnmarshalText(string(buf), c)
|
||||
err = prototext.Unmarshal(buf, c)
|
||||
if err != nil {
|
||||
log.Errorf("Error parsing config: %v", err)
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user