Hey how do we use the go client library
# spicedb
d
Hey, how do we use the go client library to write relationships with a wildcard on the subject? I tried using "*" in place of the ObjectId, but that didn't work. Does the WriteRelationships() function support writing relationships with wildcards?
v
d
Thank you so much!
Hi, the code runs fine if they are inside a main function (after commenting out the server.WithDashboardAPI(util.HTTPServerConfig{HTTPEnabled: false}) line, as it caused an error.) However if the code is included within a Test* function when we are using the "testing" module to do tests, I got the following error: -- FAIL: TestAuthzedClientWithMockSpiceDB (0.00s) panic: interface conversion: *reflection.serverReflectionServer is not grpc_reflection_v1alpha.ServerReflectionServer: missing method ServerReflectionInfo [recovered] panic: interface conversion: *reflection.serverReflectionServer is not grpc_reflection_v1alpha.ServerReflectionServer: missing method ServerReflectionInfo Do you have any idea on how to resolve this issue? I think something is not compatible with the testing module. Appreciate any guidance! https://cdn.discordapp.com/attachments/1145281277130440734/1147300551793573919/message.txt
v
Hi @daweilics, I was able to run this test alongside the above code and couldn't reproduce your issue. Maybe related to conflicting grpc version imports in your Go app?
Copy code
package main

import (
    "context"
    "testing"

    v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
    "github.com/authzed/grpcutil"
    "github.com/stretchr/testify/require"
    "google.golang.org/grpc/codes"
)

func TestName(t *testing.T) {
    ctx, cancel := context.WithCancel(context.Background())
    defer cancel()
    srv, err := newServer(context.Background())
    require.NoError(t, err)

    conn, err := srv.GRPCDialContext(ctx)
    require.NoError(t, err)

    schemaSrv := v1.NewSchemaServiceClient(conn)

    go func() {
        if err := srv.Run(ctx); err != nil {
            require.NoError(t, err)
        }
    }()

    _, err = schemaSrv.ReadSchema(ctx, &v1.ReadSchemaRequest{})
    require.Error(t, err)
    grpcutil.RequireStatus(t, codes.NotFound, err)
}
https://cdn.discordapp.com/attachments/1145281277130440734/1148172346256003103/message.txt
d
Thanks for getting back to me! Yeah, it is because of the wrong grpc version I had. I got it working after changing the grpc version from v.1.57.0 to v1.54.0.