== Comparison operators implement

(Pamleft) #1

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

(Johan Dahl) #2


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

(Pamleft) #3

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.

(Johan Dahl) #4

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.

(cosmos) #5

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

(system) closed #6

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