Skip to content

Commit

Permalink
[Service] Rename the ServiceId proto to Service (#150)
Browse files Browse the repository at this point in the history
Renamed the `ServiceId` proto to `Service` so `ServiceId.Id` is more semantic and less confusing.
---

Co-authored-by: Bryan White <[email protected]>
Co-authored-by: Daniel Olshansky <[email protected]>
Co-authored-by: Dima Kniazev <[email protected]>
  • Loading branch information
3 people committed Nov 8, 2023
1 parent a67b4ad commit cbc8e8a
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions pkg/client/gomock_reflect_3526400147/prog.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

package main

import (
"encoding/gob"
"flag"
"fmt"
"os"
"path"
"reflect"

"github.com/golang/mock/mockgen/model"

pkg_ "github.com/pokt-network/poktroll/pkg/client"
)

var output = flag.String("output", "", "The output file name, or empty to use stdout.")

func main() {
flag.Parse()

its := []struct{
sym string
typ reflect.Type
}{

{ "TxContext", reflect.TypeOf((*pkg_.TxContext)(nil)).Elem()},

{ "TxClient", reflect.TypeOf((*pkg_.TxClient)(nil)).Elem()},

}
pkg := &model.Package{
// NOTE: This behaves contrary to documented behaviour if the
// package name is not the final component of the import path.
// The reflect package doesn't expose the package name, though.
Name: path.Base("github.com/pokt-network/poktroll/pkg/client"),
}

for _, it := range its {
intf, err := model.InterfaceFromInterfaceType(it.typ)
if err != nil {
fmt.Fprintf(os.Stderr, "Reflection: %v\n", err)
os.Exit(1)
}
intf.Name = it.sym
pkg.Interfaces = append(pkg.Interfaces, intf)
}

outfile := os.Stdout
if len(*output) != 0 {
var err error
outfile, err = os.Create(*output)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to open output file %q", *output)
}
defer func() {
if err := outfile.Close(); err != nil {
fmt.Fprintf(os.Stderr, "failed to close output file %q", *output)
os.Exit(1)
}
}()
}

if err := gob.NewEncoder(outfile).Encode(pkg); err != nil {
fmt.Fprintf(os.Stderr, "gob encode: %v\n", err)
os.Exit(1)
}
}

0 comments on commit cbc8e8a

Please sign in to comment.