google / uuid

Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make uuid.Nil and other values as a constant

xorcare opened this issue · comments

Hello! I suggest to make uuid.Nil and other global uuids as constant to avoid modification at runtime.

One example of a problem I look in practice:

err = rows.Scan(
	&uuid.Nil, // for group by only
	//...
)

Such a seemingly innocuous change modifies the value of the uuid.Nil variable, and breaks the comparison.

var uid uuid.UUID

if uid == uuid.Nil {
	// This condition doesn't work.
}

Unfortunately there is no way to make a constant from an array, and my suggestion is meaningless. My mistake, sorry. 🥲