Groups
Groups
Sign in
Groups
Groups
golang-nuts
Conversations
About
Send feedback
Help
Ask about Golang Behavior
79 views
Skip to first unread message
febriananda pramudita
unread,
Mar 20, 2023, 11:44:54 AM
3/20/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
I was playing with protobuf marshaller recently and found this behavior
https://gist.github.com/FwP-pintu/448f8ecddf27987a7e5b8a103eda12cb
Is behavior: "nil slice with more than 0 capacity" is intended? Thank you.
Tamás Gulácsi
unread,
Mar 20, 2023, 12:15:28 PM
3/20/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
You should print cap(newMessage.Biawaks).
A nil slice cannot have non-zero capacity.
A nil slice and a zero-length slice is semantically equivalent.
Brian Candler
unread,
Mar 20, 2023, 12:25:48 PM
3/20/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
On Monday, 20 March 2023 at 16:15:28 UTC Tamás Gulácsi wrote:
You should print cap(newMessage.Biawaks).
Good catch on that typo :-)
FWIW, here it is as a playground link:
https://go.dev/play/p/CHaW3lMutXN
jake...@gmail.com
unread,
Mar 20, 2023, 12:26:41 PM
3/20/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
You have:
fmt
.
Println
(
"AFTER:"
,
newMessage
.
Biawaks
==
nil
,
cap
(
message
.
Biawaks
))
Did you mean:
fmt
.
Println
(
"AFTER:"
,
newMessage
.
Biawaks
==
nil
,
cap
(
newMessage
.
Biawaks
))
If so, then
Reply all
Reply to author
Forward
0 new messages