From 90ce1936e32f46de4c64752dfc54df75ec5758f0 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Wed, 14 Jan 2015 18:09:36 -0500 Subject: strings: add Compare(x, y string) int, for symmetry with bytes.Compare The implementation is the same assembly (or Go) routine. Change-Id: Ib937c461c24ad2d5be9b692b4eed40d9eb031412 Reviewed-on: https://go-review.googlesource.com/2828 Reviewed-by: Brad Fitzpatrick --- src/strings/strings_decl.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/strings/strings_decl.go') diff --git a/src/strings/strings_decl.go b/src/strings/strings_decl.go index 810a696af2..9dc2a9a6c6 100644 --- a/src/strings/strings_decl.go +++ b/src/strings/strings_decl.go @@ -6,3 +6,10 @@ package strings // IndexByte returns the index of the first instance of c in s, or -1 if c is not present in s. func IndexByte(s string, c byte) int // ../runtime/asm_$GOARCH.s + +// Compare returns an integer comparing two strings lexicographically. +// The result will be 0 if a==b, -1 if a < b, and +1 if a > b. +// +// In most cases it is simpler to use the built-in comparison operators +// ==, <, >, and so on. +func Compare(a, b string) int // ../runtime/noasm.go or ../runtime/asm_*.s -- cgit v1.3-5-g9baa