0

I am attempting to add a scan/value interface for automatic conversion for my custom structs. I was also able to implement both Value() and Scan() on a bool type, but when trying to implement it on something with a gocql.UUID field, I can't get the Scan() to work.

Any suggestions would be very much appreciated!

Short Example:

type Uid struct {
    gocql.UUID
}

func (u *Uid) Scan(value interface{}) error {
    ...
    if sv, err := driver.String.ConvertValue(value); err == nil {
    if v, ok := sv.(string); ok { // <---  THIS DOESN'T WORK
        parsedUUID, _ := gocql.ParseUUID(v)
        ...
    }
}

Full code: https://play.golang.org/p/ndCZTJZ5rb

1 Answer 1

1

The value was already structured as a byte array, so the solution ended up being:

fmt.Sprintf("%s", sv) 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.