I am generating uuid using "uuid.New()" method from "https://github.com/google/uuid" lib. Is there any method to remove hyphens from UUID?
The github.com/google/uuid
package represents a UUID as an array of 16 bytes. The array is the raw data of UUID, not the hex encoded representation with hyphens.
No action is required to remove hyphens because the hyphens are not part of the data in the UUID value.
If you want to remove the hyphens from the string representation returned by the String method, simply use strings.Replace()
as follows:
uuid := uuid.New().String()
uuidWithoutHyphens := strings.Replace(uuid, "-", "", -1)