package main import ( "context" "encoding/json" "fmt" "io/ioutil" "os" "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi" "git.coopgo.io/coopgo-platform/mobility-accounts/storage" "google.golang.org/grpc" ) func main() { if len(os.Args) < 2 { fmt.Println("missing JSON file path") return } conn, err := grpc.Dial("dns:///localhost:8090", grpc.WithInsecure(), grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"round_robin"}`)) if err != nil { panic(err) } client := grpcapi.NewMobilityAccountsClient(conn) jsonFile, err := os.Open(os.Args[1]) byteValue, _ := ioutil.ReadAll(jsonFile) var account storage.Account json.Unmarshal(byteValue, &account) accountProto := grpcapi.AccountFromStorageType(&account) response, err := client.Register(context.Background(), &grpcapi.RegisterRequest{ Account: accountProto, }) if err != nil { panic(err) } jsonresponse, err := json.Marshal(response) if err != nil { panic(err) } fmt.Println(string(jsonresponse)) }