1

Is there a way to convert a Go type like []string to a set<text> using gocql? Or do I need to make my own mapper for that? I know gocql is able to convert a Go value to a Scylla/Cassandra value with their marshaller but I want to get the type, not the data value (gocql returns a byte array).

Thank you!

Sculas
  • 25
  • 2
  • 6

1 Answers1

1

I found that gocqltable does the trick for what I want. gocqltable has a mapper built in to convert Go types to Cassandra types, so I copied the type.go file into my project (since the original is unexported) and used it as specified in table.go.

You can find the stringTypeOf method I used here, and the usage of it here.

Sculas
  • 25
  • 2
  • 6
  • Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the external resource is unreachable or goes permanently offline. – arowell Sep 29 '21 at 22:15
  • 1
    Thanks for letting me know about that @arowell, I did not think of that. I've edited my message. I sadly cannot quote the code since it is fairly large. – Sculas Sep 30 '21 at 22:44