How do I go about finding the length of a string pointer which comes from a struct. Currently I am writing unit tests and want to see whether a string pointer is less than 250 characters. If r is my and myString is a string pointer.
This code is not valid:
if len(r.myString) > 256 {
return ErrStringTooLong
}
you can access an object with a star before pointer variable name for eg len(*r.myString)
You should explain why your code is not correct, and which error message you get. If it is a pointer to a string, you should dereference it by asterix *
len(*r.myString)