Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

GetOrSet doesn't return cache miss message #112

Open
yintamaa opened this issue Jul 28, 2022 · 3 comments
Open

GetOrSet doesn't return cache miss message #112

yintamaa opened this issue Jul 28, 2022 · 3 comments

Comments

@yintamaa
Copy link

i wanna using GetOrSet to set a empty []byte("") for protoMessage when cache miss
but i have no idea how to determine cache miss, []byte("") will also make [value == nil] true

@coocood
Copy link
Owner

coocood commented Jul 28, 2022

You can set a single byte value like []byte{0} instead of empty []byte{}.

@yintamaa
Copy link
Author

You can set a single byte value like []byte{0} instead of empty []byte{}.

i haved also think about it,but proto.Unmarshal([]byte{0}) will get some error:invalid field number

@coocood
Copy link
Owner

coocood commented Jul 28, 2022

You can set a single byte value like []byte{0} instead of empty []byte{}.

i haved also think about it,but proto.Unmarshal([]byte{0}) will get some error:invalid field number

Then check the length before calling Unmarshal.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants