== Comparison operators implement

Don’t laugh at me, I am just curious why == can use to compare kinds of types. And I want to know == string comparision operators implement. I have already looked in the source code, it seems very difficult to find.

A Curious Student

Hi

I think you will find them here https://golang.org/src/internal/bytealg/
and one implementation in assembly for each plattform for example equal_amd64.s

1 Like

yes,I found it. But I don’t know connection with == and files equal_XXX.s. Maybe I am not very familiar with the grammar.

This i equals for strings (and maybe structs). Equality on types like ints, floats, runes is just single machine instructions so no function is required.

Maybe the internals are platform dependent. Assambley language differs from one processor to another

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.