Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Question] It doesn't support to transform between Big-endian and Little-endian in net work #74

Open
Lei-2024 opened this issue Apr 4, 2018 · 1 comment

Comments

@Lei-2024
Copy link

Lei-2024 commented Apr 4, 2018

Hi

I meet a problem when I use this code to query from Sql Server.

I define a "UNIQUEIDENTIFIER" column in database, i use "id uuid.UUID" to query from database.

The right value in DB is "C74037D4-D0BA-471C-9200-31187972F117".

But what i got is "d43740c7-bad0-1c47-9200-31187972f117", it seemed that front third has wrong sequence.

I see UUID define is "type UUID [Size]byte", it seems that it don't care network sequence.

I use this package "database/sql" to query DB which will process UUID as []byte.

It seemed that there will be a problem when UUID used in network.

Best regards
Forston

@olavivaino
Copy link

olavivaino commented May 21, 2018

This is known as GUID/UUID endian issue. I'm not sure if byte order in UUID type is actually wrong, at least reading-writing to-from SQL server works just fine. However when UUID is converted to string or from string then endianness goes wrong. Usually its not neccessary to display UUID's as text but sometimes its needed and then it matters.
And sometimes its really needed to have UUID's as constants in the code and the most convenient way would be to have them in string format. This is another cenario when endianness issue gets on the way. Currently the only apparent way with this package is to convert UUID strings into wrong endianness and then convert it to UUID type. Thats a working workaround. But it would be really nice to have conversion from string handling both little and big endian.

Thers a blog post explaining backround of this endian issue: https://blogs.msdn.microsoft.com/openspecification/2013/10/08/guids-and-endianness-endi-an-ne-ssinguid-or-idne-na-en-ssinguid/

Thanks!

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

No branches or pull requests

2 participants